apiVersion: apps/v1
kind: Deployment
metadata:
  name: porter-manager
  labels:
    control-plane: porter-manager
    app: porter-manager
spec:
  selector:
    matchLabels:
      control-plane: porter-manager
      app: porter-manager
  strategy:
    rollingUpdate:
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        control-plane: porter-manager
        app: porter-manager
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchExpressions:
                  - key: app
                    operator: In
                    values:
                      - porter-manager
              topologyKey: "kubernetes.io/hostname"
      tolerations:
        - key: "CriticalAddonsOnly"
          operator: "Exists"
        # cloud controller manages should be able to run on masters
        - key: "node-role.kubernetes.io/master"
          effect: NoSchedule
      nodeSelector:
        kubernetes.io/os: linux
      containers:
        - command:
            - porter-manager
          args:
            - --api-hosts=:50051
            - --webhook-port=443
          image: controller:latest
          imagePullPolicy: IfNotPresent
          name: porter-manager
          readinessProbe:
            exec:
              command:
                - sh
                - -c
                - |
                  gobgp -p 50051 global
            failureThreshold: 3
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 1
          securityContext:
            capabilities:
              add: [ "NET_ADMIN", "SYS_TIME" ]
          env:
            - name: PORTER_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: NODE_NAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
          ports:
            - containerPort: 443
              name: webhook
              protocol: TCP
          volumeMounts:
            - name: webhook-cert
              mountPath: /tmp/k8s-webhook-server/serving-certs/
              readOnly: true
      terminationGracePeriodSeconds: 10
      hostNetwork: true
      volumes:
        - name: webhook-cert
          secret:
            secretName: porter-admission
            items:
              - key: key
                path: tls.key
              - key: cert
                path: tls.crt

