{{if .AdmissionController}}
kind: DaemonSet
apiVersion: apps/v1
metadata:
  name: kuryr-dns-admission-controller
  namespace: openshift-kuryr
  labels:
    app: kuryr-dns-admission-controller
  annotations:
    kubernetes.io/description: |
      This daemon set launches the admisson controller that will force TPC DNS resolution for pods on each node.
    release.openshift.io/version: "{{.ReleaseVersion}}"
spec:
  selector:
    matchLabels:
      app: kuryr-dns-admission-controller
  updateStrategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: kuryr-dns-admission-controller
        namespace: openshift-kuryr
        component: network
        type: infra
        openshift.io/component: network
    spec:
      serviceAccountName: kuryr
      containers:
      - name: kuryr-dns-admission-controller
        image: {{ .ControllerImage }}
        command:
        - kuryr-dns-webhook
        args:
        - --bind-address=0.0.0.0
        - --port=6443
        - --tls-private-key-file=/etc/webhook/tls.key
        - --tls-cert-file=/etc/webhook/tls.crt
        - --ns=openshift-insights
        - --ns=openshift-etcd-operator
        - --ns=openshift-authentication-operator
        volumeMounts:
        - name: webhook-certs
          mountPath: /etc/webhook
          readOnly: True
        imagePullPolicy: IfNotPresent
        resources:
          requests:
            cpu: 10m
      priorityClassName: "system-cluster-critical"
      restartPolicy: Always
      nodeSelector:
        node-role.kubernetes.io/master: ""
      volumes:
      - name: webhook-certs
        secret:
          secretName: {{.WebhookSecret}}
      tolerations:
      - key: "node-role.kubernetes.io/master"
        operator: Exists
        effect: NoSchedule
      - key: "node.kubernetes.io/not-ready"
        operator: Exists
        effect: NoSchedule
{{- end}}
