#apiVersion: v1
#kind: Namespace
#metadata:
#  labels:
#    control-plane: controller-manager
#  name: system
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: controller-manager
  namespace: system
  labels:
    control-plane: controller-manager
spec:
  selector:
    matchLabels:
      control-plane: controller-manager
  replicas: 1
  template:
    metadata:
      labels:
        control-plane: controller-manager
    spec:
# TODO: Used only during testing to speed up development. Pod come up faster on SV master VM rather than as Pod VM.
#      hostNetwork: true
#      securityContext:
#        runAsNonRoot: true
      containers:
      - command:
        - /manager
        args:
# TODO: disabling leader election for now. Take care of deleting the existing replica during updates.
#        - --leader-elect
        - --metrics-bind-address=:18080
        - --health-probe-bind-address=:18081
        image: controller:latest
        name: manager
        securityContext:
          allowPrivilegeEscalation: true
        livenessProbe:
          httpGet:
            path: /healthz
            port: 18081
          initialDelaySeconds: 15
          periodSeconds: 20
        readinessProbe:
          httpGet:
            path: /readyz
            port: 18081
          initialDelaySeconds: 5
          periodSeconds: 10
        resources:
          limits:
            cpu: 1000m
            memory: 1Gi
          requests:
            cpu: 1000m
            memory: 512Mi
      serviceAccountName: controller-manager
      terminationGracePeriodSeconds: 10
# TODO: Remove this when the operator needs to be run in workload namespace.
#      tolerations:
#        - effect: NoSchedule
#          key: node-role.kubernetes.io/master
#          operator: Exists
#        - effect: NoSchedule
#          key: kubeadmNode
#          operator: Equal
#          value: master
#      nodeSelector:
#        node-role.kubernetes.io/master: ""