Deployments are workloads (for example, Nginx) that do not store any data or status. You can create Deployments on the CCE console or by running kubectl commands.
If a pod has multiple containers, ensure that the ports used by the containers do not conflict with each other. Otherwise, creating the Deployment will fail.
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. |
If the workload contains more than one pod, EVS volumes cannot be mounted.
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-deployment.yaml
The following is an example YAML file. For more information about Deployments, see Kubernetes documentation.
apiVersion: apps/v1 kind: Deployment metadata: name: nginx spec: replicas: 1 selector: matchLabels: app: nginx strategy: type: RollingUpdate template: metadata: labels: app: nginx spec: containers: - image: nginx # If you use an image in My Images, obtain the image path from SWR. imagePullPolicy: Always name: nginx imagePullSecrets: - name: default-secret
For details about these parameters, see Table 1.
Parameter |
Description |
Mandatory/Optional |
---|---|---|
apiVersion |
API version. NOTE:
Set this parameter based on the cluster version.
|
Mandatory |
kind |
Type of a created object. |
Mandatory |
metadata |
Metadata of a resource object. |
Mandatory |
name |
Name of the Deployment. |
Mandatory |
spec |
Detailed description of the Deployment. |
Mandatory |
replicas |
Number of pods. |
Mandatory |
selector |
Determines container pods that can be managed by the Deployment. |
Mandatory |
strategy |
Upgrade mode. Possible values:
By default, rolling update is used. |
Optional |
template |
Detailed description of a created container pod. |
Mandatory |
metadata |
Metadata. |
Mandatory |
labels |
metadata.labels: Container labels. |
Optional |
spec: containers |
|
Mandatory |
imagePullSecrets |
Name of the secret used during image pulling. If a private image is used, this parameter is mandatory.
|
Optional |
kubectl create -f nginx-deployment.yaml
If the following information is displayed, the Deployment is being created.
deployment "nginx" created
kubectl get deployment
If the following information is displayed, the Deployment is running.
NAME READY UP-TO-DATE AVAILABLE AGE nginx 1/1 1 1 4m5s
Parameter description