{%- set podTypeBootstrap = "yes" %}
{%- set resourceName = kolla_kubernetes.cli.args.resource_name %}
{%- import "services/common/common-lib.yml.j2" as lib with context %}
apiVersion: batch/v1
kind: Job
metadata:
  name: glance-manage-db
  namespace: {{ kolla_kubernetes_namespace }}
spec:
  parallelism: 1
  completions: 1
  template:
    spec:
      restartPolicy: OnFailure
      nodeSelector:
{%- set selector = kolla_kubernetes_hostlabel_controller %}
          {{ selector.key }}: {{ selector.value }}
      containers:
        - image: "{{ glance_api_image_full }}"
          name: main
          env:
            - name: KOLLA_BOOTSTRAP
              value: ""
            - name: KOLLA_CONFIG_STRATEGY
              value: "{{ config_strategy }}"
          volumeMounts:
{{ lib.common_volume_mounts(indent=12) }}
{% if glance_backend_ceph != "yes" %}
            - mountPath: {{ container_config_directory }}
              name: glance-api-config
              readOnly: true
            - mountPath: /var/lib/glance/
              name: glance-persistent-storage
{% else %}
            - mountPath: {{ container_config_directory }}/config.json
              name: glance-api-config
              readOnly: true
              subPath: config.json
            - mountPath: {{ container_config_directory }}/glance-api.conf
              name: glance-api-config
              readOnly: true
              subPath: glance-api.conf
            - mountPath: {{ container_config_directory}}/ceph.conf
              name: ceph-conf
              subPath: ceph.conf
            - mountPath: {{ container_config_directory}}/ceph.client.glance.keyring
              name: ceph-conf
              subPath: ceph.conf
{% endif %}
      volumes:
{{ lib.common_volumes(indent=8) }}
        - name: glance-api-config
          configMap:
            name: glance-api
{% if glance_backend_ceph != "yes" %}
        - name: glance-persistent-storage
          persistentVolumeClaim:
            claimName: {{ kolla_kubernetes.template.vars.pvc_name }}
{% else %}
        - name: ceph-conf
          configMap:
            name: ceph-conf
{% endif %}
