# Copyright (C) 2021  Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ihub-deployment
  namespace: isecl
  labels:
    env: test
    app: ihub
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ihub
  template:
    metadata:
      labels:
        app: ihub
    spec:
      securityContext:
        fsGroup: 1001
      initContainers:
        - image: busybox:1.32
          imagePullPolicy: Always
          name: chmod-pg-data
          command:
            - /bin/chown
            - -R
            - "1001"
            - /etc/ihub
            - /var/log/ihub
          volumeMounts:
            - name: ihub-config-volume
              mountPath: /etc/ihub
            - name: ihub-logs-volume
              mountPath: /var/log/ihub
      containers:
        - name: ihub
          image: <image-name>:<image-tag>
          imagePullPolicy: Always
          securityContext:
            runAsUser: 1001
            runAsGroup: 1001
          envFrom:
            - configMapRef:
                name: ihub-config
          volumeMounts:
            - name: ihub-config-volume
              mountPath: /etc/ihub/
            - name: ihub-k8s-certs
              mountPath: /etc/ihub/apiserver.crt
              subPath: apiserver.crt
            - name: ihub-logs-volume
              mountPath: /var/log/ihub/
            - mountPath: /etc/secrets/
              name: ihub-secrets
              readOnly: true
      volumes:
        - name: ihub-logs-volume
          hostPath:
            path: /var/log/ihub/
            type: DirectoryOrCreate
        - name: ihub-config-volume
          hostPath:
            path: /etc/ihub/
            type: DirectoryOrCreate
        - name: ihub-k8s-certs
          secret:
            secretName: ihub-k8s-certs
            defaultMode: 0640
        - name: ihub-secrets
          projected:
            sources:
              - secret:
                  name: ihub-credentials
              - secret:
                  name: bearer-token