Creating a Workload
A workload is an abstract model of a group of pods in Kubernetes. Workloads defined in Kubernetes include Deployments, StatefulSets, and jobs.
Basic Concepts
- Deployments: Pods are completely independent of each other and functionally identical. They feature auto scaling and rolling upgrade. For example, Nginx and WordPress. For details on how to create a Deployment, see Creating a Deployment.
- StatefulSets: Pods are not completely independent of each other. They have stable persistent storage and network identifiers, and feature orderly deployment, scale-in, and deletion. For example, MySQL-HA and etcd. For details on how to create a StatefulSet, see Creating a StatefulSet.
Relationship Between Workloads and Containers
As shown in Figure 1, a workload controls one or more pods. A pod consists of one or more containers. Each container is created from a container image. Pods of Deployments are exactly the same.
Workload Lifecycle
| Status | Description |
|---|---|
| Running | All pods are running. |
| Unready | All pods are in the pending state. |
| Upgrading | After the upgrade operation is triggered, the workload is being upgraded. |
| Stopped | After the stop operation is triggered, the workload is stopped and the number of pods changes to 0. |
| Available | For a multi-pod Deployment, some pods are abnormal but at least one pod is available. |
| Deleting | After the delete operation is triggered, the workload is being deleted. |
Creating a Deployment
- (Optional) If you create a workload using My Images, first upload the image to SWR. For details about how to upload an image, see Image Management. If you create a workload from an open source image, you do not need to upload the image.
- Log in to the cluster console. In the navigation pane, choose Workloads > Deployments. On the page displayed, click Create Deployment.
- Set basic workload parameters as described in Table 2. The parameters marked with asterisks (*) are mandatory.
Table 2 Basic workload parameters Parameter
Description
*Name
Name of a workload, which must be unique.
*Cluster
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.
*Pods
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.
Description
Description of the workload.
- Click Next to add a container.
- Click Add Container and select the image to be deployed.
- My Images: Create a workload using an image in the HUAWEI CLOUD image repository. If no image is available, click push an image to push an image.
- If your image repository does not require authentication, set Secret Authentication to No, select the corresponding image, and then click OK.
- If your image repository requires authentication (using account and password), select the corresponding secret, and then click OK. If no secret is available, create a secret by following the procedure described in Creating a Secret.
- Open Source Images: Create a workload using an official image in the open source image repository.
- If your image repository does not require authentication, set Secret Authentication to No, select the corresponding image, and then click OK.
- If your image repository requires authentication (using account and password), select the corresponding secret, and then click OK. If no secret is available, create a secret by following the procedure described in Creating a Secret.
- Third-Party Images: Create a workload using an image from any third-party image repository (image repositories other than HUAWEI CLOUD SWR and open source image repository). Ensure that the node where the workload is running is accessible from public networks.
- If your image repository does not require authentication, set Secret Authentication to No, enter an image address, and then click OK.
- If your image repository requires authentication (using account and password), select the corresponding secret, enter an image address, and then click OK.
- My Images: Create a workload using an image in the HUAWEI CLOUD image repository. If no image is available, click push an image to push an image.
- Configure image parameters.
Table 3 Image parameters Parameter
Description
Image Name
Name of the image. You can click Change Image to select another image.
Image Tag
Tag of the image to be deployed. If you choose an image on the My Images or Open Source Images tab page, you must specify this parameter.
Container Name
Container name, which can be changed.
Container Specifications
Resource amount that users can apply for and the maximum amount of resources that are available to users. For details, see Setting Container Specifications.- Request: Minimum amount of resources required for running a container.
- Limit: If a container is overloaded, the system may be faulty. To avoid this situation, set the maximum limits for the container resource quotas to ensure that container resources do not exceed the limits.
- Configure container lifecycle, that is, set the commands that need to be executed in each phase during container management.
- Startup Command: Executed to start a container. For details, see Setting Container Startup Commands.
- Post-Start: Executed after a container runs successfully. For details, see Setting Container Lifecycle Parameters.
- Pre-Stop: Executed to delete logs or temporary files before a container is stopped. For details, see Setting Container Lifecycle Parameters.
- Set the health check function that checks whether containers and services are running properly. Two types of probes are provided: liveness probes and readiness probes. For details, see Setting Health Check for a Container.
- Liveness Probe: The probe restarts the workload when detecting that the workload pod is unhealthy.
- Readiness Probe: The probe sets the workload to the unready state when detecting that the workload pod is unhealthy. In this way, the service traffic will not be directed to the workload pod.
- Set environment variables. Environment variables can be added to a container. In general, environment variables are used to set parameters.
In the Environment Variables area, click Add Environment Variable.
- Set container permissions to protect the system and other containers from being affected.
Enter the user ID to set container permissions and prevent systems and other containers from being affected.
- Mount data storage to containers for persistent storage and high disk I/O. For details, see Federated PVCs.
After the workload is created, you can access the workload details page of the cluster console, click the Container Settings tab, and click Modify Container Settings to modify the container settings.
- Click Add Container and select the image to be deployed.
- Click Next. Then, click Create Service and set the workload access type.
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 Network Management.
- ClusterIP
A workload can be accessed from other workloads in the same cluster through a cluster-internal domain name. A cluster-internal domain name is in the format of <User-defined Service name>.<Namespace of the workload>.svc.cluster.local, for example, nginx.default.svc.cluster.local.
- NodePort
A workload can be accessed by other workloads in the same VPC using the IP address of a cluster node. The NodePort access type is applicable to the scenario in which other workloads in the same VPC in the cloud need to access the workload in the Kubernetes cluster.
- LoadBalancer
A workload can be accessed from a public network through a load balancer. LoadBalancer provides higher reliability than EIP-based NodePort because an EIP is no longer bound to a single node. The LoadBalancer access type is applicable to the scenario in which a Service exposed to public networks is required. The access address is in the format of <IP address of public network load balancer>:<access port>, for example, 10.117.117.117:80.
- ClusterIP
- Click Next and configure advanced settings.
- Upgrade Policy: In-place upgrade and Rolling upgrade are available.
- In-place upgrade: Old pods are deleted before new pods are created. Services will be interrupted during an in-place upgrade.
- Rolling upgrade: An old pod is gradually replaced with a new pod. During the upgrade, service traffic is evenly distributed to the old and new pods to ensure service continuity.
Maximum Number of Unavailable Pods: Maximum number of unavailable pods allowed in a rolling upgrade. If the number is equal to the total number of pods, services may be interrupted. Minimum number of alive pods = Total pods – Maximum number of unavailable pods
- Graceful Deletion: Set a time window (0–9,999s) for pre-stop commands to finish execution before a workload is deleted. The default value is 30s.
- Migration Policy: Set a time window for the system to schedule the workload pod to another available node when the node where the workload pod is running is unavailable. The default value is 300s.
- Scheduling Policies: You can combine static global scheduling policies or dynamic runtime scheduling policies as required. For details, see Scheduling Policy Overview.
- Pod Label: System-defined app labels added during workload creation cannot be modified. You can click Add Label to add labels.
- Upgrade Policy: In-place upgrade and Rolling upgrade are available.
- After the configuration is complete, click Create. You can view the Deployment status in the Deployment list.
If the Deployment is in the Running state, the Deployment is successfully created.
Creating a StatefulSet
- (Optional) If you create a workload using My Images, first upload the image to SWR. For details about how to upload an image, see Image Management. If you create a workload from an open source image, you do not need to upload the image.
- Log in to the cluster console. In the navigation pane, choose Workloads > StatefulSets. On the page displayed, click Create StatefulSet.
- Set basic workload parameters as described in Table 4. The parameters marked with asterisks (*) are mandatory.
Table 4 Basic workload parameters Parameter
Description
*Name
Name of a workload, which must be unique.
*Cluster
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.
*Pods
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.
Description
Description of the workload.
- Click Next, and add a container.
- Click Add Container and select the image to be deployed.
- My Images: Create a workload using an image in the HUAWEI CLOUD image repository. If no image is available, click push an image to push an image.
- If your image repository does not require authentication, set Secret Authentication to No, select the corresponding image, and then click OK.
- If your image repository requires authentication (using account and password), select the corresponding secret, and then click OK. If no secret is available, create a secret by following the procedure described in Creating a Secret.
- Open Source Images: Create a workload using an official image in the open source image repository.
- If your image repository does not require authentication, set Secret Authentication to No, select the corresponding image, and then click OK.
- If your image repository requires authentication (using account and password), select the corresponding secret, and then click OK. If no secret is available, create a secret by following the procedure described in Creating a Secret.
- Third-Party Images: Create a workload using an image from any third-party image repository (image repositories other than HUAWEI CLOUD SWR and open source image repository). Ensure that the node where the workload is running is accessible from public networks.
- If your image repository does not require authentication, set Secret Authentication to No, enter an image address, and then click OK.
- If your image repository requires authentication (using account and password), select the corresponding secret, enter an image address, and then click OK.
- My Images: Create a workload using an image in the HUAWEI CLOUD image repository. If no image is available, click push an image to push an image.
- Configure image parameters.
Table 5 Image parameters Parameter
Description
Image Name
Name of the image. You can click Change Image to select another image.
Image Tag
Tag of the image to be deployed. If you choose an image on the My Images or Open Source Images tab page, you must specify this parameter.
Container Name
Container name, which can be changed.
Container Specifications
Resource amount that users can apply for and the maximum amount of resources that are available to users. For details, see Setting Container Specifications.- Request: Minimum amount of resources required for running a container.
- Limit: If a container is overloaded, the system may be faulty. To avoid this situation, set the maximum limits for the container resource quotas to ensure that container resources do not exceed the limits.
- Configure container lifecycle, that is, set the commands that need to be executed in each phase during container management.
- Startup Command: Executed to start a container. For details, see Setting Container Startup Commands.
- Post-Start: Executed after a container runs successfully. For details, see Setting Container Lifecycle Parameters.
- Pre-Stop: Executed to delete logs or temporary files before a container is stopped. For details, see Setting Container Lifecycle Parameters.
- Set the health check function that checks whether containers and services are running properly. Two types of probes are provided: liveness probes and readiness probes. For details, see Setting Health Check for a Container.
- Liveness Probe: The probe restarts the workload when detecting that the workload pod is unhealthy.
- Readiness Probe: The probe sets the workload to the unready state when detecting that the workload pod is unhealthy. In this way, the service traffic will not be directed to the workload pod.
- Set environment variables. Environment variables can be added to a container. In general, environment variables are used to set parameters.
In the Environment Variables area, click Add Environment Variable.
- Set container permissions to protect the system and other containers from being affected.
Enter the user ID to set container permissions and prevent systems and other containers from being affected.
- Mount data storage to containers for persistent storage and high disk I/O. For details, see Federated PVCs.
After the workload is created, you can access the workload details page of the cluster console, click the Container Settings tab, and click Modify Container Settings to modify the container settings.
- Click Add Container and select the image to be deployed.
- Click Next, and set headless Service parameters, as shown in Table 6.
Table 6 Headless Service parameters Parameter
Description
Service Name
Name of the Service corresponding to the workload for mutual access between workloads in the same cluster. This Service is used for internal discovery of pods, and does not require an independent IP address or load balancing.
Port Name
Name of the container port. You are advised to enter a name that indicates the function of the port.
Container Port
Listening port inside the container.
- Click Add Service and set the workload access type.
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 Network Management.
- ClusterIP
A workload can be accessed from other workloads in the same cluster through a cluster-internal domain name. A cluster-internal domain name is in the format of <User-defined Service name>.<Namespace of the workload>.svc.cluster.local, for example, nginx.default.svc.cluster.local.
- NodePort
A workload can be accessed by other workloads in the same VPC using the IP address of a cluster node. The NodePort access type is applicable to the scenario in which other workloads in the same VPC in the cloud need to access the workload in the Kubernetes cluster.
- LoadBalancer
A workload can be accessed from a public network through a load balancer. LoadBalancer provides higher reliability than EIP-based NodePort because an EIP is no longer bound to a single node. The LoadBalancer access type is applicable to the scenario in which a Service exposed to public networks is required. The access address is in the format of <IP address of public network load balancer>:<access port>, for example, 10.117.117.117:80.
- ClusterIP
- Click Next and configure advanced settings.
- Upgrade Policy: Only Rolling upgrade is supported.
During a rolling upgrade, old pods are gradually replaced with new ones, and service traffic is evenly distributed to both old and new pods to ensure service continuity.
- Pod Management Policy: There are two types of policies: ordered and parallel.
Ordered: The StatefulSet will deploy, delete, or scale pods in order and one by one. (The StatefulSet continues only after the previous pod is ready or deleted.) This is the default policy.
Parallel: The StatefulSet will create pods in parallel to match the desired scale without waiting, and will delete all pods at once.
- Graceful Deletion: Set a time window (0–9,999s) for pre-stop commands to finish execution before a workload is deleted. The default value is 30s.
- Migration Policy: Set a time window for the system to schedule the workload pod to another available node when the node where the workload pod is running is unavailable. The default value is 300s.
- Scheduling Policies: You can combine static global scheduling policies or dynamic runtime scheduling policies as required. For details, see Scheduling Policy Overview.
- Pod Label: System-defined app labels added during workload creation cannot be modified. You can click Add Label to add labels.
- Upgrade Policy: Only Rolling upgrade is supported.
- After the configuration is complete, click Create. You can view the StatefulSet status in the StatefulSet list.
If the StatefulSet is in the Running state, the StatefulSet is successfully created.
Related Operations
Click the name of a workload. On the Pods tab page, click
next to the pod name to view pod details.
- Events: You can set search criteria, such as the time segment during which an event is generated or the event name, to view related events.
- Containers: You can view the container name, status, image, and restarts of the pod.
- Log: You can view and download container logs.
- Monitor: If the selected cluster is a HUAWEI CLOUD cluster, you can view the CPU usage and memory usage of the pods running on the cluster. This function is unavailable for other types of clusters.
Last Article: Workload Management
Next Article: Federating an Application

Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.