apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: opennet
  namespace: kube-system
  labels:
    tier: node
    app: opennet
spec:
  selector:
    matchLabels:
      name: opennet
  updateStrategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        tier: node
        app: opennet
        name: opennet
    spec:
      tolerations:
        - operator: Exists
          effect: NoSchedule
      containers:
        - name: opennet
          image: ankrnetwork/opennet:latest
          imagePullPolicy: IfNotPresent
          args:
            - |
              #step 1: remove opennet.sock
              rm -f /tmp/opennet.sock

              #step 2: copy the opennet execute program to the default cni path /opt/cni/bin
              rm /host/opt/cni/bin/opennet
              cp /root/opennet /host/opt/cni/bin

              #step 3: run the daemon service program
              /root/components -debug -endpoints "https://192.168.0.38:2379,https://192.168.0.39:2379,https://192.168.0.40:2379"
          command:
            - /bin/sh
            - -c
          resources:
            limits:
              cpu: "100m"
              memory: "50Mi"
          securityContext:
            privileged: true
          volumeMounts:
            - name: cnibin
              mountPath: /host/opt/cni/bin
            - name: communication-path
              mountPath: /tmp
            - mountPath: /ssl
              name: secret-etcd-certs
              readOnly: true
      volumes:
        - name: cnibin
          hostPath:
            path: /opt/cni/bin
        - name: communication-path
          hostPath:
            path: /tmp
        - name: secret-etcd-certs
          secret:
            secretName: etcd-certs
