---
kind: DaemonSet
apiVersion: apps/v1
metadata:
  name: kube-flannel
  namespace: kube-system
  labels:
    app.kubernetes.io/name: flannel
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: flannel
  updateStrategy:
    # Shouldn't be a problem with RollingUpdate, but might as well have this controlled.
    type: OnDelete
  template:
    metadata:
      labels:
        app.kubernetes.io/name: flannel
    spec:
      hostNetwork: true
      tolerations:
        - operator: Exists
          effect: NoSchedule
      serviceAccountName: flannel
      initContainers:
        - name: install-cni
          image: 'quay.io/coreos/flannel:v0.10.0-amd64'
          command:
            - cp
          args:
            - -f
            - /etc/kube-flannel/cni-conf.json
            - /etc/cni/net.d/10-flannel.conflist
          volumeMounts:
            - name: cni
              mountPath: /etc/cni/net.d
            - name: flannel-config
              mountPath: /etc/kube-flannel/
      containers:
        - name: kube-flannel
          image: 'quay.io/coreos/flannel:v0.10.0-amd64'
          command:
            - /opt/bin/flanneld
          args:
            - --ip-masq
            - --kube-subnet-mgr
          resources:
            requests:
              cpu: '100m'
              memory: '50Mi'
            limits:
              cpu: '100m'
              memory: '50Mi'
          securityContext:
            privileged: true
          env:
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          volumeMounts:
            - name: run
              mountPath: /run
            - name: flannel-config
              mountPath: /etc/kube-flannel/
      volumes:
        - name: run
          hostPath:
            path: /run
        - name: cni
          hostPath:
            path: /etc/cni/net.d
        - name: flannel-config
          configMap:
            name: flannel-config
