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

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: sqvs-deployment
  namespace: isecl
  labels:
    env: demo
    app: sqvs
spec:
  replicas: 1
  selector:
    matchLabels:
      app: sqvs
  template:
    metadata:
      labels:
        app: sqvs
    spec:
      securityContext:
        fsGroup: 2000
      initContainers:
        - image: busybox:1.32
          imagePullPolicy: Always
          name: chmod-pg-data
          command:
            - /bin/chown
            - -R
            - "1001"
            - /etc/sqvs
            - /var/log/sqvs
          volumeMounts:
            - name: sqvs-config-volume
              mountPath: /etc/sqvs
            - name: sqvs-logs-volume
              mountPath: /var/log/sqvs
            - name: trusted-rootca
              mountPath: /tmp/
      containers:
        - name: sqvs
          image: <image-name>:<image-tag>
          imagePullPolicy: Always
          securityContext:
            runAsUser: 1001
            runAsGroup: 1001
          ports:
            - containerPort: 12000
          envFrom:
            - configMapRef:
                name: sqvs-config
          volumeMounts:
            - name: sqvs-config-volume
              mountPath: /etc/sqvs/
            - name: sqvs-logs-volume
              mountPath: /var/log/sqvs/
            - mountPath: /etc/secrets/
              name: sqvs-secrets
              readOnly: true
            - name: trusted-rootca
              mountPath: /tmp/ 
      volumes:
        - name: sqvs-logs-volume
          hostPath:
            path: /var/log/sqvs/
            type: DirectoryOrCreate
        - name: sqvs-config-volume
          hostPath:
            path: /etc/sqvs/
            type: DirectoryOrCreate
        - name: sqvs-secrets
          secret:
              secretName: bearer-token
        - name: trusted-rootca
          secret:
              secretName: sqvs-trusted-rootca
