---
apiVersion: apps/v1
kind: Deployment

metadata:
    name: api-v1

spec:
    replicas: 1
    strategy:
        rollingUpdate:
            maxSurge: 1
            maxUnavailable: 1
        type: RollingUpdate
    selector:
        matchLabels:
            app: library-api # this is for Istio
            version: v1
            platform: sweetrpg
            package: library
            component: api
    template:
        metadata:
            labels:
                platform: sweetrpg
                app: library-api
                package: library
                component: api
                version: v1
        spec:
            serviceAccountName: library-api
            imagePullSecrets:
                - name: sweetrpg-registry
            containers:
                - name: app
                  image: registry.sweetrpg.com/sweetrpg-library-api:latest
                  imagePullPolicy: Always
                  envFrom:
                      - configMapRef:
                            name: api-v1-common
                      - configMapRef:
                            name: api-v1-env
                      - secretRef:
                            name: api-v1-db
                      - secretRef:
                            name: api-v1-auth
                      - secretRef:
                            name: api-v1-misc
                      - secretRef:
                            name: api-v1-cache
                  env: []
                  ports:
                      - containerPort: 8281
                        name: http
                  resources:
                      requests:
                          cpu: "20m"
                          memory: "55m"
                      limits:
                          cpu: "1.0"
                          memory: "1Gi"
                  livenessProbe:
                      httpGet:
                          path: /health/ping
                          port: 8281
                      initialDelaySeconds: 90
                      timeoutSeconds: 10
                  readinessProbe:
                      httpGet:
                          path: /health/ping
                          port: 8281
                      initialDelaySeconds: 30
                      timeoutSeconds: 10
                  volumeMounts:
                      - mountPath: /data
                        name: data
                      - mountPath: /config
                        name: config
            volumes:
                - name: config
                  secret:
                      secretName: api-v1-files
                      items:
                          - key: newrelic.ini
                            path: newrelic.ini
                - name: data
                  emptyDir: {}
            restartPolicy: Always
