kubectl is the command-line utility for interacting with a Kubernetes cluster. Use it to inspect nodes, retrieve cluster information, deploy applications, scale workloads, monitor runtime state, and debug failures. section 3.3.2
A production workflow starts with cluster visibility: list nodes and their readiness, confirm cluster connectivity, then create or run an application. Kubernetes objects provide the configuration boundary for these operations, including metadata, labels, container images, and ports. section 3.3.2 section 3.3.3
Use kubectl throughout an application’s operational lifecycle:
- Inspect infrastructure with kubectl get nodes and kubectl cluster-info. section 3.3.2
- Create and update YAML-defined resources with kubectl create -f and kubectl apply -f. section 3.3.3
- Check readiness, status, restart counts, and age with kubectl get pod or kubectl get deployments. section 3.3.3
- Diagnose failures with kubectl describe and kubectl logs; an invalid image produces ErrImagePull and 0/1 readiness. section 3.3.3
- Expose a pod locally with kubectl port-forward, then remove it with kubectl delete when the test is complete. section 3.3.3
Deploy and debug a FastAPI pod
Define a pod with a container image and listening port, create it with kubectl create -f pod.yaml, and verify it with kubectl get pod. If the image is wrong, kubectl get pod reports ErrImagePull; fix the image, reapply the YAML, and use kubectl describe pod joker or kubectl logs joker for detail. Use kubectl port-forward joker 8080:80 to test the running service locally. section 3.3.3
Listing 3.4 pod.yaml: creating a pod
apiVersion: v1 #1
kind: Pod #2
metadata:
name: joker #3
spec:
containers:
- name: hello-joker #4
image: <docker_hub_repo>:hello-joker:v1 #5
ports:
- containerPort: 8083 #6
Inspect the complete pod manifest showing the API version, object kind, metadata, container image, and exposed port. section 3.3.3
kubectl describe deployment joker-deployment
Events:
Type Reason Age From
---- ------ ---- ----
Normal ScalingReplicaSet 40m deployment-controller
Scaled up replica set
joker-deployment
-5d7fd8d75f to 3
Normal ScalingReplicaSet 104s deployment-controller
Scaled up replica set
joker-deployment
-5c6f544ccd to 1
Normal ScalingReplicaSet 96s deployment-controller
Scaled down replica set
joker-deployment
-5d7fd8d75f to 2
Normal ScalingReplicaSet 96s deployment-controller
Scaled up replica set
joker-deployment
-5c6f544ccd to 2
Normal ScalingReplicaSet 86s deployment-controller
Scaled down replica set
joker-deployment
-5d7fd8d75f to 1
Normal ScalingReplicaSet 86s deployment-controller
Scaled up replica set
joker-deployment
-5c6f544ccd to 3
Normal ScalingReplicaSet 78s deployment-controller
Scaled down replica set
joker-deployment
-5d7fd8d75f to 0
Trace deployment events as ReplicaSets scale up and down during an image update. section 3.3.3










