diff --git a/README.md b/README.md index f5fc96e..98487df 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,6 @@ | [![chart downloads](https://img.shields.io/github/downloads/ccremer/charts/emby-0.2.3/total)](https://github.com/ccremer/charts/releases/tag/emby-0.2.3) | [emby](charts/emby/README.md) | | [![chart downloads](https://img.shields.io/github/downloads/ccremer/charts/fronius-exporter-0.8.1/total)](https://github.com/ccremer/charts/releases/tag/fronius-exporter-0.8.1) | [fronius-exporter](charts/fronius-exporter/README.md) | | [![chart downloads](https://img.shields.io/github/downloads/ccremer/charts/fronius-stack-0.1.5/total)](https://github.com/ccremer/charts/releases/tag/fronius-stack-0.1.5) | [fronius-stack](charts/fronius-stack/README.md) | -| [![chart downloads](https://img.shields.io/github/downloads/ccremer/charts/kubernetes-zfs-provisioner-1.1.3/total)](https://github.com/ccremer/charts/releases/tag/kubernetes-zfs-provisioner-1.1.3) | [kubernetes-zfs-provisioner](charts/kubernetes-zfs-provisioner/README.md) | | [![chart downloads](https://img.shields.io/github/downloads/ccremer/charts/samba-0.1.1/total)](https://github.com/ccremer/charts/releases/tag/samba-0.1.1) | [samba](charts/samba/README.md) | | [![chart downloads](https://img.shields.io/github/downloads/ccremer/charts/stiebeleltron-exporter-0.1.1/total)](https://github.com/ccremer/charts/releases/tag/stiebeleltron-exporter-0.1.1) | [stiebeleltron-exporter](charts/stiebeleltron-exporter/README.md) | | [![chart downloads](https://img.shields.io/github/downloads/ccremer/charts/stiebeleltron-stack-0.1.2/total)](https://github.com/ccremer/charts/releases/tag/stiebeleltron-stack-0.1.2) | [stiebeleltron-stack](charts/stiebeleltron-stack/README.md) | diff --git a/charts/kubernetes-zfs-provisioner/.helmignore b/charts/kubernetes-zfs-provisioner/.helmignore deleted file mode 100644 index 13f45b2..0000000 --- a/charts/kubernetes-zfs-provisioner/.helmignore +++ /dev/null @@ -1,28 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*.orig -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ - -# Unit tests -test/ -*gotmpl* - diff --git a/charts/kubernetes-zfs-provisioner/Chart.yaml b/charts/kubernetes-zfs-provisioner/Chart.yaml deleted file mode 100644 index b552be1..0000000 --- a/charts/kubernetes-zfs-provisioner/Chart.yaml +++ /dev/null @@ -1,24 +0,0 @@ -apiVersion: v2 -name: kubernetes-zfs-provisioner -description: Dynamic ZFS persistent volume provisioner for Kubernetes - -# A chart can be either an 'application' or a 'library' chart. -# -# Application charts are a collection of templates that can be packaged into versioned archives -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# a dependency of application charts to inject those utilities and functions into the rendering -# pipeline. Library charts do not define any templates and therefore cannot be deployed. -# type: application - -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -version: 1.1.3 - -# This is the version number of the application being deployed. This version number should be -# incremented each time you make changes to the application. -#appVersion: see image.tag - -# Licensing of https://commons.wikimedia.org/wiki/File:Openzfs.svg applies -icon: https://upload.wikimedia.org/wikipedia/commons/thumb/7/7f/Openzfs.svg/257px-Openzfs.svg.png diff --git a/charts/kubernetes-zfs-provisioner/README.gotmpl.md b/charts/kubernetes-zfs-provisioner/README.gotmpl.md deleted file mode 100644 index 7a15ba5..0000000 --- a/charts/kubernetes-zfs-provisioner/README.gotmpl.md +++ /dev/null @@ -1,9 +0,0 @@ -## Upgrading from 0.x charts - -There are some breaking changes from 0.x to 1.x versions. - -* The `storageclass.classes` array is now empty. - Where it previously contained an example, the example is removed as a default value. - The example is still in `values.yaml` in form of YAML comments. -* The `image.registry` has changed from `docker.io` to `quay.io` due to Docker Hub's pull limit. -* Bumped `image.tag` to `v1.0.0` diff --git a/charts/kubernetes-zfs-provisioner/README.md b/charts/kubernetes-zfs-provisioner/README.md index c9e2cde..6a1b8c8 100644 --- a/charts/kubernetes-zfs-provisioner/README.md +++ b/charts/kubernetes-zfs-provisioner/README.md @@ -1,56 +1,10 @@ -# kubernetes-zfs-provisioner +# ⚠️ THIS CHART HAS MOVED -![Version: 1.1.3](https://img.shields.io/badge/Version-1.1.3-informational?style=flat-square) +This chart is no longer maintained here. +The chart previously available here has been moved to https://github.com/ccremer/kubernetes-zfs-provisioner/tree/master/charts/kubernetes-zfs-provisioner. -Dynamic ZFS persistent volume provisioner for Kubernetes +To communicate a clear cut, a new chart is released in version v2.0.0 with a few changes. +The releases from v2.0.0 and onwards are only available in the new location. +All previously released chart versions remain in the this repository. -## Installation - -```bash -helm repo add ccremer https://ccremer.github.io/charts -helm install kubernetes-zfs-provisioner ccremer/kubernetes-zfs-provisioner -``` -## Upgrading from 0.x charts - -There are some breaking changes from 0.x to 1.x versions. - -* The `storageclass.classes` array is now empty. - Where it previously contained an example, the example is removed as a default value. - The example is still in `values.yaml` in form of YAML comments. -* The `image.registry` has changed from `docker.io` to `quay.io` due to Docker Hub's pull limit. -* Bumped `image.tag` to `v1.0.0` - -## Values - -| Key | Type | Default | Description | -|-----|------|---------|-------------| -| affinity | object | `{}` | | -| env | object | `{}` | A dict with KEY: VALUE pairs | -| fullnameOverride | string | `""` | | -| hostAliases | object | `{}` | A dict with `{ip, hostnames array}` to configure custom entries in /etc/hosts. See [values.yaml](./values.yaml) for an example. | -| image.pullPolicy | string | `"IfNotPresent"` | | -| image.registry | string | `"quay.io"` | Container image registry | -| image.repository | string | `"ccremer/zfs-provisioner"` | Location of the container image | -| image.tag | string | `"v1.1.0"` | Container image tag | -| imagePullSecrets | list | `[]` | | -| nameOverride | string | `""` | | -| nodeSelector | object | `{}` | Reminder: This has no effect on any PVs, but maybe you want the provisioner pod running on certain nodes. | -| podSecurityContext | object | `{}` | If you encounter **issues with SSH, set `podSecurityContext.fsGroup=100`**, as the SSH files might not be readable to the container user `zfs` with uid 100. | -| provisioner.instance | string | `"pv.kubernetes.io/zfs"` | Provisoner instance name if multiple are running (multiple instances are not required for managing multiple ZFS hosts) | -| rbac.create | bool | `false` | **Required for first time deployments** Grant the service account the necessary permissions, | -| replicaCount | int | `1` | Usually `1` is fine | -| resources.limits.memory | string | `"40Mi"` | | -| resources.requests.cpu | string | `"50m"` | | -| resources.requests.memory | string | `"20Mi"` | | -| securityContext | object | `{}` | | -| serviceAccount.annotations | object | `{}` | Annotations to add to the service account | -| serviceAccount.create | bool | `true` | Specifies whether a service account should be created | -| serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template | -| ssh.config | string | `""` | **Required.** ssh_config(5)-compatible file content to configure SSH options when connecting | -| ssh.externalSecretName | string | `""` | If SSH secrets are managed externally, specify the name | -| ssh.identities | object | `{}` | **Required.** Provide a private key for each SSH identity. See [values.yaml](./values.yaml) for an example | -| ssh.knownHosts | list | `[]` | **Required.** List of {host, pubKey} dicts where the public key of each host is configured | -| ssh.mountPath | string | `"/home/zfs/.ssh"` | The path where the SSH config and identities are mounted | -| storageClass.classes | list | `[]` | Storage classes to create. See [values.yaml](values.yaml) for an example. | -| storageClass.create | bool | `false` | Whether to create storage classes for this provisioner. | -| tolerations | list | `[]` | | +To see the Helm values of the 0.x and 1.x charts, switch the file viewer to the respective release tags. diff --git a/charts/kubernetes-zfs-provisioner/templates/_helpers.tpl b/charts/kubernetes-zfs-provisioner/templates/_helpers.tpl deleted file mode 100644 index 91cb319..0000000 --- a/charts/kubernetes-zfs-provisioner/templates/_helpers.tpl +++ /dev/null @@ -1,70 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "kubernetes-zfs-provisioner.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "kubernetes-zfs-provisioner.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- if contains $name .Release.Name -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} -{{- end -}} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "kubernetes-zfs-provisioner.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Common labels -*/}} -{{- define "kubernetes-zfs-provisioner.labels" -}} -helm.sh/chart: {{ include "kubernetes-zfs-provisioner.chart" . }} -{{ include "kubernetes-zfs-provisioner.selectorLabels" . }} -{{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} -{{- end }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end -}} - -{{/* -Selector labels -*/}} -{{- define "kubernetes-zfs-provisioner.selectorLabels" -}} -app.kubernetes.io/name: {{ include "kubernetes-zfs-provisioner.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end -}} - -{{/* -Create the name of the service account to use -*/}} -{{- define "kubernetes-zfs-provisioner.serviceAccountName" -}} -{{- if .Values.serviceAccount.create -}} - {{ default (include "kubernetes-zfs-provisioner.fullname" .) .Values.serviceAccount.name }} -{{- else -}} - {{ default "default" .Values.serviceAccount.name }} -{{- end -}} -{{- end -}} - -{{/* -Create the name of the secret to use -*/}} -{{- define "kubernetes-zfs-provisioner.secretName" -}} - {{ default (include "kubernetes-zfs-provisioner.fullname" .) .Values.ssh.externalSecretName }} -{{- end -}} diff --git a/charts/kubernetes-zfs-provisioner/templates/deployment.yaml b/charts/kubernetes-zfs-provisioner/templates/deployment.yaml deleted file mode 100644 index 56ec32c..0000000 --- a/charts/kubernetes-zfs-provisioner/templates/deployment.yaml +++ /dev/null @@ -1,75 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "kubernetes-zfs-provisioner.fullname" . }} - labels: - {{- include "kubernetes-zfs-provisioner.labels" . | nindent 4 }} -spec: - replicas: {{ .Values.replicaCount }} - selector: - matchLabels: - {{- include "kubernetes-zfs-provisioner.selectorLabels" . | nindent 6 }} - template: - metadata: - labels: - {{- include "kubernetes-zfs-provisioner.selectorLabels" . | nindent 8 }} - spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ include "kubernetes-zfs-provisioner.serviceAccountName" . }} - securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} - containers: - - name: provisioner - securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - env: - - name: ZFS_PROVISIONER_INSTANCE - value: {{ .Values.provisioner.instance }} - {{- with .Values.env }} - {{- range $key, $value := . }} - - name: {{ $key }} - value: {{ $value }} - {{- end }} - {{- end }} - ports: - - name: http - containerPort: 8080 - volumeMounts: - - name: ssh - mountPath: {{ .Values.ssh.mountPath }} - resources: - {{- toYaml .Values.resources | nindent 12 }} - {{- with .Values.hostAliases }} - hostAliases: - {{- range $ip, $hostnames := . }} - - ip: {{ $ip }} - hostnames: - {{- range . }} - - {{ . }} - {{- end }} - {{- end }} - {{- end }} - volumes: - {{- with .Values.ssh }} - - name: ssh - secret: - secretName: {{ include "kubernetes-zfs-provisioner.secretName" $ }} - defaultMode: 0600 - {{- end }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} diff --git a/charts/kubernetes-zfs-provisioner/templates/rbac.yaml b/charts/kubernetes-zfs-provisioner/templates/rbac.yaml deleted file mode 100644 index e5b40e7..0000000 --- a/charts/kubernetes-zfs-provisioner/templates/rbac.yaml +++ /dev/null @@ -1,32 +0,0 @@ -{{- if .Values.rbac.create -}} ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: {{ include "kubernetes-zfs-provisioner.fullname" . }}-binding - labels: - {{- include "kubernetes-zfs-provisioner.labels" . | nindent 4 }} -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: system:persistent-volume-provisioner -subjects: -- kind: ServiceAccount - name: {{ include "kubernetes-zfs-provisioner.serviceAccountName" . }} - namespace: {{ .Release.Namespace }} ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: {{ include "kubernetes-zfs-provisioner.fullname" . }}-leaderelection - labels: - {{- include "kubernetes-zfs-provisioner.labels" . | nindent 4 }} -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: system:controller:endpoint-controller -subjects: -- kind: ServiceAccount - name: {{ include "kubernetes-zfs-provisioner.serviceAccountName" . }} - namespace: {{ .Release.Namespace }} -{{- end -}} diff --git a/charts/kubernetes-zfs-provisioner/templates/secret.yaml b/charts/kubernetes-zfs-provisioner/templates/secret.yaml deleted file mode 100644 index d1adee7..0000000 --- a/charts/kubernetes-zfs-provisioner/templates/secret.yaml +++ /dev/null @@ -1,22 +0,0 @@ -{{- if not .Values.ssh.externalSecretName -}} -apiVersion: v1 -kind: Secret -metadata: - name: {{ include "kubernetes-zfs-provisioner.fullname" . }} - labels: - {{- include "kubernetes-zfs-provisioner.labels" . | nindent 4 }} -stringData: - {{- with .Values.ssh.knownHosts }} - known_hosts: | - {{- range . }} - {{ .host }} {{ .pubKey }} - {{ end }} - {{- end }} - {{- with .Values.ssh.config }} - config: | - {{- . | nindent 4 }} - {{- end }} - {{- range $key,$value := .Values.ssh.identities }} - {{ $key -}}: {{ $value | toYaml | indent 2 }} - {{- end }} -{{- end }} diff --git a/charts/kubernetes-zfs-provisioner/templates/serviceaccount.yaml b/charts/kubernetes-zfs-provisioner/templates/serviceaccount.yaml deleted file mode 100644 index 167572f..0000000 --- a/charts/kubernetes-zfs-provisioner/templates/serviceaccount.yaml +++ /dev/null @@ -1,12 +0,0 @@ -{{- if .Values.serviceAccount.create -}} -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ include "kubernetes-zfs-provisioner.serviceAccountName" . }} - labels: - {{- include "kubernetes-zfs-provisioner.labels" . | nindent 4 }} - {{- with .Values.serviceAccount.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end -}} diff --git a/charts/kubernetes-zfs-provisioner/templates/storageclass.yaml b/charts/kubernetes-zfs-provisioner/templates/storageclass.yaml deleted file mode 100644 index f069c07..0000000 --- a/charts/kubernetes-zfs-provisioner/templates/storageclass.yaml +++ /dev/null @@ -1,19 +0,0 @@ -{{- if .Values.storageClass.create -}} -{{- range .Values.storageClass.classes }} ---- -kind: StorageClass -apiVersion: storage.k8s.io/v1 -metadata: - name: {{ .name }} - labels: - {{- include "kubernetes-zfs-provisioner.labels" $ | nindent 4 }} -provisioner: {{ $.Values.provisioner.instance }} -reclaimPolicy: {{ .policy | default "Delete" }} -parameters: - parentDataset: {{ .parentDataset }} - hostname: {{ .hostName }} - type: {{ .type | default "nfs" }} - node: {{ .node | default "''" }} - shareProperties: {{ .shareProperties | default "''" }} -{{- end }} -{{- end }} diff --git a/charts/kubernetes-zfs-provisioner/test/deployment_test.go b/charts/kubernetes-zfs-provisioner/test/deployment_test.go deleted file mode 100644 index f4cf450..0000000 --- a/charts/kubernetes-zfs-provisioner/test/deployment_test.go +++ /dev/null @@ -1,71 +0,0 @@ -package test - -import ( - "testing" - "unsafe" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - v1 "k8s.io/api/core/v1" - - "github.com/gruntwork-io/terratest/modules/helm" - appv1 "k8s.io/api/apps/v1" -) - -var tplDeployment = []string{"templates/deployment.yaml"} - -func Test_Deployment_ShouldRender_EnvironmentVariables(t *testing.T) { - options := &helm.Options{ - ValuesFiles: []string{"values/deployment_1.yaml"}, - } - - expectedKeys := []string{"KEY1", "ANOTHER_KEY", "ZFS_PROVISIONER_INSTANCE"} - expectedValues := []string{"value", "another value", "pv.kubernetes.io/zfs"} - - output := helm.RenderTemplate(t, options, helmChartPath, releaseName, tplDeployment) - - var deployment appv1.Deployment - helm.UnmarshalK8SYaml(t, output, &deployment) - - envs := deployment.Spec.Template.Spec.Containers[0].Env - assert.Equal(t, len(envs), 3) - for i, _ := range envs { - require.Contains(t, envs, v1.EnvVar{ - Name: expectedKeys[i], - Value: expectedValues[i], - }) - } -} - -func Test_Deployment_ShouldRender_SshVolumes_IfEnabled(t *testing.T) { - options := &helm.Options{ - ValuesFiles: []string{"values/deployment_2.yaml"}, - } - - output := helm.RenderTemplate(t, options, helmChartPath, releaseName, tplDeployment) - - var deployment appv1.Deployment - helm.UnmarshalK8SYaml(t, output, &deployment) - - volumeMounts := deployment.Spec.Template.Spec.Containers[0].VolumeMounts - require.Contains(t, volumeMounts, v1.VolumeMount{ - Name: "ssh", - MountPath: "/home/zfs/.ssh", - }) - - volumes := deployment.Spec.Template.Spec.Volumes - require.Contains(t, volumes, v1.Volume{ - Name: "ssh", - VolumeSource: v1.VolumeSource{ - Secret: &v1.SecretVolumeSource{ - SecretName: releaseName + "-kubernetes-zfs-provisioner", - DefaultMode: getIntPointer(0600), - }, - }, - }) -} - -func getIntPointer(mode int) *int32 { - i := *((*int32)(unsafe.Pointer(&mode))) - return &i -} diff --git a/charts/kubernetes-zfs-provisioner/test/main_test.go b/charts/kubernetes-zfs-provisioner/test/main_test.go deleted file mode 100644 index b8c62fa..0000000 --- a/charts/kubernetes-zfs-provisioner/test/main_test.go +++ /dev/null @@ -1,6 +0,0 @@ -package test - -var ( - helmChartPath = ".." - releaseName = "test-release" -) diff --git a/charts/kubernetes-zfs-provisioner/test/secret_test.go b/charts/kubernetes-zfs-provisioner/test/secret_test.go deleted file mode 100644 index 0eff9db..0000000 --- a/charts/kubernetes-zfs-provisioner/test/secret_test.go +++ /dev/null @@ -1,58 +0,0 @@ -package test - -import ( - "testing" - - "github.com/gruntwork-io/terratest/modules/helm" - "github.com/stretchr/testify/assert" - v1 "k8s.io/api/core/v1" -) - -var tplSecret = []string{"templates/secret.yaml"} - -func Test_Secret_GivenNoExternalSecret_WhenConfigSet_ThenRenderConfigFile(t *testing.T) { - options := &helm.Options{ - ValuesFiles: []string{"values/secret_1.yaml"}, - } - - output := helm.RenderTemplate(t, options, helmChartPath, releaseName, tplSecret) - - var secret v1.Secret - helm.UnmarshalK8SYaml(t, output, &secret) - - config := secret.StringData["config"] - assert.Equal(t, `Host test - IdentityFile ~/.ssh/id_ed25519`, config) -} - -func Test_Secret_GivenNoExternalSecret_WhenIdentitiesSet_ThenRenderPrivateKeys(t *testing.T) { - options := &helm.Options{ - ValuesFiles: []string{"values/secret_2.yaml"}, - } - - output := helm.RenderTemplate(t, options, helmChartPath, releaseName, tplSecret) - - var secret v1.Secret - helm.UnmarshalK8SYaml(t, output, &secret) - - expected := "----\nPRIVATE_KEY\n----" - - assert.Contains(t, secret.StringData["id_rsa"], expected) - assert.Contains(t, secret.StringData["id_ed25519"], expected) -} - -func Test_Secret_GivenNoExternalSecret_WhenKnownHostsSet_ThenRenderHostKeys(t *testing.T) { - options := &helm.Options{ - ValuesFiles: []string{"values/secret_3.yaml"}, - } - - output := helm.RenderTemplate(t, options, helmChartPath, releaseName, tplSecret) - - var secret v1.Secret - helm.UnmarshalK8SYaml(t, output, &secret) - - expectedHost := "test" - expectedPubKey := "ssh-rsa asdf" - - assert.Contains(t, secret.StringData["known_hosts"], expectedHost+" "+expectedPubKey) -} diff --git a/charts/kubernetes-zfs-provisioner/test/storageclass_test.go b/charts/kubernetes-zfs-provisioner/test/storageclass_test.go deleted file mode 100644 index 5583d7c..0000000 --- a/charts/kubernetes-zfs-provisioner/test/storageclass_test.go +++ /dev/null @@ -1,78 +0,0 @@ -package test - -import ( - "testing" - - "github.com/gruntwork-io/terratest/modules/helm" - "github.com/stretchr/testify/assert" - core "k8s.io/api/core/v1" - v1 "k8s.io/api/storage/v1" -) - -var tplStorageclass = []string{"templates/storageclass.yaml"} - -func Test_Storageclass_GivenClassesEnabled_WhenNoPolicyDefined_ThenRenderDefault(t *testing.T) { - options := &helm.Options{ - ValuesFiles: []string{"values/storageclass_1.yaml"}, - SetValues: map[string]string{ - "storageClass.classes[0].policy": "", - }, - } - - output := helm.RenderTemplate(t, options, helmChartPath, releaseName, tplStorageclass) - - var class v1.StorageClass - helm.UnmarshalK8SYaml(t, output, &class) - - expectedPolicy := core.PersistentVolumeReclaimDelete - assert.Equal(t, &expectedPolicy, class.ReclaimPolicy) -} - -func Test_StorageClass_GivenClassesEnabled_WhenNoTypeDefined_ThenRenderDefault(t *testing.T) { - options := &helm.Options{ - ValuesFiles: []string{"values/storageclass_1.yaml"}, - } - - output := helm.RenderTemplate(t, options, helmChartPath, releaseName, tplStorageclass) - - var class v1.StorageClass - helm.UnmarshalK8SYaml(t, output, &class) - - assert.Equal(t, "nfs", class.Parameters["type"]) -} - -func Test_StorageClass_GivenClassesEnabled_WhenNodeDefined_ThenRenderNodeName(t *testing.T) { - options := &helm.Options{ - SetValues: map[string]string{ - "storageClass.create": "true", - "storageClass.classes[0].node": "host", - "storageClass.classes[0].type": "hostpath", - }, - } - - output := helm.RenderTemplate(t, options, helmChartPath, releaseName, tplStorageclass) - - var class v1.StorageClass - helm.UnmarshalK8SYaml(t, output, &class) - - assert.Equal(t, "host", class.Parameters["node"]) - assert.Equal(t, "hostpath", class.Parameters["type"]) -} - -func Test_StorageClass_GivenClassesEnabled_WhenAdditionalParametersUndefined_ThenRenderEmptyValues(t *testing.T) { - options := &helm.Options{ - ValuesFiles: []string{"values/storageclass_1.yaml"}, - SetValues: map[string]string{ - "storageClass.classes[0].node": "", - "storageClass.classes[0].shareProperties": "", - }, - } - - output := helm.RenderTemplate(t, options, helmChartPath, releaseName, tplStorageclass) - - var class v1.StorageClass - helm.UnmarshalK8SYaml(t, output, &class) - - assert.Equal(t, "", class.Parameters["shareProperties"]) - assert.Equal(t, "", class.Parameters["node"]) -} diff --git a/charts/kubernetes-zfs-provisioner/test/values/deployment_1.yaml b/charts/kubernetes-zfs-provisioner/test/values/deployment_1.yaml deleted file mode 100644 index 9ac9ebf..0000000 --- a/charts/kubernetes-zfs-provisioner/test/values/deployment_1.yaml +++ /dev/null @@ -1,3 +0,0 @@ -env: - KEY1: value - ANOTHER_KEY: another value diff --git a/charts/kubernetes-zfs-provisioner/test/values/deployment_2.yaml b/charts/kubernetes-zfs-provisioner/test/values/deployment_2.yaml deleted file mode 100644 index a480eba..0000000 --- a/charts/kubernetes-zfs-provisioner/test/values/deployment_2.yaml +++ /dev/null @@ -1,5 +0,0 @@ -ssh: - identities: - id_rsa: | - ----BEGIN---- - ----END---- diff --git a/charts/kubernetes-zfs-provisioner/test/values/secret_1.yaml b/charts/kubernetes-zfs-provisioner/test/values/secret_1.yaml deleted file mode 100644 index 964cd3d..0000000 --- a/charts/kubernetes-zfs-provisioner/test/values/secret_1.yaml +++ /dev/null @@ -1,5 +0,0 @@ -ssh: - externalSecretName: "" - config: | - Host test - IdentityFile ~/.ssh/id_ed25519 diff --git a/charts/kubernetes-zfs-provisioner/test/values/secret_2.yaml b/charts/kubernetes-zfs-provisioner/test/values/secret_2.yaml deleted file mode 100644 index 4447d1a..0000000 --- a/charts/kubernetes-zfs-provisioner/test/values/secret_2.yaml +++ /dev/null @@ -1,11 +0,0 @@ -ssh: - externalSecretName: "" - identities: - id_ed25519: | - ---- - PRIVATE_KEY - ---- - id_rsa: | - ---- - PRIVATE_KEY - ---- diff --git a/charts/kubernetes-zfs-provisioner/test/values/secret_3.yaml b/charts/kubernetes-zfs-provisioner/test/values/secret_3.yaml deleted file mode 100644 index 1e0bfa8..0000000 --- a/charts/kubernetes-zfs-provisioner/test/values/secret_3.yaml +++ /dev/null @@ -1,5 +0,0 @@ -ssh: - externalSecretName: "" - knownHosts: - - host: test - pubKey: ssh-rsa asdf diff --git a/charts/kubernetes-zfs-provisioner/test/values/storageclass_1.yaml b/charts/kubernetes-zfs-provisioner/test/values/storageclass_1.yaml deleted file mode 100644 index bbbf032..0000000 --- a/charts/kubernetes-zfs-provisioner/test/values/storageclass_1.yaml +++ /dev/null @@ -1,4 +0,0 @@ -storageClass: - create: true - classes: - - name: test diff --git a/charts/kubernetes-zfs-provisioner/values.yaml b/charts/kubernetes-zfs-provisioner/values.yaml deleted file mode 100644 index 190f74e..0000000 --- a/charts/kubernetes-zfs-provisioner/values.yaml +++ /dev/null @@ -1,120 +0,0 @@ -# Default values for kubernetes-zfs-provisioner. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -# -- Usually `1` is fine -replicaCount: 1 - -image: - # -- Location of the container image - repository: ccremer/zfs-provisioner - # -- Container image registry - registry: quay.io - # -- Container image tag - tag: v1.1.0 - pullPolicy: IfNotPresent - -imagePullSecrets: [] -nameOverride: "" -fullnameOverride: "" - -provisioner: - # -- Provisoner instance name if multiple are running (multiple - # instances are not required for managing multiple ZFS hosts) - instance: pv.kubernetes.io/zfs - -storageClass: - # -- Whether to create storage classes for this provisioner. - create: false - # -- Storage classes to create. See [values.yaml](values.yaml) for an example. - classes: [] - # - name: zfs - # # -- The provisioners connects through SSH to this ZFS host - # hostName: storage-1.domain.tld - # # -- Existing dataset on the target ZFS host - # parentDataset: tank/kubernetes - # # -- The reclaim policy supported by the provisioner - # policy: "Delete" - # # -- NFS export properties (see `exports(5)`) - # shareProperties: "" - # # -- Provision type, one of [`nfs`, `hostpath`] - # type: "nfs" - # # -- Override `kubernetes.io/hostname` from `hostName` parameter for - # # `HostPath` node affinity - # node: "" - -ssh: - # -- If SSH secrets are managed externally, specify the name - externalSecretName: "" - # -- The path where the SSH config and identities are mounted - mountPath: "/home/zfs/.ssh" - # -- **Required.** ssh_config(5)-compatible file content to configure SSH options when connecting - config: "" - # config: | - # Host my-host - # IdentityFile ~/.ssh/id_ed25519 - # User zfs - - # -- **Required.** Provide a private key for each SSH identity. - # See [values.yaml](./values.yaml) for an example - identities: {} -# id_ed25519: | -# -----BEGIN OPENSSH PRIVATE KEY----- -# ... -# -----END OPENSSH PRIVATE KEY----- - - # -- **Required.** List of {host, pubKey} dicts where the public key of each host is configured - knownHosts: [] -# - host: my-host -# pubKey: ssh-ed25519 AAAAC3NzaC... - -# -- A dict with KEY: VALUE pairs -env: {} - -# -- A dict with `{ip, hostnames array}` to configure custom entries in /etc/hosts. -# See [values.yaml](./values.yaml) for an example. -hostAliases: {} -# 192.168.1.1: -# - my-custom-host.name - -serviceAccount: - # -- Specifies whether a service account should be created - create: true - # -- Annotations to add to the service account - annotations: {} - # -- The name of the service account to use. - # If not set and create is true, a name is generated using the fullname template - name: "" - -rbac: - # -- **Required for first time deployments** Grant the service account - # the necessary permissions, - create: false - -# -- If you encounter **issues with SSH, set `podSecurityContext.fsGroup=100`**, as the SSH -# files might not be readable to the container user `zfs` with uid 100. -podSecurityContext: {} - # fsGroup: 100 - -securityContext: {} - # capabilities: - # drop: - # - ALL - # readOnlyRootFilesystem: true - # runAsNonRoot: true - # runAsUser: 100 - -resources: - limits: - memory: 40Mi - requests: - cpu: 50m - memory: 20Mi - -# -- Reminder: This has no effect on any PVs, but maybe you want the provisioner pod running -# on certain nodes. -nodeSelector: {} - -tolerations: [] - -affinity: {}