apiVersion: apps/v1
kind: Deployment
metadata:
  name: api-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      component: api
  template:
    metadata:
      name: api-pod
      labels:
        component: api
    spec:
      volumes:
        - name: api-storage
          persistentVolumeClaim:
            claimName: api-storage-pvc
        - name: backup
          persistentVolumeClaim:
            claimName: backup-pvc
        - name: nginx-config
          configMap:
            name: api-nginx-cm
      containers:
        - name: api
          image: moail/timeline-api
          envFrom:
            - configMapRef:
                name: api-cm
            - secretRef:
                name: api-secret
          env:
            - name: DB_DATABASE
              valueFrom:
                secretKeyRef:
                  name: db-secret
                  key: database
            - name: DB_USERNAME
              valueFrom:
                secretKeyRef:
                  name: db-secret
                  key: username
            - name: DB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: db-secret
                  key: password
          securityContext:
            runAsGroup: 1500
            runAsUser: 1500
          volumeMounts:
            - name: api-storage
              mountPath: /api/storage/app
            - name: backup
              mountPath: /backup
        - name: nginx
          image: moail/timeline-api-nginx
          readinessProbe:
            httpGet:
              path: /api
              port: 80
          livenessProbe:
            httpGet:
              path: /api
              port: 80
          volumeMounts:
            - name: api-storage
              mountPath: /api/storage/app
              readOnly: true
            - name: nginx-config
              mountPath: /etc/nginx/conf.d
