apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: sdn-controller
  namespace: openshift-sdn
  annotations:
    kubernetes.io/description: |
      This deployment runs the openshift SDN networking controller.
    release.openshift.io/version: "{{.ReleaseVersion}}"
  labels:
    app: sdn-controller
spec:
  selector:
    matchLabels:
      app: sdn-controller
  template:
    metadata:
      labels:
        app: sdn-controller
    spec:
      containers:
      - name: sdn-controller
        image: {{.SDNImage}}
        command:
        - /bin/bash
        - -c
        - |
          if [[ -f /env/_master ]]; then
            set -o allexport
            source /env/_master
            set +o allexport
          fi

          exec openshift-sdn-controller --v=${OPENSHIFT_SDN_LOG_LEVEL:-2}
        resources:
          requests:
            cpu: 10m
            memory: 50Mi
        env:
        # point sdn-controller to the internal apiserver load balancer
        - name: KUBERNETES_SERVICE_PORT
          value: "{{.KUBERNETES_SERVICE_PORT}}"
        - name: KUBERNETES_SERVICE_HOST
          value: "{{.KUBERNETES_SERVICE_HOST}}"
        terminationMessagePolicy: FallbackToLogsOnError
        volumeMounts:
        - mountPath: /env
          name: env-overrides
      hostNetwork: true
      nodeSelector:
        node-role.kubernetes.io/master: ""
      priorityClassName: "system-cluster-critical"
      restartPolicy: Always
      serviceAccountName: sdn-controller
      securityContext:
        runAsNonRoot: true
        runAsUser: 65534
      tolerations:
      - key: "node-role.kubernetes.io/master"
        operator: "Exists"
        effect: "NoSchedule"
      - key: "node.kubernetes.io/not-ready"
        operator: "Exists"
        effect: "NoSchedule"
      volumes:
      - name: env-overrides
        configMap:
          name: env-overrides
          optional: true
