apiVersion: apps/v1
kind: Deployment
metadata:
  name: controller
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: imperator
  replicas: 1
  template:
    metadata:
      labels:
        app.kubernetes.io/name: imperator
    spec:
      securityContext:
        runAsNonRoot: true
      containers:
      - name: imperator-controller
        command:
          - /imperator-controller
        args:
          - --leader-elect
        image: controller:latest
        imagePullPolicy: Always
        env:
          - name: IMPERATOR_CORE_NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
        securityContext:
          allowPrivilegeEscalation: false
        ports:
          - containerPort: 9443
            name: webhook-server
            protocol: TCP
        livenessProbe:
          httpGet:
            path: /healthz
            port: 8081
          initialDelaySeconds: 15
          periodSeconds: 20
        readinessProbe:
          httpGet:
            path: /readyz
            port: 8081
          initialDelaySeconds: 5
          periodSeconds: 10
        resources:
          limits:
            cpu: 200m
            memory: 100Mi
          requests:
            cpu: 100m
            memory: 20Mi
        volumeMounts:
          - mountPath: /tmp/k8s-webhook-server/serving-certs
            name: cert
            readOnly: true
      - name: kube-rbac-proxy
        image: gcr.io/kubebuilder/kube-rbac-proxy:v0.8.0
        args:
          - "--secure-listen-address=0.0.0.0:8443"
          - "--upstream=http://127.0.0.1:8080/"
          - "--logtostderr=true"
          - "--v=10"
        ports:
          - containerPort: 8443
            protocol: TCP
            name: https
      volumes:
        - name: cert
          secret:
            defaultMode: 420
            secretName: webhook-server-cert
      serviceAccountName: imperator-controller
      terminationGracePeriodSeconds: 10
