1+ {{- define "cinder.api.deployment" -}}
2+ {{- $type := index . 1 -}}
3+ {{- $conf := index . 2 -}}
4+ {{- with index . 0 -}}
15kind : Deployment
26apiVersion : apps/v1
37
48metadata :
5- name : cinder-api
9+ name : cinder-api-{{ $type }}
610 labels :
711 system : openstack
812 type : api
@@ -11,7 +15,7 @@ metadata:
1115 secret.reloader.stakater.com/reload : " {{ .Release.Name }}-secrets"
1216 deployment.reloader.stakater.com/pause-period : " 60s"
1317spec :
14- replicas : {{ .Values.pod. replicas.api }}
18+ replicas : {{ $conf. replicas }}
1519 revisionHistoryLimit : {{ .Values.pod.lifecycle.upgrades.deployments.revisionHistory }}
1620 strategy :
1721 type : {{ .Values.pod.lifecycle.upgrades.deployments.podReplacementStrategy }}
@@ -22,25 +26,25 @@ spec:
2226 {{ end }}
2327 selector :
2428 matchLabels :
25- name : cinder-api
29+ name : cinder-api-{{ $type }}
2630 template :
2731 metadata :
2832 labels :
29- name : cinder-api
30- {{- tuple . "cinder" "api" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | nindent 8 }}
33+ name : cinder-api-{{ $type }}
34+ {{- tuple . "cinder" (printf "api-%s" $type) | include "helm-toolkit.snippets.kubernetes_metadata_labels" | nindent 8 }}
3135 {{- include "utils.topology.pod_label" . | indent 8 }}
3236 annotations :
33- configmap-etc-hash : {{ include (print $ .Template.BasePath "/etc-configmap.yaml") . | sha256sum }}
34- secrets-hash : {{ include (print $ .Template.BasePath "/secrets.yaml") . | sha256sum }}
37+ configmap-etc-hash : {{ include (print .Template.BasePath "/etc-configmap.yaml") . | sha256sum }}
38+ secrets-hash : {{ include (print .Template.BasePath "/secrets.yaml") . | sha256sum }}
3539 {{- if .Values.proxysql.mode }}
3640 prometheus.io/scrape : " true"
3741 prometheus.io/targets : {{ required ".Values.alerts.prometheus missing" .Values.alerts.prometheus | quote }}
3842 {{- end }}
3943 {{- include "utils.linkerd.pod_and_service_annotation" . | indent 8 }}
4044 spec :
41- {{- tuple . "cinder" "api" | include "kubernetes_pod_anti_affinity" | nindent 6 }}
45+ {{- tuple . "cinder" (printf "api-%s" $type) | include "kubernetes_pod_anti_affinity" | nindent 6 }}
4246 {{- include "utils.proxysql.pod_settings" . | nindent 6 }}
43- {{- tuple . (dict "name" "cinder-api" ) | include "utils.topology.constraints" | indent 6 }}
47+ {{- tuple . (dict "name" (printf "cinder-api-%s" $type) ) | include "utils.topology.constraints" | indent 6 }}
4448 initContainers :
4549 {{- tuple . (dict "service" (include "cinder.service_dependencies" . ) "jobs" (include "cinder.migration_job_name" .)) | include "utils.snippets.kubernetes_entrypoint_init_container" | indent 6 }}
4650 {{- if .Values.proxysql.native_sidecar }}
5155 image : {{required ".Values.global.registry is missing" .Values.global.registry}}/loci-cinder:{{.Values.imageVersionCinderApi | default .Values.imageVersion | required "Please set cinder.imageVersion or similar" }}
5256 imagePullPolicy : {{ required ".Values.global.imagePullPolicy is missing" .Values.global.imagePullPolicy }}
5357 command :
54- {{- if .Values.api .use_uwsgi }}
58+ {{- if $conf .use_uwsgi }}
5559 - uwsgi
5660 - --ini
5761 - /etc/cinder/api_uwsgi.ini
7074 name : sentry
7175 key : {{ .Chart.Name }}.DSN.python
7276 {{- end }}
73- {{- if .Values.api .use_uwsgi }}
77+ {{- if $conf .use_uwsgi }}
7478 - name : OS_OSLO_MESSAGING_RABBIT__HEARTBEAT_IN_PTHREAD
7579 value : " true"
7680 {{- end }}
@@ -89,64 +93,16 @@ spec:
8993 port : cinder-api
9094 initialDelaySeconds : 15
9195 timeoutSeconds : 5
92- {{- if .Values.pod. resources.api }}
96+ {{- if $conf. resources }}
9397 resources :
94- {{ toYaml .Values.pod. resources.api | indent 12 }}
98+ {{- toYaml $conf. resources | nindent 12 }}
9599 {{- end }}
96100 ports :
97101 - name : cinder-api
98102 containerPort : {{.Values.cinderApiPortInternal }}
99103 volumeMounts :
100- - name : etccinder
101- mountPath : /etc/cinder
102- - name : cinder-etc
103- mountPath : /etc/cinder/cinder.conf
104- subPath : cinder.conf
105- readOnly : true
106- - name : cinder-etc-confd
107- mountPath : /etc/cinder/cinder.conf.d
108- - name : cinder-etc
109- mountPath : /etc/cinder/api-paste.ini
110- subPath : api-paste.ini
111- readOnly : true
112- {{- if .Values.api.use_uwsgi }}
113- - mountPath : /etc/cinder/api_uwsgi.ini
114- name : cinder-etc
115- subPath : api_uwsgi.ini
116- readOnly : true
117- {{- end }}
118- - name : cinder-etc
119- mountPath : /etc/cinder/policy.yaml
120- subPath : policy.yaml
121- readOnly : true
122- - name : cinder-etc
123- mountPath : /etc/cinder/logging.ini
124- subPath : logging.ini
125- readOnly : true
126- - name : cinder-etc
127- mountPath : /etc/cinder/cinder_audit_map.yaml
128- subPath : cinder_audit_map.yaml
129- readOnly : true
130- - name : cinder-etc
131- mountPath : /etc/cinder/resource_filters.json
132- subPath : resource_filters.json
133- readOnly : true
134- {{- if .Values.api_rate_limit.enabled }}
135- - name : cinder-etc
136- mountPath : /etc/cinder/ratelimit.yaml
137- subPath : ratelimit.yaml
138- readOnly : true
139- - name : redis-ratelimit-secret
140- mountPath : /etc/cinder/ratelimit-backend-secret.conf
141- subPath : ratelimit-backend-secret.conf
142- readOnly : true
143- {{- end }}
144- {{- if .Values.watcher.enabled }}
145104 - name : cinder-etc
146- mountPath : /etc/cinder/watcher.yaml
147- subPath : watcher.yaml
148- readOnly : true
149- {{- end }}
105+ mountPath : /etc/cinder
150106 {{- include "utils.proxysql.volume_mount" . | indent 12 }}
151107 {{- include "utils.coordination.volume_mount" . | indent 12 }}
152108 {{- if not .Values.proxysql.native_sidecar }}
@@ -163,27 +119,82 @@ spec:
163119 - name : metrics
164120 containerPort : {{ .Values.port_metrics }}
165121 volumeMounts :
166- - name : cinder -etc
167- mountPath : /etc/statsd/statsd-exporter.yaml
168- subPath : statsd-exporter.yaml
169- readOnly : true
170- {{- include "jaeger_agent_sidecar" . | indent 8 }}
122+ - name : statsd -etc
123+ mountPath : /etc/statsd/statsd-exporter.yaml
124+ subPath : statsd-exporter.yaml
125+ readOnly : true
126+ {{- include "jaeger_agent_sidecar" . | indent 8 }}
171127 volumes :
172- - name : etccinder
173- emptyDir : {}
174- - name : cinder-etc
175- configMap :
176- name : cinder-etc
177- - name : cinder-etc-confd
178- secret :
179- secretName : {{ .Release.Name }}-secrets
180- {{- include "utils.proxysql.volumes" . | indent 8 }}
181- {{- include "utils.coordination.volumes" . | indent 8 }}
182-
183- {{- if .Values.api_rate_limit.enabled }}
184- - name : redis-ratelimit-secret
185- secret :
186- secretName : cinder-api-ratelimit-secret
187- {{- end }}
188-
128+ - name : cinder-etc
129+ projected :
130+ sources :
131+ - configMap :
132+ name : cinder-etc
133+ items :
134+ - key : cinder.conf
135+ path : cinder.conf
136+ - key : logging.ini
137+ path : logging.ini
138+ - secret :
139+ name : {{ .Release.Name }}-secrets
140+ items :
141+ - key : secrets.conf
142+ path : cinder.conf.d/secrets.conf
143+ - configMap :
144+ name : cinder-api-{{ $type }}-etc
145+ items :
146+ - key : cinder-api.conf
147+ path : cinder-api.conf
148+ - key : api-paste.ini
149+ path : api-paste.ini
150+ {{- if $conf.use_uwsgi }}
151+ - key : api_uwsgi.ini
152+ path : api_uwsgi.ini
153+ {{- end }}
154+ - key : policy.yaml
155+ path : policy.yaml
156+ - key : resource_filters.json
157+ path : resource_filters.json
158+ {{- if .Values.audit.enabled }}
159+ - key : cinder_audit_map.yaml
160+ path : cinder_audit_map.yaml
161+ {{- end }}
162+ {{- if .Values.watcher.enabled }}
163+ - key : watcher.yaml
164+ path : watcher.yaml
165+ {{- end }}
166+ {{- if $conf.rate_limit.enabled }}
167+ - key : ratelimit.yaml
168+ path : ratelimit.yaml
169+ {{- end }}
170+ {{- if $conf.rate_limit.enabled }}
171+ - secret :
172+ name : cinder-api-{{ $type }}-ratelimit-secret
173+ items :
174+ - key : ratelimit-backend-secret.conf
175+ path : ratelimit-backend-secret.conf
176+ {{- end }}
177+ - name : statsd-etc
178+ projected :
179+ sources :
180+ - configMap :
181+ name : cinder-etc
182+ items :
183+ - key : statsd-exporter.yaml
184+ path : statsd-exporter.yaml
185+ {{- include "utils.proxysql.volumes" . | indent 6 }}
186+ {{- include "utils.coordination.volumes" . | indent 6 }}
187+ {{- end }}
188+ {{- end }}
189189
190+ {{- include "cinder.api.deployment" (tuple . "external" (
191+ dict "replicas" .Values.pod.replicas.api_external
192+ " use_uwsgi" .Values.api_external.use_uwsgi
193+ " resources" .Values.pod.resources.api_external
194+ " rate_limit" .Values.api_external.rate_limit )) }}
195+ ---
196+ {{ include "cinder.api.deployment" (tuple . "internal" (
197+ dict "replicas" .Values.pod.replicas.api_internal
198+ " use_uwsgi" .Values.api_internal.use_uwsgi
199+ " resources" .Values.pod.resources.api_internal
200+ " rate_limit" .Values.api_internal.rate_limit )) }}
0 commit comments