apiVersion: apps/v1
kind: Deployment
metadata:
  name: progapanda-org
  labels:
    app.kubernetes.io/name: progapanda-org
    app.kubernetes.io/instance: progapanda-org
    app.kubernetes.io/version: "1"
spec:
  replicas: 5
  selector:
    matchLabels:
      app.kubernetes.io/name: progapanda-org
      app.kubernetes.io/instance: progapanda-org
  template:
    metadata:
      labels:
        app.kubernetes.io/name: progapanda-org
        app.kubernetes.io/instance: progapanda-org
    spec:
      containers:
        - name: progapanda-org
          image: "docker.io/progapandist/progapanda-org"
          command:
            - ./webterm
          env:
            - name: DOCKER_TLS_VERIFY
              value: "1"
            - name: DOCKER_HOST
              value: tcp://127.0.0.1:2376
            - name: DOCKER_TLS_CERTDIR
              value: /certs/client
            - name: DOCKER_CERT_PATH
              value: /certs/client
          imagePullPolicy: Always
          volumeMounts:
            - name: docker-certs
              mountPath: /certs
          ports:
            - name: http
              containerPort: 4567
              protocol: TCP
          resources:
            requests:
              cpu: 20m
              memory: 64Mi
            limits:
              cpu: 40m
              memory: 128Mi

        # DIND sidecar
        - name: dind-daemon
          image: docker:stable-dind
          env:
            - name: DOCKER_TLS_CERTDIR
              value: /certs
          securityContext:
            privileged: true
          volumeMounts:
            - name: docker-certs
              mountPath: /certs
            - name: docker-graph-storage
              mountPath: /var/lib/docker
          ports:
            - name: docker
              containerPort: 2376
              protocol: TCP
          resources:
            requests:
              cpu: 100m
              memory: 128Mi
              ephemeral-storage: 128Mi
            limits:
              cpu: 200m
              memory: 256Mi
              ephemeral-storage: 256Mi

      # Volumes
      volumes:
        - name: docker-certs
          hostPath:
            path: /certs
        - name: docker-graph-storage
          emptyDir: {}
