Ultimate CKA test series doubt

For below question:

For this question, please set the context to cluster1 by running:

kubectl config use-context cluster1

We deployed an app using a deployment called web-dp-cka06-trb. it’s using the httpd:latest image. There is a corresponding service called web-service-cka06-trb that exposes this app on the node port 30005. However, the app is not accessible!

Troubleshoot and fix this issue. Make sure you are able to access the app using curl http://kodekloud-exam.app:30005 command.

I bring up the PODs, Deployment,

student-node ~ ➜ kubectl get pods
NAME READY STATUS RESTARTS AGE
demo-pod-cka29-trb 1/1 Running 0 46m
nginx-cka01-trb 0/2 CrashLoopBackOff 13 (3m42s ago) 45m
nodeapp-dp-cka08-trb-74f948c4b8-748lc 1/1 Running 0 46m
web-dp-cka06-trb-5ddc9f44c5-k5q2z 1/1 Running 0 18m

student-node ~ ➜ kubectl get deployments.apps
NAME READY UP-TO-DATE AVAILABLE AGE
nodeapp-dp-cka08-trb 1/1 1 1 46m
web-dp-cka06-trb 1/1 1 1 46m

At last step there is selector mismatch in service, i try to change the label as per deployment but still no progress:

student-node ~ ➜ curl http://kodekloud-exam.app:30005
curl: (7) Failed to connect to kodekloud-exam.app port 30005: Connection refused

Can you please help where i am doing the mistake?

In solution provided by you:

kubectl get deploy web-dp-cka06-trb -o yaml

Under labels you will see labels:**deploy:** web-app-cka06-trb
So we can see that service is using wrong selector label, let’s edit the service to fix the same

kubectl edit svc web-service-cka06-trb

Let’s try to access the webapp now.

curl http://kodekloud-exam.app:30005

Boom! app should be accessible now.

label is wrong:

labels:**deploy:** web-app-cka06-trb

when we check in original file:
its
app: web-app-cka06-trb

Please let me know on this ASAP

Hi @swapnilbkc

There is more to fix than just the service selector. You have to first fix the pod of the deployment which is not running at the start of the question

Hint - there are three errors to find in the pod template of the deployment, all of which must be fixed before the pod will run. Only then will correcting the service have the desired effect

Start with kubectl describe on the pod to find out why it cannot run.

Hi Allistair,
i have brought the pods up:

student-node ~ ➜ kubectl get pods
NAME READY STATUS RESTARTS AGE
demo-pod-cka29-trb 1/1 Running 0 46m
nginx-cka01-trb 0/2 CrashLoopBackOff 13 (3m42s ago) 45m
nodeapp-dp-cka08-trb-74f948c4b8-748lc 1/1 Running 0 46m
web-dp-cka06-trb-5ddc9f44c5-k5q2z 1/1 Running 0 18m

student-node ~ ➜ kubectl get deployments.apps
NAME READY UP-TO-DATE AVAILABLE AGE
nodeapp-dp-cka08-trb 1/1 1 1 46m
web-dp-cka06-trb 1/1 1 1 46m

If the pod is running, you should now be able to correct the service selector and it will pass.