Skip to main content
In this guide, we introduce Kubernetes deployments by first examining the current environment state before any deployment is created.

Environment Verification

Start by checking how many pods exist on the system with the command:
Output:
Next, verify the number of ReplicaSets:
Output:
Finally, check the existing deployments:
Output:
At this point, the environment is clean—no pods, ReplicaSets, or deployments are present. Some changes are then applied. Rechecking the deployments now shows that one deployment has been created:
Output:
Next, inspect the ReplicaSets:
Output:
And finally, list the pods:
Output:
None of the four pods are ready. To investigate further, inspect one of the pods in detail:
Within the detailed output, you will notice that the image used is “busybox888” (visible under the “Pulling image” events). Key excerpts from the describe output include:
The image “busybox888” does not exist, which is why the pods are not becoming ready. Verify and update your image name as needed.

Creating a Deployment Using a YAML Definition

The next task is to create a new deployment using a YAML file. In your root directory, verify the YAML file presence:
Then, attempt to create the deployment by executing:
You might encounter an error similar to this:
Upon inspecting the file, you could notice that although the API version is correctly set to apps/v1, the kind is mistakenly written in lowercase. The kind field is case sensitive and must start with an uppercase letter. Below is the corrected YAML definition:
After correcting the kind field, save the file and run:
If the file is corrected properly, the deployment will be created successfully.

Creating a Deployment via the Command Line

An alternative method is to create a deployment directly from the command line by specifying the name, image, and number of replicas. For example, to create an HTTP frontend deployment with three replicas using a specific image, run:
It is a good practice to verify the newly created deployment immediately:
You should see the new http-frontend deployment listed, and eventually, the pods should transition to a ready state.

Summary

This lesson demonstrated how to:
  • Check the environment for existing pods, ReplicaSets, and deployments.
  • Troubleshoot a deployment issue caused by an incorrect image.
  • Correctly create a deployment using a YAML definition.
  • Create a deployment directly from the command line.
Ensuring correct syntax and case sensitivity in your Kubernetes YAML files is crucial to avoid deployment errors.
By following these steps, you will strengthen your understanding of Kubernetes deployments and develop the skills to quickly troubleshoot and resolve common issues.

Watch Video