Skip to content

Commit 4ed25c0

Browse files
author
juan131
committed
[bitnami/memcached] Chart standardized
Signed-off-by: juan131 <juanariza@vmware.com>
1 parent b9a9533 commit 4ed25c0

15 files changed

+936
-541
lines changed

bitnami/memcached/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ name: memcached
2222
sources:
2323
- https://github.com/bitnami/bitnami-docker-memcached
2424
- http://memcached.org/
25-
version: 5.15.14
25+
version: 6.0.0

bitnami/memcached/README.md

+221-119
Large diffs are not rendered by default.

bitnami/memcached/ci/values-production.yaml

-5
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Test values file for generating hidden section of the yaml
2+
# and check that the rendering is correct
3+
architecture: high-availability
4+
replicaCount: 3
5+
persistence:
6+
enabled: true
7+
metrics:
8+
enabled: true
9+
serviceMonitor:
10+
enabled: true

bitnami/memcached/templates/NOTES.txt

+24-12
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,40 @@ CHART NAME: {{ .Chart.Name }}
22
CHART VERSION: {{ .Chart.Version }}
33
APP VERSION: {{ .Chart.AppVersion }}
44

5-
** Please be patient while the chart is being deployed **
5+
{{- if and (not .Values.auth.enabled) (contains .Values.service.type "LoadBalancer") }}
6+
-------------------------------------------------------------------------------
7+
WARNING
68

7-
{{- if eq .Values.architecture "standalone" }}
8-
Memcached can be accessed on port 11211 on the following DNS name from within your cluster: {{ template "common.names.fullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}
9-
{{- else if eq .Values.architecture "high-availability" }}
10-
Memcached endpoints are exposed on the headless service named: {{ template "common.names.fullname" . }}.
11-
Please see https://github.com/memcached/memcached/wiki/ConfiguringClient to understand the Memcached model and need for client-based consistent hashing.
12-
You might also want to consider more advanced routing/replication approaches with mcrouter: https://github.com/facebook/mcrouter/wiki/Replicated-pools-setup
9+
By specifying "serviceType=LoadBalancer" and not specifying "auth.enabled=true"
10+
you have most likely exposed the Memcached service externally without any
11+
authentication mechanism.
12+
13+
For security reasons, we strongly suggest that you switch to "ClusterIP" or
14+
"NodePort". As alternative, you can also specify valid credentials using the
15+
"auth.username" and "auth.password" parameters.
16+
17+
-------------------------------------------------------------------------------
1318
{{- end }}
1419

15-
{{- if and (contains "bitnami/" .Values.image.repository) (not (.Values.image.tag | toString | regexFind "-r\\d+$|sha256:")) }}
20+
** Please be patient while the chart is being deployed **
21+
22+
Memcached can be accessed via port {{ .Values.service.ports.memcached }} on the following DNS name from within your cluster:
23+
24+
{{ include "common.names.fullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}
25+
26+
{{- if eq .Values.architecture "high-availability" }}
1627

17-
WARNING: Rolling tag detected ({{ .Values.image.repository }}:{{ .Values.image.tag }}), please note that it is strongly recommended to avoid using rolling tags in a production environment.
18-
+info https://docs.bitnami.com/containers/how-to/understand-rolling-tags-containers/
28+
Please see https://github.com/memcached/memcached/wiki/ConfiguringClient to understand the Memcached model and need for client-based consistent hashing.
29+
You might also want to consider more advanced routing/replication approaches with mcrouter: https://github.com/facebook/mcrouter/wiki/Replicated-pools-setup
1930

2031
{{- end }}
32+
2133
{{- if .Values.metrics.enabled }}
2234

2335
To access the Memcached Prometheus metrics from outside the cluster execute the following commands:
2436

25-
kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ template "common.names.fullname" . }}-metrics {{ .Values.metrics.service.port }}:{{ .Values.metrics.service.port }} &
26-
curl http://127.0.0.1:{{ .Values.metrics.service.port }}/metrics
37+
kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ printf "%s-metrics" (include "common.names.fullname" .) }} {{ .Values.metrics.service.ports.metrics }}:{{ .Values.metrics.service.ports.metrics }} &
38+
curl http://127.0.0.1:{{ .Values.metrics.service.ports.metrics }}/metrics
2739

