---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: multi-networkpolicy
rules:
  - apiGroups: ["k8s.cni.cncf.io"]
    resources:
      - '*'
    verbs:
      - '*'
  - apiGroups:
      - ""
    resources:
      - pods
      - namespaces
    verbs:
      - list
      - watch
      - get
  # Watch for changes to Kubernetes NetworkPolicies.
  - apiGroups: ["networking.k8s.io"]
    resources:
      - networkpolicies
    verbs:
      - watch
      - list
  - apiGroups:
      - ""
      - events.k8s.io
    resources:
      - events
    verbs:
      - create
      - patch
      - update
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: multi-networkpolicy
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: multi-networkpolicy
subjects:
- kind: ServiceAccount
  name: multi-networkpolicy
  namespace: kube-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: multi-networkpolicy
  namespace: kube-system
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: multi-networkpolicy-ds-amd64
  namespace: kube-system
  labels:
    tier: node
    app: multi-networkpolicy
    name: multi-networkpolicy
spec:
  selector:
    matchLabels:
      name: multi-networkpolicy
  updateStrategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        tier: node
        app: multi-networkpolicy
        name: multi-networkpolicy
    spec:
      hostNetwork: true
      nodeSelector:
        kubernetes.io/arch: amd64
      tolerations:
      - operator: Exists
        effect: NoSchedule
      serviceAccountName: multi-networkpolicy
      containers:
      - name: multi-networkpolicy
        # crio support requires multus:latest for now. support 3.3 or later.
        image: docker.io/nfvpe/multi-networkpolicy-iptables:snapshot-amd64
        imagePullPolicy: Always
        command: ["/usr/bin/multi-networkpolicy-iptables"]
        args:
        - "--host-prefix=/host"
        # uncomment this if runtime is docker
        # - "--container-runtime=docker"
        - "--container-runtime-endpoint=/run/containerd/containerd.sock"
        resources:
          requests:
            cpu: "100m"
            memory: "50Mi"
          limits:
            cpu: "100m"
            memory: "50Mi"
        securityContext:
          privileged: true
          capabilities:
            add: ["SYS_ADMIN", "SYS_NET_ADMIN"]
        volumeMounts:
        - name: host
          mountPath: /host
      volumes:
        - name: host
          hostPath:
            path: /
