apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "cert-manager-webhook-regru.fullname" . }}
  namespace: {{ .Release.Namespace }}
  labels:
    app: {{ include "cert-manager-webhook-regru.name" . }}
    chart: {{ include "cert-manager-webhook-regru.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  replicas: 1
  selector:
    matchLabels:
      app: {{ include "cert-manager-webhook-regru.name" . }}
      release: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app: {{ include "cert-manager-webhook-regru.name" . }}
        release: {{ .Release.Name }}
    spec:
      serviceAccountName: {{ include "cert-manager-webhook-regru.fullname" . }}
      containers:
        - name: {{ .Chart.Name }}
          image: {{ .Values.issuer.image }}
          args:
            - --secure-port=8443
            - --tls-cert-file=/tls/tls.crt
            - --tls-private-key-file=/tls/tls.key
          env:
            - name: GROUP_NAME
              value: {{ .Values.groupName.name }}
            - name: REGRU_USERNAME
              value: {{ .Values.issuer.user }}
            - name: REGRU_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: regru-password
                  key: REGRU_PASSWORD
          ports:
            - name: https
              containerPort: 8443
              protocol: TCP
          livenessProbe:
            httpGet:
              scheme: HTTPS
              path: /healthz
              port: https
          readinessProbe:
            httpGet:
              scheme: HTTPS
              path: /healthz
              port: https
          volumeMounts:
            - name: certs
              mountPath: /tls
              readOnly: true
          resources:
            requests:
              cpu: {{ .Values.resources.requests.cpu }}
              memory: {{ .Values.resources.requests.memory }}
            limits:
              memory: {{ .Values.resources.limits.memory }}
      volumes:
        - name: certs
          secret:
            secretName: {{ include "cert-manager-webhook-regru.servingCertificate" . }}
    {{- with .Values.nodeSelector }}
      nodeSelector:
{{ toYaml . | indent 8 }}
    {{- end }}
    {{- with .Values.affinity }}
      affinity:
{{ toYaml . | indent 8 }}
    {{- end }}
    {{- with .Values.tolerations }}
      tolerations:
{{ toYaml . | indent 8 }}
    {{- end }}
