Skip to content

Commit

Permalink
Merge pull request #23 from ameijer/storageclass
Browse files Browse the repository at this point in the history
Storageclass
  • Loading branch information
ameijer authored Apr 24, 2021
2 parents ec97258 + 33a4729 commit a74bcd3
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/k8s-as-helm)](https://artifacthub.io/packages/search?repo=k8s-as-helm)
[![Lint and Test Charts](https:/ameijer/k8s-as-helm/actions/workflows/ci.yaml/badge.svg)](https:/ameijer/k8s-as-helm/actions/workflows/ci.yaml)
# Kubernetes as Helm (k8s-as-helm)

<img src="https://ameijer.github.io/k8s-as-helm/icon.png" width="100" height="100">
Expand Down Expand Up @@ -36,7 +37,7 @@ API Object | Status | Link
`CronJob` | TODO |
`Deployment` | TODO |
`DaemonSet` | TODO |
`StorageClass` | TODO |
`StorageClass` | :heavy_check_mark: | [storageclass](https:/ameijer/k8s-as-helm/tree/master/charts/storageclass)
`Volume` | TODO |
`HoirizontalPodAutoscaler` | TODO |
`PodSecurityPolicy` | TODO |
Expand Down
16 changes: 16 additions & 0 deletions charts/storageclass/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v2
appVersion: "v1.0.0"
home: https:/ameijer/k8s-as-helm
description: Helm Chart representing a single Storage Class Kubernetes API object
name: storageclass
version: 1.0.0
icon: https://ameijer.github.io/k8s-as-helm/icon.png
maintainers:
- name: ameijer
url: https:/ameijer
keywords:
- storageclass
- storage
- class
- api
- primitives
2 changes: 2 additions & 0 deletions charts/storageclass/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

The Storage Class Chart {{ .Release.Name }} has been installed into your cluster!
46 changes: 46 additions & 0 deletions charts/storageclass/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Storage Class Chart
[![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/k8s-as-helm)](https://artifacthub.io/packages/search?repo=k8s-as-helm)

## TL;DR;

```console
$ helm repo add k8s-as-helm https://ameijer.github.io/k8s-as-helm/
$ helm install my-release k8s-as-helm/storageclass
```

## Introduction

Helm charts are great! They are really configurable and let you build complicated software stacks in seconds. Tools like [Helmfile](https:/roboll/helmfile) combine helm charts together to allow you to set up an environment consisting entirely of helm releases.

Let's say, though, you want to add additional code to a third party helm chart. You could make a new chart with your K8s API resource and the third party chart as a dependency, but that requires maintenance which might not be worth it if you only needed a single additional resource created. That's where k8s-as-helm charts come in. These charts wrap a single Kubernetes resource in a helm chart with all the key parameters exposed.

The storageclass chart deploys a single Kubernetes [Storage Class](https://kubernetes.io/docs/concepts/storage/storage-classes/) object.

## Installation

```console
$ helm repo add k8s-as-helm https://ameijer.github.io/k8s-as-helm/
$ helm install my-release k8s-as-helm/storageclass
```

## Configuration

The following table lists the configurable parameters of the storageclass chart and their default values.

Parameter | Description | Default
--- | --- | ---
`nameOverride` | override name of the chart component | .Release.Name
`apiVersion` | api version of k8s object | `"v1"`
`annotations` | annotations in yaml map format to be added to the object | `null`
`labels` | labels to add to Storage Class object | `null`
`defaultClass` | boolean to set annotation designating this object as the default storage class | `true`
`bindingMode` | the binding mode for PVCs using this storage class | `WaitForFirstConsumer`
`provisioner` | (REQUIRED) the provisioner to use for this class | ""
`allowVolumeExpansion` | allow expansion of PVCs using this storage class | true
`reclaimPolicy` | configures the retention of the PVC when dynamically created using this class | `Delete`
`parameters` | storage class parameters used for volumes created with this storage class | `null`
`mountOptions` | options used by volumes created by this storage class | `null`

## Example Configuration

For some examples of values used to configure this chart, see [the ci/example values for this chart](./ci/ci-values.yaml)
12 changes: 12 additions & 0 deletions charts/storageclass/ci/ci-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
labels:
"test": "true"
parameters:
testParam: "testVal"

provisioner: "local-path"

annotations:
com.k8s.as.helm.annotation: "test"

mountOptions:
- test
14 changes: 14 additions & 0 deletions charts/storageclass/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Setup a chart name
*/}}
{{- define "storageclass.name" -}}
{{- default .Release.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for the object
*/}}
{{- define "apiVersion" -}}
{{- default "storage.k8s.io/v1" .Values.apiVersion -}}
{{- end -}}
36 changes: 36 additions & 0 deletions charts/storageclass/templates/storageclass.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: {{ template "apiVersion" }}
kind: StorageClass
metadata:
labels:
app: {{ template "storageclass.name" . }}
chart: {{ .Chart.Name }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- if .Values.labels }}
{{ toYaml .Values.labels | indent 4 }}
{{- end }}
name: {{ template "storageclass.name" . }}
{{- if or .Values.annotations .Values.defaultClass }}
annotations:
{{ toYaml .Values.annotations | indent 4}}
{{- end }}
{{- if .Values.defaultClass }}
storageclass.kubernetes.io/is-default-class: "true"
{{- end }}
volumeBindingMode: {{ .Values.bindingMode }}
provisioner: {{ .Values.provisioner }}
allowVolumeExpansion: {{ .Values.allowVolumeExpansion }}
reclaimPolicy: {{ .Values.reclaimPolicy }}
{{- if .Values.parameters }}
parameters:
{{- range $key, $value := .Values.parameters }}
{{ $key }}: {{ $value }}
{{- end }}
{{- end }}

{{- if .Values.mountOptions }}
mountOptions:
{{- range .Values.mountOptions }}
- {{ . }}
{{- end }}
{{- end }}
4 changes: 4 additions & 0 deletions charts/storageclass/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bindingMode: WaitForFirstConsumer
defaultClass: true
allowVolumeExpansion: true
reclaimPolicy: Delete

0 comments on commit a74bcd3

Please sign in to comment.