2840
{{- end }}
2941

bitnami/memcached/templates/_helpers.tpl

+24-23
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
{{/* vim: set filetype=mustache: */}}
22

3-
{{/*
4-
Create a default fully qualified app name.
5-
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
6-
If release name contains chart name it will be used as a full name.
7-
*/}}
8-
{{- define "memcached.fullname" -}}
9-
{{- include "common.names.fullname" . -}}
10-
{{- end -}}
11-
123
{{/*
134
Return the proper Memcached image name
145
*/}}
@@ -38,6 +29,17 @@ Return the proper Docker Image Registry Secret Names
3829
{{- include "common.images.pullSecrets" (dict "images" (list .Values.image .Values.metrics.image .Values.volumePermissions.image) "global" .Values.global) -}}
3930
{{- end -}}
4031

32+
{{/*
33+
Create the name of the service account to use
34+
*/}}
35+
{{- define "memcached.serviceAccountName" -}}
36+
{{- if .Values.serviceAccount.create -}}
37+
{{ default (include "common.names.fullname" .) .Values.serviceAccount.name }}
38+
{{- else -}}
39+
{{ default "default" .Values.serviceAccount.name }}
40+
{{- end -}}
41+
{{- end -}}
42+
4143
{{/*
4244
Check if there are rolling tags in the images
4345
*/}}
@@ -54,6 +56,7 @@ Compile all warnings into a single message, and call fail.
5456
{{- $messages := list -}}
5557
{{- $messages := append $messages (include "memcached.validateValues.architecture" .) -}}
5658
{{- $messages := append $messages (include "memcached.validateValues.replicaCount" .) -}}
59+
{{- $messages := append $messages (include "memcached.validateValues.auth" .) -}}
5760
{{- $messages := append $messages (include "memcached.validateValues.readOnlyRootFilesystem" .) -}}
5861
{{- $messages := without $messages "" -}}
5962
{{- $message := join "\n" $messages -}}
@@ -83,22 +86,20 @@ memcached: replicaCount
8386
{{- end -}}
8487
{{- end -}}
8588

86-
{{/* Validate values of Memcached - securityContext.readOnlyRootFilesystem */}}
87-
{{- define "memcached.validateValues.readOnlyRootFilesystem" -}}
88-
{{- if and .Values.securityContext.enabled .Values.securityContext.readOnlyRootFilesystem (not (empty .Values.memcachedPassword)) -}}
89-
memcached: securityContext.readOnlyRootFilesystem
90-
Enabling authentication is not compatible with using a read-only filesystem.
91-
Please disable it (--set securityContext.readOnlyRootFilesystem=false)
89+
{{/* Validate values of Memcached - authentication */}}
90+
{{- define "memcached.validateValues.auth" -}}
91+
{{- if and .Values.auth.enabled (empty .Values.auth.username) -}}
92+
memcached: auth.username
93+
Enabling authentication requires setting a valid admin username.
94+
Please set a valid username (--set auth.username="xxxx")
9295
{{- end -}}
9396
{{- end -}}
9497

95-
{{/*
96-
Create the name of the service account to use
97-
*/}}
98-
{{- define "memcached.serviceAccountName" -}}
99-
{{- if .Values.serviceAccount.create -}}
100-
{{ default (include "memcached.fullname" .) .Values.serviceAccount.name }}
101-
{{- else -}}
102-
{{ default "default" .Values.serviceAccount.name }}
98+
{{/* Validate values of Memcached - containerSecurityContext.readOnlyRootFilesystem */}}
99+
{{- define "memcached.validateValues.readOnlyRootFilesystem" -}}
100+
{{- if and .Values.containerSecurityContext.enabled .Values.containerSecurityContext.readOnlyRootFilesystem .Values.auth.enabled -}}
101+
memcached: containerSecurityContext.readOnlyRootFilesystem
102+
Enabling authentication is not compatible with using a read-only filesystem.
103+
Please disable it (--set containerSecurityContext.readOnlyRootFilesystem=false)
103104
{{- end -}}
104105
{{- end -}}

