CCE provides deployment and management capabilities for multiple types of containers and supports features of container workloads, including creation, configuration, monitoring, scaling, upgrade, uninstall, service discovery, and load balancing.
DaemonSet ensures that only one pod runs on all or some nodes. When a node is added to a cluster, a new pod is also added for the node. When a node is removed from a cluster, the pod is also reclaimed. If a DaemonSet is deleted, all pods created by it will be deleted.
The typical application scenarios of a DaemonSet are as follows:
You can deploy a DaemonSet for each type of daemons on all nodes, or deploy multiple DaemonSets for the same type of daemons. In the second case, DaemonSets have different flags and different requirements on memory and CPU for different hardware types.
You must have one cluster available before creating a DaemonSet. For details on how to create a cluster, see Creating a CCE Cluster.
If the workload contains more than one pod, EVS volumes cannot be mounted.
Service Settings
A Service is used for pod access. With a fixed IP address, a Service forwards access traffic to pods and performs load balancing for these pods.
You can also create a Service after creating a workload. For details about the Service, see Service Overview.
The following procedure uses Nginx as an example to describe how to create a workload using kubectl.
vi nginx-daemonset.yaml
The content of the description file is as follows: The following provides an example. For more information on DaemonSets, see Kubernetes documents.
apiVersion: apps/v1 kind: DaemonSet metadata: name: nginx-daemonset labels: app: nginx-daemonset spec: selector: matchLabels: app: nginx-daemonset template: metadata: labels: app: nginx-daemonset spec: nodeSelector: # Node selection. A pod is created on a node only when the node meets daemon=need. daemon: need containers: - name: nginx-daemonset image: nginx:alpine resources: limits: cpu: 250m memory: 512Mi requests: cpu: 250m memory: 512Mi imagePullSecrets: - name: default-secret
The replicas parameter used in defining a Deployment or StatefulSet does not exist in the above configuration for a DaemonSet, because each node has only one replica. It is fixed.
The nodeSelector in the preceding pod template specifies that a pod is created only on the nodes that meet daemon=need, as shown in the following figure. If you want to create a pod on each node, delete the label.
kubectl create -f nginx-daemonset.yaml
If the following information is displayed, the DaemonSet is being created.
daemonset.apps/nginx-daemonset created
kubectl get ds
$ kubectl get ds NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE nginx-daemonset 1 1 0 1 0 daemon=need 116s