Deploy Nginx Web Server on Kubernetes Cluster

Dear @Inderpreet, @kodekloud-support3 and @Ayman
The task mentioned was assigned to me. It asked to create a deployment with nginx as image and a service. I used a tag to a specific version of nginx so the task failed. The service is working properly and using nginx, why the task failed?


Hello @francilio, I used imperative command to perform this task with --image=nginx and succeeded. Maybe the tag you used is the reason.

1 Like

I also think so. I think it shouldn’t interfere, as the image is the right one

Hello, francilio
If task described to use image nginx only and you used nginx:version then it’s a fairly chance to failed. We won’t decide version.

@Inderpreet, can you give it a look? Putting a version is a reason to fail?

@Inderpreet,@kodekloud-support3

Can you please check why this task got failed?

image

thor@jump_host ~$ kubectl get service nginx-service -o wide
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
nginx-service NodePort 10.104.112.169 80:30011/TCP 5m41s app=nginx
thor@jump_host ~$ kubectl get deployments nginx-deployment -o wide
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
nginx-deployment 3/3 3 3 8m50s nginx-container nginx app=nginx
thor@jump_host ~$ thor@jump_host /$

thor@jump_host ~$ kubectl get service nginx-service -o wide
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
nginx-service NodePort 10.104.112.169 80:30011/TCP 5m41s app=nginx
thor@jump_host ~$ kubectl get deployments nginx-deployment -o wide
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
nginx-deployment 3/3 3 3 8m50s nginx-container nginx app=nginx
thor@jump_host ~$ thor@jump_host /$

Hello, q69145
Can you write full error message not visible end part?

Hi @francilio could you please share your KKE username?

@q69145 I think as per question the label app should be nginx-app and the selector used for service should be app: nginx-app but as per screenshot you used app: nginx which seems to be the reason of failure.

[email protected]

@francilio give it another try.

Thank you, @Inderpreet and @rahul456

@Inderpreet @rahul456 I did it again, but it failed with ‘Service not found for nginx deployment or inccorect selectors were used’, but the service is there with the right name. I put the pod label at the selector, not the deployment one, as you can see in the following picture


I tested the service and node ports and everything works


So, the service can route to the pods. I saw that you improved the text a lot and a thank you for that. I think you should add to this task that the selector must use the deployments label.

As per the question I believe the labels app must have value app-nginx. The mapping seems correct but the labels value is incorrect as per requirements mentioned that’s why it failed I believe.

@Inderpreet
The task asks for the label app with nginx-app value in deployment, I don’t think it says the pods must have the same label. I gave the label app: nginx-app and type: front-end to deployment but gave app: nginx to pods (as you can see the deployment selector use app: nginx also)

@francilio yes labels are for deployment only not for pods as per question. I got your point and marked it Success for you.

1 Like

Thank you @Inderpreet

@Inderpreet @kodekloud-support3 and @Ayman
Hello,

My Task failed with:

image

I think i got everything right:


Maybe the way you define label for deployment cause the validation script to fail.