bitnami/memcached/templates/deployment.yaml

+83-43
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@ spec:
2121
{{- if .Values.podLabels }}
2222
{{- include "common.tplvalues.render" (dict "value" .Values.podLabels "context" $) | nindent 8 }}
2323
{{- end }}
24-
{{- if or .Values.podAnnotations (and .Values.metrics.enabled .Values.metrics.podAnnotations) }}
2524
annotations:
25+
{{- if .Values.auth.enabled }}
26+
checksum/secrets: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }}
27+
{{- end }}
2628
{{- if .Values.podAnnotations }}
2729
{{- include "common.tplvalues.render" (dict "value" .Values.podAnnotations "context" $) | nindent 8 }}
2830
{{- end }}
2931
{{- if and .Values.metrics.enabled .Values.metrics.podAnnotations }}
3032
{{- include "common.tplvalues.render" (dict "value" .Values.metrics.podAnnotations "context" $) | nindent 8 }}
3133
{{- end }}
32-
{{- end }}
3334
spec:
3435
{{- include "memcached.imagePullSecrets" . | nindent 6 }}
3536
{{- if .Values.hostAliases }}
@@ -53,12 +54,13 @@ spec:
5354
topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.topologySpreadConstraints "context" .) | nindent 8 }}
5455
{{- end }}
5556
{{- if .Values.priorityClassName }}
56-
priorityClassName: {{ .Values.priorityClassName | quote }}
57+
priorityClassName: {{ .Values.priorityClassName }}
58+
{{- end }}
59+
{{- if .Values.schedulerName }}
60+
schedulerName: {{ .Values.schedulerName }}
5761
{{- end }}
58-
{{- if .Values.securityContext.enabled }}
59-
securityContext:
60-
fsGroup: {{ .Values.securityContext.fsGroup }}
61-
runAsUser: {{ .Values.securityContext.runAsUser }}
62+
{{- if .Values.podSecurityContext.enabled }}
63+
securityContext: {{- omit .Values.podSecurityContext "enabled" | toYaml | nindent 8 }}
6264
{{- end }}
6365
serviceAccountName: {{ template "memcached.serviceAccountName" . }}
6466
{{- if .Values.initContainers }}
@@ -68,73 +70,111 @@ spec:
6870
- name: memcached
6971
image: {{ template "memcached.image" . }}
7072
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
71-
{{- if .Values.command }}
73+
{{- if .Values.containerSecurityContext.enabled }}
74+
securityContext: {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }}
75+
{{- end }}
76+
{{- if .Values.diagnosticMode.enabled }}
77+
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
78+
{{- else if .Values.command }}
7279
command: {{- include "common.tplvalues.render" (dict "value" .Values.command "context" $) | nindent 12 }}
7380
{{- end }}
74-
{{- if .Values.arguments }}
75-
args: {{- include "common.tplvalues.render" (dict "value" .Values.arguments "context" $) | nindent 12 }}
81+
{{- if .Values.diagnosticMode.enabled }}
82+
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
83+
{{- else if .Values.args }}
84+
args: {{- include "common.tplvalues.render" (dict "value" .Values.args "context" $) | nindent 12 }}
7685
{{- end }}
7786
env:
7887
- name: BITNAMI_DEBUG
7988
value: {{ ternary "true" "false" .Values.image.debug | quote }}
80-
{{- if .Values.memcachedUsername }}
89+
{{- if .Values.auth.enabled }}
8190
- name: MEMCACHED_USERNAME
82-
value: {{ .Values.memcachedUsername | quote }}
83-
{{- end }}
84-
{{- if .Values.memcachedPassword }}
91+
value: {{ .Values.auth.username | quote }}
8592
- name: MEMCACHED_PASSWORD
8693
valueFrom:
8794
secretKeyRef:
88-
name: {{ template "common.names.fullname" . }}
95+
name: {{ include "common.names.fullname" . }}
8996
key: memcached-password
9097
{{- end }}
91-
{{- if .Values.extraEnv }}
92-
{{- toYaml .Values.extraEnv | nindent 12 }}
98+
{{- if .Values.extraEnvVars }}
99+
{{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }}
93100
{{- end }}
101+
{{- if or .Values.extraEnvVarsCM .Values.extraEnvVarsSecret }}
102+
envFrom:
103+
{{- if .Values.extraEnvVarsCM }}
104+
- configMapRef:
105+
name: {{ include "common.tplvalues.render" (dict "value" .Values.extraEnvVarsCM "context" $) }}
106+
{{- end }}
107+
{{- if .Values.extraEnvVarsSecret }}
108+
- secretRef:
109+
name: {{ include "common.tplvalues.render" (dict "value" .Values.extraEnvVarsSecret "context" $) }}
110+
{{- end }}
111+
{{- end }}
94112
ports:
95-
- name: {{ .Values.portName }}
96-
containerPort: 11211
97-
livenessProbe:
113+
- name: memcache
114+
containerPort: {{ .Values.containerPorts.memcached }}
115+
{{- if not .Values.diagnosticMode.enabled }}
116+
{{- if .Values.livenessProbe.enabled }}
117+
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.livenessProbe "enabled") "context" $) | nindent 12 }}
98118
tcpSocket:
99-
port: {{ .Values.portName }}
100-
initialDelaySeconds: 30
101-
timeoutSeconds: 5
102-
failureThreshold: 6
103-
readinessProbe:
119+
port: memcache
120+
{{- else if .Values.customLivenessProbe }}
121+
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customLivenessProbe "context" $) | nindent 12 }}
122+
{{- end }}
123+
{{- if .Values.readinessProbe.enabled }}
124+
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.readinessProbe "enabled") "context" $) | nindent 12 }}
104125
tcpSocket:
105-
port: {{ .Values.portName }}
106-
initialDelaySeconds: 5
107-
timeoutSeconds: 3
108-
periodSeconds: 5
126+
port: memcache
127+
{{- else if .Values.customReadinessProbe }}
128+
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customReadinessProbe "context" $) | nindent 12 }}
129+
{{- end }}
130+
{{- if .Values.startupProbe.enabled }}
131+
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.startupProbe "enabled") "context" $) | nindent 12 }}
132+
tcpSocket:
133+
port: memcache
134+
{{- else if .Values.customStartupProbe }}
135+
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customStartupProbe "context" $) | nindent 12 }}
136+
{{- end }}
137+
{{- end }}
138+
{{- if .Values.lifecycleHooks }}
139+
lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.lifecycleHooks "context" $) | nindent 12 }}
140+
{{- end }}
109141
{{- if .Values.resources }}
110142
resources: {{- toYaml .Values.resources | nindent 12 }}
111143
{{- end }}
112144
volumeMounts:
113145
- name: tmp
114146
mountPath: /tmp
115-
{{- if .Values.securityContext.enabled }}
116-
securityContext:
117-
readOnlyRootFilesystem: {{ .Values.securityContext.readOnlyRootFilesystem }}
118-
{{- end }}
119147
{{- if .Values.metrics.enabled }}
120148
- name: metrics
121149
image: {{ template "memcached.metrics.image" . }}
122150
imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
123151
ports:
124-
- name: {{ .Values.metrics.portName }}
125-
containerPort: 9150
126-
livenessProbe:
152+
- name: metrics
153+
containerPort: {{ .Values.metrics.containerPorts.metrics }}
154+
{{- if not .Values.diagnosticMode.enabled }}
155+
{{- if .Values.metrics.livenessProbe.enabled }}
156+
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.livenessProbe "enabled") "context" $) | nindent 12 }}
127157
httpGet:
128158
path: /metrics
129-
port: {{ .Values.metrics.portName }}
130-
initialDelaySeconds: 15
131-
timeoutSeconds: 5
132-
readinessProbe:
159+
port: {{ .Values.metrics.containerPorts.metrics }}
160+
{{- else if .Values.metrics.customLivenessProbe }}
161+
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customLivenessProbe "context" $) | nindent 12 }}
162+
{{- end }}
163+
{{- if .Values.metrics.readinessProbe.enabled }}
164+
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.readinessProbe "enabled") "context" $) | nindent 12 }}
133165
httpGet:
134166
path: /metrics
135-
port: {{ .Values.metrics.portName }}
136-
initialDelaySeconds: 5
137-
timeoutSeconds: 1
167+
port: {{ .Values.metrics.containerPorts.metrics }}
168+
{{- else if .Values.metrics.customReadinessProbe }}
169+
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customReadinessProbe "context" $) | nindent 12 }}
170+
{{- end }}
171+
{{- if .Values.metrics.startupProbe.enabled }}
172+
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.startupProbe "enabled") "context" $) | nindent 12 }}
173+
port: memcache
174+
{{- else if .Values.metrics.customStartupProbe }}
175+
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customStartupProbe "context" $) | nindent 12 }}
176+
{{- end }}
177+
{{- end }}
138178
{{- if .Values.metrics.resources }}
139179
resources: {{- toYaml .Values.metrics.resources | nindent 12 }}
140180
{{- end }}

