Essential Commands for the Kubernetes Certified Administrator (CKA) Exam

Matías Salinas
2 min readApr 10, 2023

--

If you’re preparing for the Kubernetes Certified Administrator (CKA) exam, you’ll need to know how to work with Kubernetes from the command line. In this article, we’ll cover some essential commands that you should be familiar with for the exam.

1.- kubectl version This command displays the version of the kubectl command-line tool and the Kubernetes server. Example output:

Client Version: version.Info{...}
Server Version: version.Info{...}

2.- kubectl create This command creates a new Kubernetes object from a YAML or JSON file. Example:

kubectl create -f pod.yaml

3.- kubectl get This command displays information about Kubernetes objects. Example:

kubectl get pods

4.- kubectl describe This command provides detailed information about a Kubernetes object. Example:

kubectl describe pod my-pod

5.- kubectl logs This command displays the logs of a container in a pod. Example:

kubectl logs my-pod my-container

6.- kubectl exec This command runs a command in a container in a pod. Example:

kubectl exec my-pod -- ls /

7.- kubectl port-forward This command forwards a local port to a port in a pod. Example:

kubectl port-forward pod/my-pod 8080:80

8.- kubectl delete This command deletes a Kubernetes object. Example:

kubectl delete pod my-pod

8.- kubectl apply This command updates a Kubernetes object from a YAML or JSON file. Example:

kubectl apply -f pod.yaml

10.- kubectl edit This command opens a Kubernetes object in an editor. Example:

kubectl edit pod my-pod

11.- kubectl rollout status This command shows the status of a deployment rollout. Example:

kubectl rollout status deployment/my-deployment

12.- kubectl scale This command scales a deployment. Example:

kubectl scale deployment/my-deployment --replicas=3

13.- kubectl label This command adds a label to a Kubernetes object. Example:

kubectl label pod my-pod environment=prod

14.- kubectl annotate This command adds an annotation to a Kubernetes object. Example:

kubectl annotate pod my-pod description="My first pod"

15.- kubectl create secret This command creates a secret. Example:

kubectl create secret generic my-secret --from-literal=password=secretpassword

16.- kubectl get events This command displays events related to Kubernetes objects. Example:

kubectl get events

17.- kubectl apply — dry-run This command checks if a YAML or JSON file can be applied to the Kubernetes cluster without actually applying it. Example:

kubectl apply -f pod.yaml --dry-run

18.- kubectl top This command displays resource usage statistics for Kubernetes objects. Example:

kubectl top pod my-pod

19.- kubectl taint This command taints a node. Example:

kubectl taint node my-node app=blue:NoSchedule

20.- kubectl uncordon This command sets a node to the schedulable state. Example:

kubectl uncordon my-node

By mastering these commands, you’ll have a solid foundation for working with Kubernetes from the command line, and you’ll be well on your way to passing the CKA exam. Good luck!

--

--

Matías Salinas
Matías Salinas

No responses yet