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

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: cms-deployment
  namespace: isecl
  labels:
    env: test
    app: cms
spec:
  replicas: 1
  selector:
    matchLabels:
      app: cms
  template:
    metadata:
      labels:
        app: cms
    spec:
      securityContext:
        fsGroup: 1001
      initContainers:
        - image: busybox:1.32
          imagePullPolicy: Always
          name: chmod-cms-data
          command:
            - /bin/chown
            - -R
            - "1001"
            - /etc/cms
            - /var/log/cms
          volumeMounts:
            - name: cms-config-volume
              mountPath: /etc/cms
            - name: cms-logs-volume
              mountPath: /var/log/cms
      containers:
        - image: <image-name>:<image-tag>
          name: cms
          imagePullPolicy: Always
          securityContext:
            runAsUser: 1001
            runAsGroup: 1001
          ports:
            - containerPort: 8445
          envFrom:
            - configMapRef:
                name: cms-config
          volumeMounts:
            - name: cms-logs-volume
              mountPath: /var/log/cms/
            - name: cms-config-volume
              mountPath: /etc/cms/
      volumes:
        - name: cms-logs-volume
          hostPath:
            path: /var/log/cms/
            type: DirectoryOrCreate
        - name: cms-config-volume
          hostPath:
            path: /etc/cms/
            type: DirectoryOrCreate
