apiVersion: apps/v1
kind: Deployment
metadata:
  name: app
spec:
  selector:
    matchLabels:
      service: app
  replicas: 5
  template:
    metadata:
      labels:
        service: app
    spec:
      containers:
        - name: main
          image: sloopstash/app:v1
          imagePullPolicy: Always
          volumeMounts:
            - name: supervisor-server
              mountPath: /etc/supervisord.conf
            - name: app-supervisor
              mountPath: /etc/supervisord.d/app.ini
            - name: nginx-supervisor
              mountPath: /etc/supervisord.d/nginx.ini
            - name: nginx-server
              mountPath: /etc/nginx/nginx.conf
            - name: app-nginx
              mountPath: /etc/nginx/conf.d/app.conf
            - name: app-source
              mountPath: /opt/app
          command:
            - "/usr/bin/supervisord"
            - "-c"
            - "/etc/supervisord.conf"
          ports:
            - containerPort: 80
          readinessProbe:
            exec:
              command:
                - "/usr/bin/supervisorctl"
                - "status"
                - "nginx"
            initialDelaySeconds: 5
            periodSeconds: 10
          livenessProbe:
            httpGet:
              scheme: HTTP
              path: /health
              port: 80
              httpHeaders:
                - name: Host
                  value: app.crm
            initialDelaySeconds: 15
            periodSeconds: 20
      volumes:
        - name: supervisor-server
          hostPath:
            path: /opt/kickstart-kubernetes/supervisor/conf/main.conf
            type: File
        - name: app-supervisor
          hostPath:
            path: /opt/kickstart-kubernetes/supervisor/conf/app.ini
            type: File
        - name: nginx-supervisor
          hostPath:
            path: /opt/kickstart-kubernetes/supervisor/conf/nginx.ini
            type: File
        - name: nginx-server
          hostPath:
            path: /opt/kickstart-kubernetes/nginx/conf/main.conf
            type: File
        - name: app-nginx
          hostPath:
            path: /opt/kickstart-kubernetes/nginx/conf/app.conf
            type: File
        - name: app-source
          hostPath:
            path: /opt/kickstart-kubernetes/app
            type: Directory
