apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    k8s-app: kubeedge
    kubeedge: cloudcore
  name: cloudcore
  namespace: kubeedge
spec:
  replicas: 2
  selector:
    matchLabels:
      k8s-app: kubeedge
      kubeedge: cloudcore
  template:
    metadata:
      labels:
        k8s-app: kubeedge
        kubeedge: cloudcore
    spec:
      hostNetwork: true
      readinessGates:
        - conditionType: "kubeedge.io/CloudCoreIsLeader"
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: node-role.kubernetes.io/edge
                    operator: DoesNotExist
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchExpressions:
                  - key: kubeedge
                    operator: In
                    values:
                      - cloudcore
              topologyKey: kubernetes.io/hostname
      containers:
        - name: cloudcore
          image: kubeedge/cloudcore:v1.3.0
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 10000
              name: cloudhub
              protocol: TCP
          resources:
            limits:
              cpu: 200m
              memory: 1Gi
            requests:
              cpu: 100m
              memory: 512Mi
          volumeMounts:
            - name: conf
              mountPath: /etc/kubeedge/config
            - name: certs
              mountPath: /etc/kubeedge
          env:
            - name: CLOUDCORE_POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: CLOUDCORE_POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
      restartPolicy: Always
      serviceAccount: cloudcore
      serviceAccountName: cloudcore
      volumes:
        - name: conf
          configMap:
            name: cloudcore
        - name: certs
          secret:
            secretName: cloudcore
            items:
              - key: edge.crt
                path: certs/edge.crt
              - key: edge.key
                path: certs/edge.key
              - key: rootCA.crt
                path: ca/rootCA.crt
