openstack-helm/cinder/templates/cron-job-service-cleaner.yaml
okozachenko d554d74bf0 Fix cinder host name
Now `cinder-volume-worker` is set as DEFAULT.host. It results only
one host per volume service type registered regardless of replica
numbers.

To fix this, removed DEFAULT.host from default values so hostname
of pods will be used as host name.
It will produce garbage services with down state because pod name
changes every creation. To avoid this, added a cronjob for service
clean.

Change-Id: I9ec6f62105124f9088afdb231099b532fc83bb34
2022-09-06 19:47:50 +10:00

86 lines
3.6 KiB
YAML

{{/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/}}
{{- if .Values.manifests.cron_job_service_cleaner }}
{{- $envAll := . }}
{{- $serviceAccountName := "cinder-service-cleaner" }}
{{ tuple $envAll "service_cleaner" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }}
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: cinder-service-cleaner
annotations:
{{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }}
spec:
schedule: {{ .Values.jobs.service_cleaner.cron | quote }}
successfulJobsHistoryLimit: {{ .Values.jobs.service_cleaner.history.success }}
failedJobsHistoryLimit: {{ .Values.jobs.service_cleaner.history.failed }}
{{- if .Values.jobs.service_cleaner.starting_deadline }}
startingDeadlineSeconds: {{ .Values.jobs.service_cleaner.starting_deadline }}
{{- end }}
concurrencyPolicy: Forbid
jobTemplate:
metadata:
labels:
{{ tuple $envAll "cinder" "service-cleaner" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
spec:
template:
metadata:
labels:
{{ tuple $envAll "cinder" "service-cleaner" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 12 }}
spec:
serviceAccountName: {{ $serviceAccountName }}
{{ dict "envAll" $envAll "application" "service_cleaner" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 10 }}
restartPolicy: OnFailure
nodeSelector:
{{ .Values.labels.job.node_selector_key }}: {{ .Values.labels.job.node_selector_value }}
{{ if $envAll.Values.pod.tolerations.cinder.enabled }}
{{ tuple $envAll "cinder" | include "helm-toolkit.snippets.kubernetes_tolerations" | indent 10 }}
{{ end }}
initContainers:
{{ tuple $envAll "service_cleaner" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 12 }}
containers:
- name: cinder-service-cleaner
{{ tuple $envAll "cinder_service_cleaner" | include "helm-toolkit.snippets.image" | indent 14 }}
{{ tuple $envAll $envAll.Values.pod.resources.jobs.service_cleaner | include "helm-toolkit.snippets.kubernetes_resources" | indent 14 }}
{{ dict "envAll" $envAll "application" "service_cleaner" "container" "cinder_service_cleaner" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 14 }}
env:
command:
- /tmp/cinder-service-cleaner.sh
volumeMounts:
- name: pod-tmp
mountPath: /tmp
- name: cinder-bin
mountPath: /tmp/cinder-service-cleaner.sh
subPath: cinder-service-cleaner.sh
readOnly: true
- name: cinder-etc
mountPath: /etc/cinder/cinder.conf
subPath: cinder.conf
readOnly: true
volumes:
- name: pod-tmp
emptyDir: {}
- name: cinder-etc
secret:
secretName: cinder-etc
defaultMode: 0444
- name: cinder-bin
configMap:
name: cinder-bin
defaultMode: 0555
{{- end }}