Skip to content

Commit 3393a5f

Browse files
author
lijianguo
committed
chore(addons): modify memcached mysql postgres volumePermissions, add redis volumePermissions
1 parent b9ed403 commit 3393a5f

11 files changed

Lines changed: 131 additions & 6 deletions

File tree

addons/memcached-1.1.0/chart/memcached/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ The following tables lists the configurable parameters of the Memcached chart an
9696
| `metrics.service.type` | Kubernetes service type for Prometheus metrics | `ClusterIP` |
9797
| `metrics.service.port` | Prometheus metrics service port | `9150` |
9898
| `metrics.service.annotations` | Prometheus exporter svc annotations | `{prometheus.io/scrape: "true", prometheus.io/port: "9150"}` |
99+
| `volumePermissions.image.registry` | Init container volume-permissions image registry | `docker.io` |
100+
| `volumePermissions.image.repository` | Init container volume-permissions image name | `bitnami/bitnami-shell` |
101+
| `volumePermissions.image.tag` | Init container volume-permissions image tag | `"10"` |
102+
| `volumePermissions.image.pullPolicy` | Init container volume-permissions image pull policy | `Always` |
103+
| `volumePermissions.image.pullSecrets` | Specify docker-registry secret names as an array | `[]` (does not add image pull secrets to deployed pods) |
104+
| `volumePermissions.resources.limits` | Init container volume-permissions resource limits | `{}` |
105+
| `volumePermissions.resources.requests` | Init container volume-permissions resource requests | `{}` |
99106

