apiVersion: apps/v1
kind: Deployment
metadata:
  name: ${NAMEPREFIX}-ironic
spec:
  replicas: 1
  strategy:
    # We cannot run Ironic with more than one replica at a time. The recreate
    # strategy makes sure that the old pod is gone before a new is started.
    type: Recreate
  selector:
    matchLabels:
      name: ${NAMEPREFIX}-ironic
  template:
    metadata:
      labels:
        name: ${NAMEPREFIX}-ironic
    spec:
      hostNetwork: true
      containers:
        - name: ironic-dnsmasq
          image: quay.io/metal3-io/ironic
          imagePullPolicy: Always
          securityContext:
             capabilities:
               add: ["NET_ADMIN"]
          command:
            - /bin/rundnsmasq
          livenessProbe:
           exec:
             command: ["sh", "-c", "ss -lun | grep :67 && ss -lun | grep :69"]
           initialDelaySeconds: 30
           periodSeconds: 30
           timeoutSeconds: 10
           successThreshold: 1
           failureThreshold: 10
          readinessProbe:
           exec:
             command: ["sh", "-c", "ss -lun | grep :67 && ss -lun | grep :69"]
           initialDelaySeconds: 30
           periodSeconds: 30
           timeoutSeconds: 10
           successThreshold: 1
           failureThreshold: 10
          volumeMounts:
            - mountPath: /shared
              name: ironic-data-volume
          envFrom:
            - configMapRef:
                name: ironic-bmo-configmap
        - name: mariadb
          image: quay.io/metal3-io/mariadb
          imagePullPolicy: Always
          livenessProbe:
           exec:
             command: ["sh", "-c", "mysqladmin status -uironic -p$(printenv MARIADB_PASSWORD)"]
           initialDelaySeconds: 30
           periodSeconds: 30
           timeoutSeconds: 10
           successThreshold: 1
           failureThreshold: 10
          readinessProbe:
           exec:
             command: ["sh", "-c", "mysqladmin status -uironic -p$(printenv MARIADB_PASSWORD)"]
           initialDelaySeconds: 30
           periodSeconds: 30
           timeoutSeconds: 10
           successThreshold: 1
           failureThreshold: 10
          volumeMounts:
            - mountPath: /shared
              name: ironic-data-volume
          env:
            - name: MARIADB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: mariadb-password
                  key: password
            - name: RESTART_CONTAINER_CERTIFICATE_UPDATED
              valueFrom:
                 configMapKeyRef:
                  name: ironic-bmo-configmap
                  key: RESTART_CONTAINER_CERTIFICATE_UPDATED
        - name: ironic
          image: quay.io/metal3-io/ironic
          imagePullPolicy: Always
          command:
            - /bin/runironic
          livenessProbe:
           exec:
             command: ["sh", "-c", "curl -sSf http://127.0.0.1:6385 || curl -sSfk https://127.0.0.1:6385"]
           initialDelaySeconds: 30
           periodSeconds: 30
           timeoutSeconds: 10
           successThreshold: 1
           failureThreshold: 10
          readinessProbe:
           exec:
             command: ["sh", "-c", "curl -sSf http://127.0.0.1:6385 || curl -sSfk https://127.0.0.1:6385"]
           initialDelaySeconds: 30
           periodSeconds: 30
           timeoutSeconds: 10
           successThreshold: 1
           failureThreshold: 10
          volumeMounts:
            - mountPath: /shared
              name: ironic-data-volume
          envFrom:
            - configMapRef:
                name: ironic-bmo-configmap
          env:
            - name: MARIADB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: mariadb-password
                  key: password
        - name: ironic-log-watch
          image: quay.io/metal3-io/ironic
          imagePullPolicy: Always
          command:
            - /bin/runlogwatch.sh
          volumeMounts:
            - mountPath: /shared
              name: ironic-data-volume
        - name: ironic-inspector
          image: quay.io/metal3-io/ironic
          imagePullPolicy: Always
          readinessProbe:
            exec:
              command: ["sh", "-c", "curl -sSf http://127.0.0.1:5050 || curl -sSf -k https://127.0.0.1:5050"]
            initialDelaySeconds: 30
            periodSeconds: 30
            timeoutSeconds: 10
            successThreshold: 1
            failureThreshold: 10
          livenessProbe:
            exec:
              command: ["sh", "-c", "curl -sSf http://127.0.0.1:5050 || curl -sSf -k https://127.0.0.1:5050"]
            initialDelaySeconds: 30
            periodSeconds: 30
            timeoutSeconds: 10
            successThreshold: 1
            failureThreshold: 10
          command:
            - /bin/runironic-inspector
          envFrom:
            - configMapRef:
                name: ironic-bmo-configmap
        - name: ironic-httpd
          image: quay.io/metal3-io/ironic
          imagePullPolicy: Always
          command:
            - /bin/runhttpd
          livenessProbe:
           exec:
             command: ["sh", "-c", "curl -sSfk https://127.0.0.1:6180"]
           initialDelaySeconds: 30
           periodSeconds: 30
           timeoutSeconds: 10
           successThreshold: 1
           failureThreshold: 10
          readinessProbe:
           exec:
             command: ["sh", "-c", "curl -sSfk https://127.0.0.1:6180"]
           initialDelaySeconds: 30
           periodSeconds: 30
           timeoutSeconds: 10
           successThreshold: 1
           failureThreshold: 10
          volumeMounts:
            - mountPath: /shared
              name: ironic-data-volume
          envFrom:
            - configMapRef:
                name: ironic-bmo-configmap
      initContainers:
        - name: ironic-ipa-downloader
          image: quay.io/metal3-io/ironic-ipa-downloader
          imagePullPolicy: Always
          command:
            - /usr/local/bin/get-resource.sh
          envFrom:
            - configMapRef:
                name: ironic-bmo-configmap
          volumeMounts:
            - mountPath: /shared
              name: ironic-data-volume
      volumes:
        - name: ironic-data-volume
          emptyDir: {}
