---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  labels:
    app: network-resources-injector
  name: network-resources-injector
  namespace: {{.Namespace}}
  annotations:
    kubernetes.io/description: |
      This daemon set launches the network resource injector component on master nodes.
    release.openshift.io/version: "{{.ReleaseVersion}}"
spec:
  selector:
    matchLabels:
      app: network-resources-injector
  updateStrategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 33%
  template:
    metadata:
      annotations:
        target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
      labels:
        app: network-resources-injector
        component: network
        type: infra
        openshift.io/component: network
    spec:
      serviceAccountName: network-resources-injector-sa
      priorityClassName: "system-cluster-critical"
      nodeSelector:
        beta.kubernetes.io/os: linux
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: node-role.kubernetes.io/master
                operator: Exists
      tolerations:
      - key: "node-role.kubernetes.io/master"
        operator: Exists
        effect: NoSchedule
      - key: "node.kubernetes.io/not-ready"
        operator: Exists
        effect: NoSchedule
      containers:
      - name: webhook-server
        image: {{.NetworkResourcesInjectorImage}}
        command:
        - webhook
        args:
        - -bind-address=0.0.0.0
        - -port=6443
        - -tls-private-key-file=/etc/tls/tls.key
        - -tls-cert-file=/etc/tls/tls.crt
        - -alsologtostderr=true
        - -insecure=true
        env:
        - name: NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        resources:
          requests:
            cpu: 10m
            memory: 50Mi
        volumeMounts:
        - mountPath: /etc/tls
          name: tls
      volumes:
      - name: tls
        secret:
          secretName: network-resources-injector-secret
