apiVersion: apps/v1
kind: Deployment
metadata:
  name: connector
  namespace: fabedge
spec:
  replicas: 1
  selector:
    matchLabels:
      app: connector
  strategy:
      type: Recreate
  template:
    metadata:
      labels:
        app: connector
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: node-role.kubernetes.io/connector
                    operator: Exists
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
                - key: app
                  operator: In
                  values:
                  - connector
            topologyKey: kubernetes.io/hostname
      hostNetwork: true
      containers:
        - name: strongswan
          image: fabedge/strongswan
          imagePullPolicy: IfNotPresent
          readinessProbe:
            exec:
              command:
              - /usr/sbin/swanctl
              - --version
            initialDelaySeconds: 15
            periodSeconds: 10
          securityContext:
            capabilities:
              add: ["NET_ADMIN", "SYS_MODULE"]
          volumeMounts:
            - name: var-run
              mountPath: /var/run/
            - name: ipsec-d
              mountPath: /etc/ipsec.d/
              readOnly: true
            - name: ipsec-secrets
              mountPath: /etc/ipsec.secrets
              subPath: ipsec.secrets
              readOnly: true
        - name: connector
          securityContext:
            capabilities:
              add: ["NET_ADMIN"]
          image: fabedge/connector
          imagePullPolicy: IfNotPresent
          args:
            - --cni-type=calico
            - --sync-period=1m
            - -v=5
          volumeMounts:
            - name: var-run
              mountPath: /var/run/
            - name: connector-config
              mountPath: /etc/fabedge/
            - name: ipsec-d
              mountPath: /etc/ipsec.d/
              readOnly: true
      volumes:
        - name: var-run
          emptyDir: {}
        - name: connector-config
          configMap:
            name: connector-config
        - name: ipsec-d
          secret:
            items:
              - key: ca.crt
                path: cacerts/ca.crt
              - key: tls.crt
                path: certs/tls.crt
              - key: tls.key
                path: private/tls.key
            secretName: cloud-connector
        - name: ipsec-secrets
          secret:
            items:
              - key: ipsec.secrets
                path: ipsec.secrets
            secretName: cloud-connector