bitnami/memcached/templates/svc-metrics.yaml bitnami/memcached/templates/metrics-svc.yaml

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: v1
33
kind: Service
44
metadata:
5-
name: {{ template "common.names.fullname" . }}-metrics
5+
name: {{ printf "%s-metrics" (include "common.names.fullname" .) | trunc 63 | trimSuffix "-" }}
66
namespace: {{ .Release.Namespace }}
77
labels: {{- include "common.labels.standard" . | nindent 4 }}
88
app.kubernetes.io/component: metrics
@@ -17,10 +17,14 @@ metadata:
1717
{{- include "common.tplvalues.render" (dict "value" .Values.metrics.service.annotations "context" $) | nindent 4 }}
1818
{{- end }}
1919
spec:
20-
type: {{ .Values.metrics.service.type }}
20+
type: ClusterIP
21+
sessionAffinity: {{ .Values.metrics.service.sessionAffinity }}
22+
{{- if .Values.metrics.service.clusterIP }}
23+
clusterIP: {{ .Values.metrics.service.clusterIP }}
24+
{{- end }}
2125
ports:
2226
- name: metrics
23-
port: {{ .Values.metrics.service.port }}
24-
targetPort: {{ .Values.metrics.portName }}
27+
port: {{ .Values.metrics.service.ports.metrics }}
28+
targetPort: metrics
2529
selector: {{- include "common.labels.matchLabels" . | nindent 4 }}
2630
{{- end }}

