From b822473155a921a718ec44f313b2d6106f529673 Mon Sep 17 00:00:00 2001 From: groundhog2k <10630407+groundhog2k@users.noreply.github.com> Date: Sun, 13 Dec 2020 14:58:20 +0100 Subject: [PATCH] Removed default node selector and improved chart configuration (#128) --- charts/redis/Chart.yaml | 2 +- charts/redis/README.md | 15 ++++++++------- charts/redis/templates/customconfig.yaml | 2 +- charts/redis/templates/service.yaml | 8 +++++++- charts/redis/templates/statefulset.yaml | 16 +++++++++++----- charts/redis/values.yaml | 19 +++++++++++-------- 6 files changed, 39 insertions(+), 23 deletions(-) diff --git a/charts/redis/Chart.yaml b/charts/redis/Chart.yaml index 5b2fba98..d9e091a3 100644 --- a/charts/redis/Chart.yaml +++ b/charts/redis/Chart.yaml @@ -8,7 +8,7 @@ maintainers: - name: groundhog2k # This is the chart version -version: 0.2.0 +version: 0.2.1 # This is the version number of the application being deployed. appVersion: "6.0.9" diff --git a/charts/redis/README.md b/charts/redis/README.md index b0b2fbb4..ddc160c4 100644 --- a/charts/redis/README.md +++ b/charts/redis/README.md @@ -1,6 +1,6 @@ # Redis -   +   A Helm chart for Redis on Kubernetes @@ -15,7 +15,7 @@ $ helm install my-release groundhog2k/redis This chart uses the original [Redis image from Docker Hub](https://hub.docker.com/_/redis/) to deploy a stateful Redis instance in a Kubernetes cluster. -It fully supports deployment of arm64v8 and amd64 multi-architecture docker image. Just set the `nodeSelector` value to `kubernetes.io/arch: "arm64"` (default is `"amd64"`) +It fully supports deployment of the multi-architecture docker image. ## Prerequisites @@ -57,11 +57,12 @@ $ helm uninstall my-release | livenessProbe | object | `see values.yaml` | Liveness probe configurationm | | readinessProbe | object | `see values.yaml` | Readiness probe configuration | | resources | object | `{}` | Resource limits and requests | -| nodeSelector."kubernetes.io/arch" | string | `"amd64"` | Deployment node selector | +| nodeSelector | object | `{}` | Deployment node selector | | podAnnotations | object | `{}` | Additional pod annotations | | podSecurityContext | object | `{}` | Pod security context | | securityContext | object | `see values.yaml` | Container security context | | env | object | `[]` | Additional container environmment variables | +| args | object | `[]` | Additional container command arguments | | serviceAccount.annotations | object | `{}` | Additional service account annotations | | serviceAccount.create | bool | `false` | Enable service account creation | | serviceAccount.name | string | `""` | Name of the service account | @@ -79,13 +80,13 @@ $ helm uninstall my-release | Key | Type | Default | Description | |-----|------|---------|-------------| | storage.accessModes[0] | string | `"ReadWriteOnce"` | Storage access mode | -| storage.persistentVolumeClaimName | string | `""` | PVC name when existing storage volume should be used | -| storage.requestedSize | string | `""` | Size for new PVC, when no existing PVC is used | -| storage.className | string | `""` | Storage class name | +| storage.persistentVolumeClaimName | string | `nil` | PVC name when existing storage volume should be used | +| storage.requestedSize | string | `nil` | Size for new PVC, when no existing PVC is used | +| storage.className | string | `nil` | Storage class name | ## Redis parameters | Key | Type | Default | Description | |-----|------|---------|-------------| | arguments | string | `nil` | Arguments for the container entrypoint process | -| redisConfig | string | `""` | Custom redis.conf | +| redisConfig | string | `nil` | Custom redis.conf | diff --git a/charts/redis/templates/customconfig.yaml b/charts/redis/templates/customconfig.yaml index e91f9969..6f053aeb 100644 --- a/charts/redis/templates/customconfig.yaml +++ b/charts/redis/templates/customconfig.yaml @@ -7,5 +7,5 @@ metadata: {{- include "redis.labels" . | nindent 4 }} data: redis.conf: | - {{ .Values.redisConfig | nindent 4 }} + {{- .Values.redisConfig | nindent 4 }} {{- end }} diff --git a/charts/redis/templates/service.yaml b/charts/redis/templates/service.yaml index 7659aca3..f22994cf 100644 --- a/charts/redis/templates/service.yaml +++ b/charts/redis/templates/service.yaml @@ -5,11 +5,17 @@ metadata: labels: {{- include "redis.labels" . | nindent 4 }} spec: - clusterIP: None + type: {{ .Values.service.type }} ports: - port: {{ .Values.service.port }} targetPort: redis protocol: TCP name: redis + {{- if and (eq .Values.service.type "NodePort") (.Values.service.nodePort) }} + nodePort: {{ .Values.service.nodePort }} + {{- end }} + {{- if and (eq .Values.service.type "LoadBalancer") (.Values.service.clusterIP) }} + clusterIP: {{ .Values.service.clusterIP }} + {{- end }} selector: {{- include "redis.selectorLabels" . | nindent 4 }} diff --git a/charts/redis/templates/statefulset.yaml b/charts/redis/templates/statefulset.yaml index 394b45ba..a50d84df 100644 --- a/charts/redis/templates/statefulset.yaml +++ b/charts/redis/templates/statefulset.yaml @@ -24,12 +24,16 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} serviceAccountName: {{ include "redis.serviceAccountName" . }} + {{- with .Values.podSecurityContext }} securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- toYaml . | nindent 8 }} + {{- end }} containers: - name: {{ .Chart.Name }} + {{- with .Values.securityContext }} securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} + {{- toYaml . | nindent 12 }} + {{- end }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} ports: @@ -66,11 +70,13 @@ spec: periodSeconds: {{ .periodSeconds }} {{- end }} {{- end }} + {{- with .Values.resources }} resources: - {{- toYaml .Values.resources | nindent 12 }} - {{- if .Values.arguments }} + {{- toYaml . | nindent 12 }} + {{- end }} + {{- if .Values.args }} args: - {{- range .Values.arguments }} + {{- range .Values.args }} - {{ . }} {{- end }} {{- end }} diff --git a/charts/redis/values.yaml b/charts/redis/values.yaml index cb886d08..dc796e57 100644 --- a/charts/redis/values.yaml +++ b/charts/redis/values.yaml @@ -22,10 +22,8 @@ serviceAccount: # If not set and create is true, a name is generated using the fullname template name: "" -## Default node type for the image -## use arm64 for the arm64v8/redis image -nodeSelector: - kubernetes.io/arch: amd64 +## Additional node selector +nodeSelector: {} ## Additional pod annotations podAnnotations: {} @@ -44,7 +42,12 @@ securityContext: ## Default redis service port (default Redis port 6379) service: + type: ClusterIP port: 6379 + ## The node port (only relevant for type NodePort) + nodePort: {} + ## The cluster ip address (only relevant for type LoadBalancer) + clusterIP: {} ## Resource limits and requests resources: {} @@ -81,7 +84,7 @@ readinessProbe: env: [] ## Arguments for the container entrypoint process -arguments: +args: [] # Custom redis.conf redisConfig: | @@ -89,13 +92,13 @@ redisConfig: | ## Storage parameters storage: ## Set persistentVolumenClaimName to reference an existing PVC - # persistentVolumeClaimName: <own-pvc-name> + persistentVolumeClaimName: {} ## Alternative set requestedSize to define a size for a dynmaically created PVC - # requestedSize: <volume-size> + requestedSize: {} ## the storage class name - # className: + className: {} ## Default access mode (ReadWriteOnce) accessModes: -- GitLab