apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: builder
  annotations:
    lookit-env-vars: "second-container"
    wait-for-gcloud-sqlproxy: "true"
    wait-for-rabbitmq: "true"
spec:
  selector:
    matchLabels: {}
  podManagementPolicy: OrderedReady
  serviceName: builder
  template:
    spec:
      initContainers: []
      containers:
      - name: docker
        image: docker:dind
        imagePullPolicy: Always
        ports:
          - containerPort: 2376
            name: docker
            protocol: TCP
        securityContext:
          privileged: true
        volumeMounts:
          - name: docker-volume
            mountPath: /var/lib/docker
          - name: docker-client-certs
            mountPath: /certs/client
          - name: checkouts-volume
            mountPath: /code/ember_build/checkouts
          - name: deployments-volume
            mountPath: /code/ember_build/deployments
      - name: builder
        image: lookit
        imagePullPolicy: IfNotPresent
        command:
        - gosu
        - www-data
        - celery
        - -A
        - project.celery.app
        - worker
        - -c
        - "2"
        - -l
        - INFO
        - -n
        - worker.%h
        - --without-gossip
        - --maxtasksperchild
        - "1"
        - -Q
        - builds,cleanup
        env:
        - name: DOCKER_HOST
          value: tcp://localhost:2376  # use TLS port
        - name: DOCKER_TLS_VERIFY
          value: "1"
        - name: DOCKER_CERT_PATH
          value: "/certs/client"
        volumeMounts:
        - name: checkouts-volume
          mountPath: /code/ember_build/checkouts
        - name: deployments-volume
          mountPath: /code/ember_build/deployments
        - name: secret-volume
          mountPath: /etc/googleAppCreds.json
          readOnly: true
          subPath: googleAppCreds.json
        - name: docker-client-certs
          mountPath: /certs/client
      volumes:
      - name: checkouts-volume
        emptyDir: {}
      - name: docker-client-certs
        emptyDir: {}
      - name: deployments-volume
        emptyDir: {}
      - name: config-volume
        configMap:
          defaultMode: 420
          name: lookit-configmap
      - name: secret-volume
        secret:
          defaultMode: 420
          secretName: lookit-secrets
      - name: cloudsql-instance-credentials
        secret:
          defaultMode: 420
          secretName: cloudsql-instance-credentials
  updateStrategy:
    rollingUpdate:
      partition: 0
    type: RollingUpdate
  volumeClaimTemplates:
  - metadata:
      name: docker-volume
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 10Gi
      storageClassName: ssd
      volumeMode: Filesystem
