Prepare for your CKA certification with a real example

Illustration of a person sitting on the floor next to a stack of books, smiling and looking at a phone, with a large chalkboard background displaying 'THE PLAN' and a drawing of a building. Illustration of a person sitting on the floor next to a stack of books, smiling and looking at a phone, with a large chalkboard background displaying 'THE PLAN' and a drawing of a building.

This time we are going to learn how to think when we are preparing the CKA test certification. We are going to see how to work with a complex exercise:

  1. Create a single Pod named ready-if-service-ready with image nginx:1.16.1-alpine.
  2. Configure a LivenessProbe which simply runs true.
  3. Also configure a ReadinessProbe which does check if the url http://service-am-i-ready:80 is reachable, you can use wget http://service-am-i-ready:80 for this.
  4. Start the Pod and confirm it isn't ready because of the ReadinessProbe
  5. Create a second Pod named am-i-ready of image nginx:1.16.1-alpine with label id: cross-server-ready.
  6. The already existing Service service-am-i-ready should now have that second Pod as endpoint.
  7. Now the first Pod should be in ready state - confirm that.

Kubernetes audit: it's a complex framework, and it's tricky to get it right. We are here to help you with that. About Kubernetes audits

We have a pod that in the readynessProbe is pointing to an url that is an endpoint created with a service. This service points to another pod, but the interesting thing here is that the exercise starts with one service only, service-am-i-ready.

We start with our service and as you can see here we have defined in this service an id called cross-server-ready:

Screenshot of a computer terminal displaying Kubernetes service configuration YAML, including metadata, spec details with ports, and a command prompt at the bottom.

This id is the key of the exercise. Now we need to create a pod ready-if-service-ready pointing in the readinessProbe to the url service-am-i-ready.

Illustration of an orange shipping container labeled "ready-if-service-ready" with an arrow pointing towards a button labeled "service-am-i-ready".

This url is setup in the service pointing to the endpoint am-i-ready with the id cross-server-ready that will be set it up in the service as you show and in the pod.

Illustration of two shipping containers connected by arrows to a central button labeled "service-am-i-ready," with text "ready-if-service-ready" and "am-i-ready" beneath each container.

We start with kubectl get all and we see that the service is there.

Terminal screen with output from Kubernetes 'kubectl get all' command showing two services with cluster IPs, ports, and age but no external IPs.

Now we need to create our pod with the LivenessPRobe and ReadinessPRobe and to learn how to do that best thing is to check in Kubernetes Documentation page that as we know we are allowed to use in our CKA certification. In the search we have an entry with a pod deployment example that we can get for our case.

Copy the code and create a file called ready-if-service-ready where we paste the code. We need to remove the parts that are not needed in our case, change the id and the component name. Then we need to change the image to use a busy box image, and after that we need to setup the livenessProbe with the command true and the readinessProbe with the command sh -c wget to the service-am-i-ready.

Screenshot of a computer terminal displaying a Kubernetes pod configuration file with liveness and readiness probes commands for an Nginx container.

Now we apply the the yaml file with Kubectl apply -f. If we execute kubectl get all again we can see that the pod is running but if we run kubectl describe pod/ready-if-service-ready we can see that there is a problem and the readisnessPRobe is failing. The reason is that we point to the service but the service is not pointing to the pod because is not there yet.

Next step is to create the new pod that is missing. To do that we start copying our previous yaml file. We edit the file and the first thing that we are going to do is remove the livened probe and readiness probe. After that we change the id to cross-server-ready and the name of the pod and the container name with the image name that will be an Nginx this time.

Now we save and apply the template. If again we execute kubectl get all we can see that currently our pods are still not running any. If we execute now kubectl describe pod/cross-server-ready we will see that the pod is not yet ready. In this case is because we are using Google Cloud with GKE autopilot and we need time to start the pod.

When the pod is up and running we can now execute again kubectl get all we can see how are pods are running as we described in the initial draft. Now we can check with kubectl describe service/service-am-i-ready and check the endpoint. And that’s all! Remember that it's always better to think twicee in the CKA test!


Here's the same article in video form for your convenience: