kubectl create.
Prerequisites
- A Kubernetes cluster (e.g., kind, Minikube, or a hosted cluster) and
kubectlconfigured to talk to it. - Basic familiarity with
kubectlcommands.
- Confirm cluster initial state (no resources in default namespace).
- Create a Deployment and observe the ReplicaSet and Pods it creates.
- Troubleshoot an
ImagePullBackOffcaused by an invalid image name. - Fix a manifest and create a Deployment from a file.
- Create a Deployment with
kubectl create deployment.
- Kubernetes Deployments: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
- kubectl cheat sheet: https://kubernetes.io/docs/reference/kubectl/cheatsheet/
- Question: How many Pods exist on the system?
- Question: How many ReplicaSets exist?
- Question: How many Deployments exist?
- After creating a Deployment (the exercise creates a Deployment named
frontend-deployment), re-check Deployments, ReplicaSets, and Pods.
- Question: Out of the existing Pods, how many are ready?
READY column above).
Troubleshoot one Pod to find the image used
- Describe one of the Pods to see the container image and error reason:
busybox888. The container is in ErrImagePull / ImagePullBackOff because that image name does not exist (or cannot be pulled). That explains why none of the pods are ready.
When creating manifests, ensure
kind values are correctly capitalized (for example, kind: Deployment). Also verify apiVersion is appropriate for the kind.If you see
ErrImagePull or ImagePullBackOff, confirm the image name and tag are correct and that the image is accessible from your cluster (e.g., public Docker Hub, private registry with proper credentials).- The provided manifest
deployment-definition-1.yamlshould use a correctapiVersionand a properly capitalizedkind. A corrected example manifest (that uses the samebusybox888image as in the exercise) looks like:
kind and apiVersion are correct, the resource will be created successfully. Use kubectl get deploy and kubectl get pods to confirm status and troubleshoot further if pods are not ready.
Create a new Deployment using kubectl create deployment
- Next task: create a Deployment named
httpd-frontendwith 3 replicas using thehttpdimage. Usekubectl create deploymentwith--imageand--replicas.
httpd-frontend Deployment should become ready once pods pull the image successfully and pass readiness checks:
httpd-frontend Deployment has 3 ready replicas.
Commands summary
Wrap-up
- A Deployment creates a ReplicaSet which in turn manages Pods.
- Use
kubectl getandkubectl describeto inspect resource status and to identifyErrImagePull/ImagePullBackOffissues. - Manifest errors (for example, wrong case in
kind) lead to API errors when creating resources—ensureapiVersionandkindare correct. - You practiced creating a Deployment from a manifest and with
kubectl create deployment, and verified Pod readiness.
- Kubernetes Deployments: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
- Troubleshooting: https://kubernetes.io/docs/tasks/debug-application-cluster/debug-application/
- kubectl reference: https://kubernetes.io/docs/reference/kubectl/overview/