apiVersion: apps/v1
kind: Deployment
metadata:
  name: kuard
  labels:
    app: kuard
spec:
  replicas: 2
  selector:
    matchLabels:
      app: kuard
  minReadySeconds: 30
  progressDeadlineSeconds: 600
  revisionHistoryLimit: 10
  strategy:
    rollingUpdate:
      # Rolling
      maxUnavailable: 20%
      maxSurge: 0%
      # Blue/Green
      # maxUnavailable: 0%
      # maxSurge: 100%
  template:
    metadata:
      name: kuard
      labels:
        app: kuard
      annotations:
        kubernetes.io/change-cause: Initial deploy of gcr.io/kuar-demo/kuard-amd64:1
        checksum.kuard.io/configmap-app: 4028b1207b09641310193a85f85b42d1f9ee51673fd3824d43c39df1e03fa441
        checksum.kuard.io/secret-api-token: eccbff586ce5457cebd9a1c3fcc7156b3fa02151e09a595cb04b1ad318f0d2bb
        checksum.kuard.io/secret-users-db: d22ebceb520ad11895522ec54b9d6caffc92d3f7a445173caea04d7c86c256f2
    spec:
      volumes:
      - name: secret-volume
        secret:
          secretName: users-db

      containers:
      - name: kuard
        imagePullPolicy: IfNotPresent
        image: gcr.io/kuar-demo/kuard-amd64:1

        ports:
          - name: app
            containerPort: 8080

        env:
          - name: API_KEY
            valueFrom:
              secretKeyRef:
                name: api-token
                key: API_TOKEN

        envFrom:
         - configMapRef:
             name: app

        volumeMounts:
        - name: secret-volume
          readOnly: true
          mountPath: '/etc/secrets'

        resources:
          requests:
            memory: "200Mi"
            cpu: "250m"
          limits:
            memory: "400Mi"
            cpu: "500m"

        # Liveness Check: Is your application alive?
        livenessProbe:
          httpGet:
            path: /healthy
            port: app
          initialDelaySeconds: 5
          timeoutSeconds: 3
          periodSeconds: 5
          failureThreshold: 3
        #
        # Readiness Check: Is your app ready to serve traffic
        #
        # Use this if there is something your container needs to do on
        # startup (e.g. compute and load large data-set into memory)
        # before it can be considered ready to receive traffic.
        #
        readinessProbe:
          httpGet:
            path: /ready
            port: app
          initialDelaySeconds: 10
          timeoutSeconds: 3
          periodSeconds: 5
          failureThreshold: 3

      automountServiceAccountToken: false
