apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "photos.fullname" . }}-api
  labels:
    {{- include "photos.labels" . | nindent 4 }}
    app.kubernetes.io/component: api
spec:
  replicas: {{ .Values.api.replicas }}
  selector:
    matchLabels:
      app.kubernetes.io/name: photos
      app.kubernetes.io/instance: {{ .Release.Name }}
      app.kubernetes.io/component: api
  template:
    metadata:
      labels:
        {{- include "photos.labels" . | nindent 8 }}
        app.kubernetes.io/component: api
    spec:
      containers:
        - name: api
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          command: ["server"]
          ports:
            - name: http
              containerPort: 8080
          env:
            {{- include "photos.env" . | nindent 12 }}
            - name: BIND_ADDR
              value: "0.0.0.0:8080"
          envFrom:
            - secretRef:
                name: {{ include "photos.secretName" . }}
          readinessProbe:
            httpGet:
              path: /api/health
              port: http
            initialDelaySeconds: 3
          livenessProbe:
            httpGet:
              path: /api/health
              port: http
            initialDelaySeconds: 10
          resources:
            {{- toYaml .Values.api.resources | nindent 12 }}
