apiVersion: batch/v1
kind: Job
metadata:
  name: neutron-migration
  labels:
    system: openstack
    type: configuration
    component: neutron
spec:
  template:
    spec:
      restartPolicy: OnFailure
      containers:
        - name: neutron-migration
          image: {{.Values.global.registry}}/loci-neutron:{{default .Values.imageVersion | required "Please set neutron.imageVersion or similar"}}
          imagePullPolicy: IfNotPresent
          command:
            - kubernetes-entrypoint
          env:
            - name: COMMAND
              value: "neutron-db-manage upgrade head"
            - name: NAMESPACE
              value: {{ .Release.Namespace }}
            - name: DEPENDENCY_SERVICE
              value: "{{ .Release.Name }}-mariadb"
            - name: PGAPPNAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
          volumeMounts:
            - mountPath: /etc/neutron
              name: etc-neutron
              readOnly: true
      volumes:
        - name: etc-neutron
          projected:
            defaultMode: 420
            sources:
            - configMap:
                items:
                - key: neutron.conf
                  path: neutron.conf
                - key: ml2-conf.ini
                  path: plugins/ml2/ml2-conf.ini
                name: neutron-etc

{{/*
   With Helm3, we don't force the replacements of job specs anymore, which
   causes deployment issues since kuberentes job specs are immutable by default.
   We solve this by generating an image specific name for every deployment,
   therefor no job will be replaced. Instead, a new job will be spawned while
   the old one will be deleted.
*/}}
{{- $jobSuffix := trimPrefix "neutron-" .Values.imageVersion -}}
apiVersion: batch/v1
kind: Job
metadata:
  name: neutron-migration
  labels:
    system: openstack
    type: configuration
    component: neutron
spec:
  template:
    spec:
      restartPolicy: OnFailure
      containers:
        - name: neutron-migration-{{$jobSuffix}}
          image: {{.Values.global.registry}}/loci-neutron:{{default .Values.imageVersion | required "Please set neutron.imageVersion or similar"}}
          imagePullPolicy: IfNotPresent
          command:
            - kubernetes-entrypoint
          env:
            - name: COMMAND
              value: "neutron-db-manage upgrade head"
            - name: NAMESPACE
              value: {{ .Release.Namespace }}
            - name: DEPENDENCY_SERVICE
              value: "{{ .Release.Name }}-mariadb"
            - name: PGAPPNAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
          volumeMounts:
            - mountPath: /etc/neutron
              name: etc-neutron
              readOnly: true
      volumes:
        - name: etc-neutron
          projected:
            defaultMode: 420
            sources:
            - configMap:
                items:
                - key: neutron.conf
                  path: neutron.conf
                - key: ml2-conf.ini
                  path: plugins/ml2/ml2-conf.ini
                name: neutron-etc

Fix helm3 deployment by naming every migration-job specifically
[Neutron] Fix helm3 deployment by naming every migration-job specifically

   With Helm3, we don't force the replacements of job specs anymore, which
   causes deployment issues since kuberentes job specs are immutable by default.
   We solve this by generating an image specific name for every deployment,
   therefor no job will be replaced. Instead, a new job will be spawned while
   the old one will be deleted.