100107
The above parameters map to the env variables defined in [bitnami/memcached](http://github.com/bitnami/bitnami-docker-memcached). For more information please refer to the [bitnami/memcached](http://github.com/bitnami/bitnami-docker-memcached) image documentation.
101108

addons/memcached-1.1.0/chart/memcached/templates/_helpers.tpl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,29 @@ Also, we can't use a single if because lazy evaluation is not an option
7171
{{- end -}}
7272
{{- end -}}
7373

74+
{{/*
75+
Return the proper Memcached image name
76+
*/}}
77+
{{- define "memcached.volumePermissions.image" -}}
78+
{{- $registryName := .Values.volumePermissions.image.registry -}}
79+
{{- $repositoryName := .Values.volumePermissions.image.repository -}}
80+
{{- $tag := .Values.volumePermissions.image.tag | toString -}}
81+
{{/*
82+
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
83+
but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic.
84+
Also, we can't use a single if because lazy evaluation is not an option
85+
*/}}
86+
{{- if .Values.global }}
87+
{{- if .Values.global.imageRegistry }}
88+
{{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}}
89+
{{- else -}}
90+
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
91+
{{- end -}}
92+
{{- else -}}
93+
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
94+
{{- end -}}
95+
{{- end -}}
96+
7497
{{/*
7598
Return the proper Memcached image name
7699
*/}}

addons/memcached-1.1.0/chart/memcached/templates/statefulset.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,28 @@ spec:
3737
fsGroup: {{ .Values.securityContext.fsGroup }}
3838
runAsUser: {{ .Values.securityContext.runAsUser }}
3939
{{- end }}
40+
{{- if .Values.persistence.enabled }}
41+
initContainers:
42+
{{- if .Values.persistence.enabled }}
43+
- name: volume-permissions
44+
image: {{ template "memcached.volumePermissions.image" . }}
45+
imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
46+
command:
47+
- /bin/bash
48+
- -ec
49+
- |
50+
touch /cache-state/memory_file
51+
chown -R {{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }} /cache-state
52+
securityContext:
53+
runAsUser: 0
54+
{{- if .Values.volumePermissions.resources }}
55+
resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
56+
{{- end }}
57+
volumeMounts:
58+
- name: data
59+
mountPath: /cache-state
60+
{{- end }}
61+
{{- end }}
4062
containers:
4163
- name: memcached
4264
{{- if .Values.persistence.enabled }}

addons/memcached-1.1.0/chart/memcached/values-production.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,40 @@ metrics:
234234
##
235235
# selector:
236236
# prometheus: my-prometheus
237+
238+
239+
## Init Container parameters
240+
## Change the owner and group of the persistent volume(s) mountpoint(s) to 'runAsUser:fsGroup' on each component
241+
## values from the securityContext section of the component
242+
##
243+
volumePermissions:
244+
image:
245+
registry: docker.io
246+
repository: bitnami/bitnami-shell
247+
tag: 10-debian-10-r103
248+
## Specify a imagePullPolicy
249+
## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'
250+
## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images
251+
##
252+
pullPolicy: Always
253+
## Optionally specify an array of imagePullSecrets (secrets must be manually created in the namespace)
254+
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
255+
## Example:
256+
## pullSecrets:
257+
## - myRegistryKeySecretName
258+
##
259+
pullSecrets: []
260+
## Init Container resource requests and limits
261+
## ref: http://kubernetes.io/docs/user-guide/compute-resources/
262+
##
263+
resources:
264+
# We usually recommend not to specify default resources and to leave this as a conscious
265+
# choice for the user. This also increases chances charts run on environments with little
266+
# resources, such as Minikube. If you do want to specify resources, uncomment the following
267+
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
268+
limits: {}
269+
# cpu: 100m
270+
# memory: 128Mi
271+
requests: {}
272+
# cpu: 100m
273+
# memory: 128Mi

addons/memcached-1.1.0/chart/memcached/values.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,3 +236,39 @@ metrics:
236236
##
237237
# selector:
238238
# prometheus: my-prometheus
239+
240+
## Init Container parameters
241+
## Change the owner and group of the persistent volume(s) mountpoint(s) to 'runAsUser:fsGroup' on each component
242+
## values from the securityContext section of the component
243+
##
244+
volumePermissions:
245+
image:
246+
registry: docker.io
247+
repository: bitnami/bitnami-shell
248+
tag: 10-debian-10-r103
249+
## Specify a imagePullPolicy
250+
## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'
251+
## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images
252+
##
253+
pullPolicy: Always
254+
## Optionally specify an array of imagePullSecrets (secrets must be manually created in the namespace)
255+
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
256+
## Example:
257+
## pullSecrets:
258+
## - myRegistryKeySecretName
259+
##
260+
pullSecrets: []
261+
## Init Container resource requests and limits
262+
## ref: http://kubernetes.io/docs/user-guide/compute-resources/
263+
##
264+
resources:
265+
# We usually recommend not to specify default resources and to leave this as a conscious
266+
# choice for the user. This also increases chances charts run on environments with little
267+
# resources, such as Minikube. If you do want to specify resources, uncomment the following
268+
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
269+
limits: {}
270+
# cpu: 100m
271+
# memory: 128Mi
272+
requests: {}
273+
# cpu: 100m
274+
# memory: 128Mi

addons/mysql-1.1.0/chart/mysql/values-production.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ clusterDomain: cluster.local
4343
## volumePermissions: Change the owner and group of the persistent volume mountpoint to runAsUser:fsGroup values from the securityContext section.
4444
##
4545
volumePermissions:
46-
enabled: false
46+
enabled: true
4747
image:
4848
registry: docker.io
4949
repository: bitnami/minideb

addons/mysql-1.1.0/chart/mysql/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ clusterDomain: cluster.local
4747
## volumePermissions: Change the owner and group of the persistent volume mountpoint to runAsUser:fsGroup values from the securityContext section.
4848
##
4949
volumePermissions:
50-
enabled: false
50+
enabled: true
5151
image:
5252
registry: docker.io
5353
repository: bitnami/minideb

addons/postgresql-1.1.0/chart/postgresql/values-production.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ image:
4646
## volumePermissions: Change the owner of the persist volume mountpoint to RunAsUser:fsGroup
4747
##
4848
volumePermissions:
49-
enabled: false
49+
enabled: true
5050
image:
5151
registry: docker.io
5252
repository: bitnami/minideb

addons/postgresql-1.1.0/chart/postgresql/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ image:
4646
## volumePermissions: Change the owner of the persist volume mountpoint to RunAsUser:fsGroup
4747
##
4848
volumePermissions:
49-
enabled: false
49+
enabled: true
5050
image:
5151
registry: docker.io
5252
repository: bitnami/minideb

addons/redis-1.1.0/chart/redis/values-production.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ metrics:
710710
## volumePermissions: Change the owner of the persist volume mountpoint to RunAsUser:fsGroup
711711
##
712712
volumePermissions:
713-
enabled: false
713+
enabled: true
714714
image:
715715
registry: docker.io
716716
repository: bitnami/minideb

0 commit comments

Comments
 (0)