{{- if .Values.identity.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "entkube.fullname" . }}-identity
  labels:
    {{- include "entkube.labels" . | nindent 4 }}
    app.kubernetes.io/component: identity
spec:
  replicas: {{ .Values.identity.replicaCount }}
  selector:
    matchLabels:
      {{- include "entkube.selectorLabels" . | nindent 6 }}
      app.kubernetes.io/component: identity
  template:
    metadata:
      labels:
        {{- include "entkube.selectorLabels" . | nindent 8 }}
        app.kubernetes.io/component: identity
    spec:
      {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      serviceAccountName: {{ include "entkube.serviceAccountName" . }}
      containers:
        - name: identity
          image: {{ include "entkube.image" (dict "root" . "component" .Values.identity) }}
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          ports:
            - name: http
              containerPort: {{ .Values.identity.port }}
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /health
              port: http
            initialDelaySeconds: 10
            periodSeconds: 30
          readinessProbe:
            httpGet:
              path: /health/ready
              port: http
            initialDelaySeconds: 5
            periodSeconds: 10
          resources:
            {{- toYaml .Values.identity.resources | nindent 12 }}
          env:
            - name: ASPNETCORE_URLS
              value: "http://+:{{ .Values.identity.port }}"
{{- end }}
