{%- set resourceName = kolla_kubernetes.cli.args.service_name %}
apiVersion: apps/v1alpha1 
kind: PetSet
spec:
  serviceName: "mariadb"
  replicas: 1
  template:
    metadata:
      labels:
        service: mariadb
      annotations:
        pod.alpha.kubernetes.io/initialized: "true"
    spec:
      terminationGracePeriodSeconds: 120 
      containers:
        - image: "{{ mariadb_image_full }}"
          name: mariadb
          lifecycle:
            preStop:
              exec:
                command: ["mysqladmin -u {{ database_user }} -p$DATABASE_PASSWORD shutdown"]
          volumeMounts:
            - mountPath: {{ container_config_directory }}
              name: mariadb-config
            - mountPath: /var/lib/mysql
              name: mariadb-persistent-storage
            - mountPath: /var/log/kolla/
              name: kolla-logs
          env:
            - name: KOLLA_KUBERNETES
              value: ""
            - name: KOLLA_CONFIG_STRATEGY
              value: {{ config_strategy }}
            - name: DATABASE_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: database-password
                  key: password
          ports:
            - containerPort: {{ mariadb_port }}
              name: mariadb
      volumes:
        - name: mariadb-config
          configMap:
            name: mariadb-configmap
        - name: mariadb-persistent-storage
          persistentVolumeClaim:
            claimName: {{ resourceName }}
        - name: kolla-logs
          emptyDir: {}
metadata:
   name: mariadb
