Deployments
TOC
Understanding DeploymentsCreating DeploymentsCreating a Deployment by using CLIPrerequisitesYAML file exampleCreating a Deployment via YAMLCreating a Deployment by using web consolePrerequisitesCreating a Deployment by using new web consoleProcedure - Configure Basic InfoProcedure - Configure PodProcedure - Configure ContainersReference InformationHeath ChecksWhen to use a Deployment in the Applications viewDeployment review points before submissionManaging DeploymentsManaging a Deployment by using CLIViewing a DeploymentUpdating a DeploymentScaling a DeploymentRolling Back a DeploymentDeleting a DeploymentManaging a Deployment by using web consoleViewing a DeploymentUpdating a DeploymentDeleting a DeploymentTroubleshooting by using CLICheck Deployment statusCheck ReplicaSet statusCheck Pod statusView LogsEnter Pod for debuggingCheck Health configurationCheck Resource LimitsUnderstanding Deployments
Refer to the official Kubernetes documentation: Deployments
Deployment is a Kubernetes higher-level workload resource used to declaratively manage and update Pod replicas for your applications. It provides a robust and flexible way to define how your application should run, including how many replicas to maintain and how to safely perform rolling updates.
A Deployment is an object in the Kubernetes API that manages Pods and ReplicaSets. When you create a Deployment, Kubernetes automatically creates a ReplicaSet, which is then responsible for maintaining the specified number of Pod replicas.
By using Deployments, you can:
- Declarative Management: Define the desired state of your application, and Kubernetes automatically ensures the cluster's actual state matches the desired state.
- Version Control and Rollback: Track each revision of a Deployment and easily roll back to a previous stable version if issues arise.
- Zero-Downtime Updates: Gradually update your application using a rolling update strategy without service interruption.
- Self-Healing: Deployments automatically replace Pod instances if they crash, are terminated, or are removed from a node, ensuring the specified number of Pods are always available.
How it works:
- You define the desired state of your application through a Deployment (e.g., which image to use, how many replicas to run).
- The Deployment creates a ReplicaSet to ensure the specified number of Pods are running.
- The ReplicaSet creates and manages the actual Pod instances.
- When you update a Deployment (e.g., change the image version), the Deployment creates a new ReplicaSet and gradually replaces the old Pods with new ones according to the predefined rolling update strategy until all new Pods are running, then it removes the old ReplicaSet.
Creating Deployments
Creating a Deployment by using CLI
Prerequisites
- Ensure you have
kubectlconfigured and connected to your cluster.
YAML file example
Creating a Deployment via YAML
Creating a Deployment by using web console
Prerequisites
Obtain the image address. The source of the images can be from the image repository integrated by the platform administrator through the toolchain or from third-party platforms' image repositories.
-
For the former, the Administrator typically assigns the image repository to your project, and you can use the images within it. If the required image repository is not found, please contact the Administrator for allocation.
-
If it is a third-party platform's image repository, ensure that images can be pulled directly from it in the current cluster.
-
If the image registry requires authentication, you need to configure the corresponding image pull secret. For more information, see Add ImagePullSecrets to ServiceAccount.
Creating a Deployment by using new web console
The new web console can expose Deployment creation from different views. Choose the entry based on whether you are working from project scope or from a concrete cluster.
- Applications view: Start from the current project. Open Applications > Applications, select the target Cluster and Namespace, and then choose the workload model or creation flow that results in a Deployment.
- Clusters view: Start from a concrete cluster. Open the target cluster first, enter the target namespace, and then navigate to Workloads > Deployments to click Create Deployment.
Before proceeding, confirm the following differences:
- In the Applications view, cluster selection is part of the project-scoped application workflow.
- In the Clusters view, the cluster is already fixed because you start inside a concrete cluster.
- In the Applications view, review whether the namespace belongs to the intended project scope.
- In the Clusters view, review whether the namespace-side resources in that cluster are ready for the Deployment.
Procedure - Configure Basic Info
-
Container Platform, navigate to Workloads > Deployments in the left sidebar.
-
Click on Create Deployment.
-
Select or Input an image, and click Confirm.
Note: When using images from the image repository integrated into web console, you can filter images by Already Integrated. The Integration Project Name, for example, images (registry-projectname), which includes the project name projectname in this web console and the project name containers in the image repository.
-
In the Basic Info section, configure declarative parameters for Deployment workloads:
Procedure - Configure Pod
Note: In mixed-architecture clusters deploying single-architecture images, ensure proper Node Affinity Rules are configured for Pod scheduling.
-
Pod section, configure container runtime parameters and lifecycle management:
- Node Affinity Rules
- Network Configuration
-
Kube-OVN
-
Calico
-
Procedure - Configure Containers
-
Container section, refer to the following instructions to configure the relevant information.
-
Click Add Container (upper right) OR Add Init Container.
See Init Containers. Init Container:
- Start before app containers (sequential execution).
- Release resources after completion.
- Deletion allowed when:
- Pod has >1 app container AND ≥1 init container.
- Not allowed for single-app-container pods.
-
Click Create.
Reference Information
Storage Volume Mounting instructions
Heath Checks
When to use a Deployment in the Applications view
Use a Deployment when the workload is primarily stateless and should be updated through replicated Pod replacement rather than stable identity or per-replica persistent state.
A Deployment is usually the better fit when:
- replica identity does not need to remain stable across replacement
- the workload should scale horizontally through interchangeable Pods
- rolling update behavior is preferred for application delivery
If the workload depends on stable ordinal identity or per-replica persistent storage, review StatefulSets instead.
Deployment review points before submission
Before creating or updating a Deployment in the Applications view, review the following carefully:
- Whether the selected project, cluster, and namespace are the intended runtime scope
- Whether the replica count matches the intended availability target
- Whether the selected image and pull credentials are valid in the target cluster
- Whether referenced ConfigMaps, Secrets, PVCs, or ServiceAccounts already exist in the same namespace
- Whether resource requests, limits, and probes match the real startup and health behavior of the application
- Whether the rollout strategy is safe for the workload and traffic pattern
Managing Deployments
Managing a Deployment by using CLI
Viewing a Deployment
-
Check the Deployment was created.
-
Get details of your Deployment.
Updating a Deployment
Follow the steps given below to update your Deployment:
-
Let's update the nginx Pods to use the nginx:1 .16.1 image.
or use the following command:
Alternatively, you can edit the Deployment and change
.spec.template.spec.containers[0].imagefromnginx:1.14.2tonginx:1.16.1: -
To see the rollout status, run:
Run kubectl get rs to see that the Deployment updated the Pods by creating a new ReplicaSet and scaling it up to 3 replicas, as well as scaling down the old ReplicaSet to 0 replicas.
Running get pods should now show only the new Pods:
Scaling a Deployment
You can scale a Deployment by using the following command:
Rolling Back a Deployment
-
Suppose that you made a typo while updating the Deployment, by putting the image name as
nginx:1.161instead ofnginx:1.16.1: -
The rollout gets stuck. You can verify it by checking the rollout status:
Deleting a Deployment
Deleting a Deployment will also delete its managed ReplicaSet and all associated Pods.
Managing a Deployment by using web console
Viewing a Deployment
You can view a deployment to get information of your application.
- Container Platform, and navigate to Workloads > Deployments.
- Locate the Deployment you wish to view.
- Click the deployment name to see the Details, Topology, Logs, Events, Monitoring, etc.
Updating a Deployment
- Container Platform, and navigate to Workloads > Deployments.
- Locate the Deployment you wish to update.
- In the Actions drop-down menu, select Update to view the Edit Deployment page.
The update operation keeps the Deployment in its current cluster and namespace. If the workload must run in a different cluster or namespace, create or apply a separate Deployment in that target scope instead of treating update as a move operation.
Before submitting an update, confirm that changes to images, probes, environment variables, ports, volume mounts, or resource settings will not break the running workload.
Changes to the Pod template can trigger a new rollout. A successful update request does not by itself mean the rollout is healthy. The real effect appears only after the new Pod revision schedules correctly, becomes ready, and replaces the previous revision without leaving the workload unavailable.
Deleting a Deployment
- Container Platform, and navigate to Workloads > Deployments.
- Locate the Deployment you wish to delete.
- In the Actions drop-down menu, Click the Delete button in the operations column and confirm.
After deletion, verify that the Deployment no longer appears in the list and that any separate Service, ConfigMap, Secret, or PVC intended to remain is still present.
Troubleshooting by using CLI
When a Deployment encounters issues, here are some common troubleshooting methods.
Check Deployment status
Check ReplicaSet status
Check Pod status
View Logs
Enter Pod for debugging
Check Health configuration
Ensure livenessProbe and readinessProbe are correctly configured, and your application's health check endpoints are responding properly. Troubleshooting probe failures
Check Resource Limits
Ensure container resource requests and limits are reasonable and that containers are not being killed due to insufficient resources.
