Skip to main content
In this lab article, you will be introduced to Kubernetes deployments. We will walk through each step of the process while ensuring that your cluster is correctly set up and that deployments function as expected.

Step 1: Check the Initial Cluster State

Before creating any deployments, verify that your cluster has no existing pods, ReplicaSets, or deployments. Start by checking for pods:
Then, check for ReplicaSets:
Finally, check for any deployments:
At this point, your environment is clean with zero pods, zero ReplicaSets, and zero deployments.

Step 2: Observe Changes After a Deployment is Created

After applying some changes, check the deployments again. You should now see that one deployment exists:
Examine the ReplicaSet created by that deployment:
And then inspect the pods:
Because none of the four pods are in a ready state, you need to identify which image they are trying to pull. Run the following command to display detailed information for one pod:
From the output, notice that the specified image is busybox:888. Since this image does not exist, the pods are unable to reach a ready state.
The image name must be valid and available in your container registry. Verify the image tag before deployment to avoid issues like ImagePullBackOff.

Step 3: Create a New Deployment Using a YAML Definition

Verify Your Current Directory and Files

Ensure you are in the correct working directory and check the available files:

Attempt to Create the Deployment

Run the following command to create the deployment from the YAML file:
If you encounter an error such as:
Open the file to correct the issue:

Update the Deployment YAML

The error is caused by incorrect casing in the kind field. The resource kind should be capitalized. Use the corrected YAML below:
After saving the changes, create the deployment again:

Step 4: Create a Deployment Using Command-Line Parameters

You can also create a deployment by specifying parameters directly in the command line. First, review the help for deployment creation:
For example, to create a deployment named http-frontend using a specified image with three replicas, run:
After executing the command, verify that the deployment and pods are running as expected:
Make sure that the http-frontend deployment reflects the desired number of replicas in the ready state.

Final Validation

To ensure all deployments are functioning, validate by checking that all created deployments are running and the pods are in a ready state. This confirms that your environment is correctly configured and operational. This concludes the lab article on Kubernetes deployments. In upcoming labs, you’ll explore additional Kubernetes functionalities to further enhance your skills.

Watch Video