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.
Before creating a DaemonSet, you must have an available cluster. For details on how to create a cluster, see Creating a CCE Standard/Turbo Cluster.
Parameter |
Description |
---|---|
Container Name |
Name the container. |
Pull Policy |
Image update or pull policy. If you select Always, the image is pulled from the image repository each time. If you do not select Always, the existing image of the node is preferentially used. If the image does not exist, the image is pulled from the image repository. |
Image Name |
Click Select Image and select the image used by the container. To use a third-party image, see Using Third-Party Images. |
Image Tag |
Select the image tag to be deployed. |
CPU Quota |
If Request and Limit are not specified, the quota is not limited. For more information and suggestions about Request and Limit, see Configuring Container Specifications. |
Memory Quota |
If Request and Limit are not specified, the quota is not limited. For more information and suggestions about Request and Limit, see Configuring Container Specifications. |
(Optional) GPU Quota |
Configurable only when the cluster contains GPU nodes and the CCE AI Suite (NVIDIA GPU) add-on is installed.
For details about how to use GPUs in the cluster, see Default GPU Scheduling in Kubernetes. |
(Optional) Privileged Container |
Programs in a privileged container have certain privileges. If Privileged Container is enabled, the container is assigned privileges. For example, privileged containers can manipulate network devices on the host machine and modify kernel parameters. |
(Optional) Init Container |
Whether to use the container as an init container. An init container does not support health check. An init container is a special container that runs before other app containers in a pod are started. Each pod can contain multiple containers. In addition, a pod can contain one or more init containers. Application containers in a pod are started and run only after the running of all init containers completes. For details, see Init Containers. |
To disable the standard output of the current workload, add the annotation kubernetes.AOM.log.stdout: [] in Labels and Annotations. For details about how to use this annotation, see Table 1.
(Optional) Service Settings
A Service provides external access for pods. With a static IP address, a Service forwards access traffic to pods and automatically balances load for these pods.
You can also create a Service after creating a workload. For details about Services of different types, see 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. 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