apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "namespace-annotation-webhook.fullname" . }}
  labels:
    app.kubernetes.io/name: {{ include "namespace-annotation-webhook.name" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
spec:
  replicas: 2
  selector:
    matchLabels:
      app.kubernetes.io/name: {{ include "namespace-annotation-webhook.name" . }}
      app.kubernetes.io/instance: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app.kubernetes.io/name: {{ include "namespace-annotation-webhook.name" . }}
        app.kubernetes.io/instance: {{ .Release.Name }}
    spec:
      serviceAccountName: {{ include "namespace-annotation-webhook.fullname" . }}
      securityContext:
        runAsNonRoot: true
        runAsUser: 65534
        fsGroup: 65534
      containers:
        - name: {{ include "namespace-annotation-webhook.name" . }}
          image: "{{ .Values.image }}"
          imagePullPolicy: IfNotPresent
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop:
                - ALL
          resources:
            requests:
              cpu: 10m
              memory: 64Mi
            limits:
              cpu: 100m
              memory: 128Mi
          ports:
            - containerPort: 8443
              name: https
          volumeMounts:
            - name: webhook-certs
              mountPath: /etc/webhook/certs
              readOnly: true
          args:
            - "--tls-cert-file=/etc/webhook/certs/tls.crt"
            - "--tls-key-file=/etc/webhook/certs/tls.key"
            - "--port-security={{ .Values.portSecurity }}"
            - "--routes={{ .Values.routes }}"
      tolerations:
      - effect: NoSchedule
        operator: Exists
      - effect: NoExecute
        operator: Exists
      - key: CriticalAddonsOnly
        operator: Exists
      volumes:
        - name: webhook-certs
          secret:
            secretName: {{ include "namespace-annotation-webhook.fullname" . }}-tls
            defaultMode: 0400
