apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "docker-registry-ui.fullname" . }}
  labels:
{{ include "docker-registry-ui.labels" . | indent 4 }}
spec:
  replicas: {{ .Values.ui.replicaCount }}
  selector:
    matchLabels:
{{ include "docker-registry-ui.matchLabels" . | indent 6 }}
  template:
    metadata:
      labels:
{{ include "docker-registry-ui.matchLabels" . | indent 8 }}
    spec:
    {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
    {{- end }}
      containers:
        - name: registry-ui
          image: "{{ .Values.ui.image.registry }}/{{ .Values.ui.image.repository }}:{{ .Values.ui.image.tag }}"
          imagePullPolicy: {{ .Values.ui.image.pullPolicy }}
          env:
            - name: REGISTRY_TITLE
              value: {{ .Values.ui.title| quote }}
            - name: DELETE_IMAGES
              value: {{ .Values.ui.delete_images| quote }}
            - name: {{ include "docker-registry-ui.url-name" . }}
              value: {{ include "docker-registry-ui.url-value" . | quote }}
            - name: PULL_URL
              value: {{ include "docker-registry-ui.pull" . | quote }}
          ports:
            - name: http
              containerPort: 80
              protocol: TCP
{{ include "docker-registry-ui.probes" . | indent 10 }}
          resources:
            {{- toYaml .Values.ui.resources | nindent 12 }}
      {{- with .Values.ui.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
    {{- with .Values.ui.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
    {{- end }}
    {{- with .Values.ui.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
    {{- end }}
