[memcached] Change deployment type to statefulset

For effective cache use all endpoints should be specified
explicitly as memcache client use specific algorithm to
identify on which cache server key is stored based on
servers availability and key name.
If memcached deployed behind the service unless same key is
stored on all memcached instances clients will always got
cache misses and will require to use heavy calls to database.
So in the end all keys will be stored on all memcached instances.
Furthermore delete operations such as revoke token or remove
keystone group call logic in service to remove data from cache
if Loadbalancer is used this functionality can't work as we
can't remove keys from all backends behind LB with single call.

Change-Id: I253cfa2740fed5e1c70ced7308a489568e0f10b9
This commit is contained in:
Vasyl Saienko 2024-09-14 15:48:32 +00:00
parent 2acad7bad8
commit 14b84a79db
4 changed files with 45 additions and 12 deletions

View File

@ -15,6 +15,6 @@ apiVersion: v1
appVersion: v1.5.5 appVersion: v1.5.5
description: OpenStack-Helm Memcached description: OpenStack-Helm Memcached
name: memcached name: memcached
version: 0.1.15 version: 0.1.16
home: https://github.com/memcached/memcached home: https://github.com/memcached/memcached
... ...

View File

@ -18,7 +18,18 @@ limitations under the License.
{{- $_ := set . "deployment_name" .Release.Name }} {{- $_ := set . "deployment_name" .Release.Name }}
{{- end }} {{- end }}
{{- if .Values.manifests.deployment }} {{- define "memcachedProbeTemplate" }}
tcpSocket:
port: {{ tuple "oslo_cache" "internal" "memcache" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
{{- end }}
{{- define "exporterProbeTemplate" }}
httpGet:
path: /metrics
port: {{ tuple "oslo_cache" "internal" "metrics" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
{{- end }}
{{- if .Values.manifests.statefulset }}
{{- $envAll := . }} {{- $envAll := . }}
{{- $rcControllerName := printf "%s-%s" $envAll.deployment_name "memcached" }} {{- $rcControllerName := printf "%s-%s" $envAll.deployment_name "memcached" }}
@ -27,7 +38,7 @@ limitations under the License.
{{ tuple $envAll "memcached" $rcControllerName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} {{ tuple $envAll "memcached" $rcControllerName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }}
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: StatefulSet
metadata: metadata:
name: {{ $rcControllerName | quote }} name: {{ $rcControllerName | quote }}
annotations: annotations:
@ -35,7 +46,9 @@ metadata:
labels: labels:
{{ tuple $envAll "memcached" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} {{ tuple $envAll "memcached" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
spec: spec:
podManagementPolicy: Parallel
replicas: {{ .Values.pod.replicas.server }} replicas: {{ .Values.pod.replicas.server }}
serviceName: "{{ tuple "oslo_cache" "internal" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }}"
selector: selector:
matchLabels: matchLabels:
{{ tuple $envAll "memcached" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 6 }} {{ tuple $envAll "memcached" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 6 }}
@ -79,9 +92,8 @@ spec:
- /tmp/memcached.sh - /tmp/memcached.sh
ports: ports:
- containerPort: {{ tuple "oslo_cache" "internal" "memcache" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} - containerPort: {{ tuple "oslo_cache" "internal" "memcache" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
readinessProbe: {{ dict "envAll" $envAll "component" "memcached" "container" "memcached" "type" "readiness" "probeTemplate" (include "memcachedProbeTemplate" $envAll | fromYaml) | include "helm-toolkit.snippets.kubernetes_probe" | indent 10 }}
tcpSocket: {{ dict "envAll" $envAll "component" "memcached" "container" "memcached" "type" "liveness" "probeTemplate" (include "memcachedProbeTemplate" $envAll | fromYaml) | include "helm-toolkit.snippets.kubernetes_probe" | indent 10 }}
port: {{ tuple "oslo_cache" "internal" "memcache" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
volumeMounts: volumeMounts:
- name: pod-tmp - name: pod-tmp
mountPath: /tmp mountPath: /tmp
@ -91,8 +103,7 @@ spec:
readOnly: true readOnly: true
{{- if .Values.monitoring.prometheus.enabled }} {{- if .Values.monitoring.prometheus.enabled }}
- name: memcached-exporter - name: memcached-exporter
image: {{ .Values.images.tags.prometheus_memcached_exporter }} {{ tuple $envAll "prometheus_memcached_exporter" | include "helm-toolkit.snippets.image" | indent 10 }}
imagePullPolicy: {{ .Values.images.pull_policy }}
{{ tuple $envAll $envAll.Values.pod.resources.prometheus_memcached_exporter | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} {{ tuple $envAll $envAll.Values.pod.resources.prometheus_memcached_exporter | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
{{ dict "envAll" $envAll "application" "server" "container" "memcached_exporter" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }} {{ dict "envAll" $envAll "application" "server" "container" "memcached_exporter" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }}
command: command:
@ -101,9 +112,8 @@ spec:
ports: ports:
- name: metrics - name: metrics
containerPort: {{ tuple "oslo_cache" "internal" "metrics" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} containerPort: {{ tuple "oslo_cache" "internal" "metrics" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
readinessProbe: {{ dict "envAll" $envAll "component" "memcached" "container" "memcached_exporter" "type" "readiness" "probeTemplate" (include "exporterProbeTemplate" $envAll | fromYaml) | include "helm-toolkit.snippets.kubernetes_probe" | indent 10 }}
tcpSocket: {{ dict "envAll" $envAll "component" "memcached" "container" "memcached_exporter" "type" "liveness" "probeTemplate" (include "exporterProbeTemplate" $envAll | fromYaml) | include "helm-toolkit.snippets.kubernetes_probe" | indent 10 }}
port: {{ tuple "oslo_cache" "internal" "metrics" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
volumeMounts: volumeMounts:
- name: pod-tmp - name: pod-tmp
mountPath: /tmp mountPath: /tmp

View File

@ -139,7 +139,7 @@ labels:
manifests: manifests:
configmap_bin: true configmap_bin: true
deployment: true statefulset: true
job_image_repo_sync: true job_image_repo_sync: true
network_policy: false network_policy: false
service: true service: true
@ -157,6 +157,28 @@ pod:
memcached_exporter: memcached_exporter:
allowPrivilegeEscalation: false allowPrivilegeEscalation: false
readOnlyRootFilesystem: true readOnlyRootFilesystem: true
probes:
memcached:
memcached:
readiness:
enabled: True
params:
initialDelaySeconds: 0
periodSeconds: 10
timeoutSeconds: 5
memcached_exporter:
liveness:
enabled: True
params:
initialDelaySeconds: 15
periodSeconds: 60
timeoutSeconds: 10
readiness:
enabled: True
params:
initialDelaySeconds: 5
periodSeconds: 60
timeoutSeconds: 10
affinity: affinity:
anti: anti:
topologyKey: topologyKey:

View File

@ -16,4 +16,5 @@ memcached:
- 0.1.13 Replace node-role.kubernetes.io/master with control-plane - 0.1.13 Replace node-role.kubernetes.io/master with control-plane
- 0.1.14 Use quay.io/airshipit/kubernetes-entrypoint:latest-ubuntu_focal by default - 0.1.14 Use quay.io/airshipit/kubernetes-entrypoint:latest-ubuntu_focal by default
- 0.1.15 Allow to pass additional service parameters - 0.1.15 Allow to pass additional service parameters
- 0.1.16 Change deployment type to statefulset
... ...