Kubernetes – CKAD Tips

Certified Kubernetes Application Developer (CKAD)

CKAD is an online tests with problems to be solved by a command line tool. Here are the tips of the test.

[1] Clusters and Nodes

  • There are several cluster environment for the exam.

You need to be in a correct cluster. Set the configuration context

kubectl config use-context k8s

You can access each node via ssh

ssh k8s-node-0
sudo -i # root

[2] Create or Apply

# create
kubectl run nginx --image=nginx --restart=Never
kubectl create cronjob nginx --image=nginx --schedule="* * * * *"

# apply = create and update
kubectl apply -f deployment.yaml

# use --save-config when you want to use 'kubectl apply' in the future
kubectl create -f deployment.yaml --save-config

[3] Create the definition file via –dry-run flag

kubectl run nginx --image=nginx --restart=Never --dry-run=client -o yaml > mypod.yaml
vim mypod.yaml
kubectl apply -f mypod.yaml
kubectl get pods
kubectl create service nodeport nginx-service --tcp=80:80 --node-port=30080 --dry-run=client -o yaml > my-service.yaml
vim my-service.yaml
kubectl apply -f my-service.yaml
kubectl get services

[4] Getting the definition file from the existing pod

kubectl get pod nginx -o yaml > pod.yaml

[5] Updating Deployments

kubectl create deployment nginx-deployment --image=nginx --dry-run=client -o yaml > my-deployment.yaml
vim my-deployment.yaml # set replicas=2
kubectl apply -f my-deployment.yaml

kubectl get deployments
kubectl get pods

# updating the image
kubectl set image deploy/nginx-deployment nginx=nginx:1.9.1

# check the image is updated
kubectl describe deployment nginx-deployment
kubectl get deployment nginx-deployment -o yaml

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s