Hello! I'm Labby, and I'd be happy to help you with that.
To inspect the pods associated with a specific deployment, you can use the kubectl get pods command combined with a label selector.
The Best Way: Using Labels
In Kubernetes, deployments manage pods by using labels. According to your current step, the web-app deployment uses the label app=web. You can find its pods by running:
kubectl get pods -l app=web
-l: Stands for "selector" (label).app=web: Is the key-value pair we defined in the deployment manifest.
Other Helpful Methods
-
Check the Deployment Details:
If you are not sure what label the deployment is using, you can run:kubectl describe deployment web-appLook for the
Selectorfield in the output; it will tell you which labels the pods are using. -
Wide Output:
To see more details about all pods (like which node they are running on), you can add-o wide:kubectl get pods -l app=web -o wide -
Check Service Endpoints:
Since you've also created a service, you can runkubectl describe service web-service. TheEndpointssection will list the internal IP addresses of the pods that the service is currently sending traffic to.
Based on your terminal history, I can see you've already successfully run kubectl describe service web-service and found two endpoints (10.244.0.2:80, 10.244.0.4:80). This confirms your pods are up and correctly linked!
Keep up the great work! Do you have any other questions about these commands?