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.
Settings in the YAML file are synchronized with those on the console. You can edit the YAML file on the console to create a workload. For example:
When you click Create YAML on the right of the console, do not create multiple YAML files in the YAML definition pane displayed. You need to create them one by one. Otherwise, an error will be reported during the creation.
Parameter |
Description |
---|---|
* Workload Name |
Name of the workload to be created. The name must be unique. Enter 4 to 63 characters starting with a letter and ending with a letter or digit. Only lowercase letters, digits, and hyphens (-) are allowed. |
* Cluster Name |
Cluster to which the workload belongs. |
* Namespace |
In a single cluster, data in different namespaces is isolated from each other. This enables applications to share the services of the same cluster without interfering each other. If no namespace is set, the default namespace is used. |
* Instances |
Number of pods in the workload. A workload can have one or more pods. You can set the number of pods. The default value is 2 and can be set to 1. Each workload pod consists of the same containers. Configuring multiple pods for a workload ensures that the workload can still run properly even if a pod is faulty. If only one pod is used, a node or pod exception may cause service exceptions. |
* Container runtime |
Select a container runtime, which cannot be changed after creation. This parameter is available only for CCE Turbo clusters.
For details about common containers and secure containers, see Secure Containers and Common Containers. |
Time Zone Synchronization |
If this parameter is enabled, the container and the node use the same time zone. NOTICE:
After time zone synchronization is enabled, disks of the hostPath type will be automatically added and listed in the Data Storage > Local Volume area. Do not modify or delete the disks. |
Description |
Description of the workload. |
A workload is an abstract model of a group of pods. One pod can encapsulate one or more containers. You can click Add Container in the upper right corner to add multiple container images and set them separately.
Parameter |
Description |
---|---|
Image Name |
Name of the image. You can click Change Image to update it. |
*Image Version |
Select the image tag to be deployed. |
*Container Name |
Name of the container. You can modify it. |
Privileged Container |
Programs in a privileged container have certain privileges. If Privileged Container is On, the container is granted superuser permissions. For example, privileged containers can manipulate network devices on the host machine and modify kernel parameters. |
Container Resources |
CPU
Memory
For more information about Request and Limit, see Setting Container Specifications. GPU: configurable only when the cluster contains GPU nodes. It indicates the percentage of GPU resources reserved for a container. Select Use and set the percentage. For example, if this parameter is set to 10%, the container is allowed to use 10% of GPU resources. If you do not select Use or set this parameter to 0, no GPU resources can be used. GPU/Graphics Card: The workload's pods will be scheduled to the node with the specified GPU. If Any GPU type is selected, the container uses a random GPU in the node. If you select a specific GPU, the container uses this GPU accordingly. |
To edit an environment variable that has been set, click Edit. To delete an environment variable that has been set, click Delete.
Currently, cloud storage cannot be mounted to secure (Kata) containers in a CCE Turbo cluster.
Enter the user ID to set container permissions and prevent systems and other containers from being affected.
If your workload will be reachable to other workloads or public networks, add a Service to define the workload access type.
The workload access type determines the network attributes of the workload. Workloads with different access types can provide different network capabilities. For details, see Overview.
If the workload is in the Running state, it has been successfully created.
Workload status is not updated in real time. Click in the upper right corner or press F5 to refresh the page.
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 3.
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