bitnami/memcached/templates/pdb.yaml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
{{- if and .Values.podDisruptionBudget.create (eq .Values.architecture "high-availability") }}
2-
apiVersion: policy/v1beta1
1+
{{- if and .Values.pdb.create (eq .Values.architecture "high-availability") }}
2+
apiVersion: {{ include "common.capabilities.policy.apiVersion" . }}
33
kind: PodDisruptionBudget
44
metadata:
55
name: {{ include "common.names.fullname" . }}
66
namespace: {{ .Release.Namespace }}
77
labels: {{- include "common.labels.standard" . | nindent 4 }}
88
spec:
9-
{{- if .Values.podDisruptionBudget.minAvailable }}
10-
minAvailable: {{ .Values.podDisruptionBudget.minAvailable }}
9+
{{- if .Values.pdb.minAvailable }}
10+
minAvailable: {{ .Values.pdb.minAvailable }}
1111
{{- end }}
12-
{{- if .Values.podDisruptionBudget.maxUnavailable }}
13-
maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }}
12+
{{- if .Values.pdb.maxUnavailable }}
13+
maxUnavailable: {{ .Values.pdb.maxUnavailable }}
1414
{{- end }}
1515
selector:
1616
matchLabels: {{ include "common.labels.matchLabels" . | nindent 6 }}

0 commit comments

Comments
 (0)