Files
apigateway-ocp/apigateway/charts/v7-traceability/templates/job.yaml
Conan Scott 555c441ad1 Updated to 7.7.0.20250830-3-BN0276-ubi
Updated ANM destinationCertCA for 7.7.0.20250830-3-BN0276-ubi
2025-11-20 15:56:45 +08:00

91 lines
2.9 KiB
YAML

{{- if not (.Values.dataVolume.useHostPath) }}
{{- if .Values.nodeSelector -}}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "v7-traceability.fullname" . }}-migrate-to-pvc
labels:
{{- include "v7-traceability.labels" . | nindent 4 }}
spec:
template:
metadata:
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-weight": "-2"
"helm.sh/hook-delete-policy": "before-hook-creation"
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "v7-traceability.selectorLabels" . | nindent 8 }}
{{- with .Values.additionalLabels }}
{{- range $key, $value := . }}
{{ default "none" $key }}: {{ default "none" $value | quote }}
{{- end }}
{{- end }}
spec:
restartPolicy: OnFailure
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.initContainer.enabled }}
initContainers:
{{- end }}
serviceAccountName: {{ include "v7-traceability.serviceAccountName" . }}
{{- with .Values.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: migrate
image: "{{ .Values.initContainer.image.name }}"
imagePullPolicy: {{ .Values.initContainer.image.pullPolicy }}
securityContext: {{- toYaml .Values.initContainer.securityContext | nindent 12 }}
command:
- sh
- -c
- |
echo "checking if data should be migrated"
if test -f /data-old/meta.json; then
# if a meta.json file exists in the old directory then migrate the data
if test -d /data; then
# clean the destination directory before migration
echo "clean the destination directory before migration"
rm -r /data/*
fi
echo "migrating the data now"
mv /data-old/* /data/
fi
volumeMounts:
- name: data
mountPath: /data
- name: data-old
mountPath: /data-old
volumes:
- name: data
persistentVolumeClaim:
claimName: {{ .Values.persistentVolumeClaimConfig.data.name }}
- name: data-old
hostPath:
path: {{ .Values.dataVolume.hostPath }}
type: DirectoryOrCreate
{{- if .Values.nodeSelector }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- else }}
nodeSelector:
traceability-agent: "true"
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- end }}