
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "nemo-kubernetes-operator.fullname" . }}-controller-manager
  labels:
    app.kubernetes.io/component: manager
    app.kubernetes.io/created-by: nemo-kubernetes-operator
    app.kubernetes.io/part-of: nemo-kubernetes-operator
    control-plane: controller-manager
  {{- include "nemo-kubernetes-operator.labels" . | nindent 4 }}
spec:
  replicas: {{ .Values.controllerManager.replicas }}
  selector:
    matchLabels:
      control-plane: controller-manager
    {{- include "nemo-kubernetes-operator.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      labels:
        control-plane: controller-manager
      {{- include "nemo-kubernetes-operator.selectorLabels" . | nindent 8 }}
      annotations:
        kubectl.kubernetes.io/default-container: manager
    spec:
      containers:
      - args: {{- toYaml .Values.controllerManager.kubeRbacProxy.args | nindent
          8 }}
        env:
        - name: KUBERNETES_CLUSTER_DOMAIN
          value: {{ quote .Values.kubernetesClusterDomain }}
        image: "{{ .Values.controllerManager.kubeRbacProxy.image.repository }}:{{
          .Values.controllerManager.kubeRbacProxy.image.tag | default .Chart.AppVersion
          }}"
        name: kube-rbac-proxy
        ports:
        - containerPort: 8443
          name: https
          protocol: TCP
        resources: {{- toYaml .Values.controllerManager.kubeRbacProxy.resources
          | nindent 10 }}
        securityContext: {{- toYaml .Values.controllerManager.kubeRbacProxy.containerSecurityContext
          | nindent 10 }}
      - args:
        {{- range .Values.controllerManager.manager.args }}
          - {{ . }}
        {{- end }}
        {{- if .Values.controllerManager.manager.scheduler }}
          - --scheduler={{ .Values.controllerManager.manager.scheduler }}
        {{- end }}
        {{- if .Values.restrictedNamespace }}
          - --restrictedNamespace={{ .Values.restrictedNamespace }}
        {{- end }}
        command:
        - /manager
        env:
        - name: KUBERNETES_CLUSTER_DOMAIN
          value: {{ quote .Values.kubernetesClusterDomain }}
        {{ include "nemo-common.env" . | nindent 8 | trim }}
        image: {{ .Values.controllerManager.manager.image.repository }}:{{ .Values.controllerManager.manager.image.tag
          | default .Chart.AppVersion }}
        livenessProbe:
          httpGet:
            path: /healthz
            port: 8081
          initialDelaySeconds: 15
          periodSeconds: 20
        name: manager
        readinessProbe:
          httpGet:
            path: /readyz
            port: 8081
          initialDelaySeconds: 5
          periodSeconds: 10
        resources: {{- toYaml .Values.controllerManager.manager.resources | nindent
          10 }}
        securityContext: {{- toYaml .Values.controllerManager.manager.containerSecurityContext
          | nindent 10 }}
      imagePullSecrets:
        {{ include "nemo-common.imagepullsecrets" . | nindent 8 | trim }}
      securityContext:
        runAsNonRoot: true
      serviceAccountName: {{ include "nemo-kubernetes-operator.fullname" . }}-controller-manager
      terminationGracePeriodSeconds: 10
