Fix nginx-alpine Service targetPort (8111 -> 80)#127
Merged
Conversation
The Service in exercises/manifests/service.yaml forwarded traffic to targetPort 8111 on the backing pods, but the deployment runs the stock nginx:alpine image with no containerPort override and no custom nginx config — so the container actually listens on port 80. Requests hitting the Service got connection refused because nothing on the pod was bound to 8111. Set targetPort to 80 to match what the nginx:alpine container is actually listening on. The Service-facing port stays at 8111 to keep the existing course material consistent (clients still hit nginx-alpine:8111). Fixes #94 Co-Authored-By: sudkul <sudhanshu.kulshrestha@udacity.com>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
exercises/manifests/service.yamlsetstargetPort: 8111on thenginx-alpineService, but the corresponding Deployment runs the stocknginx:alpineimage with nocontainerPortoverride and no custom nginx config. The container actually listens on port 80, so requests to the Service got connection refused — nothing on the pod was bound to 8111.This PR sets
targetPort: 80so the Service forwards traffic to the port nginx is actually listening on. The cluster-facingportstays at8111to keep the existing course material consistent (clients still hitnginx-alpine:8111).Fixes #94
Test plan
kubectl apply -f exercises/manifests/brings up the namespace, deployment, configmap, and service cleanly.kubectl -n demo get endpoints nginx-alpinelists 3 endpoints, each on:80(matching the 3 nginx pods).curl http://nginx-alpine.demo:8111returns the default nginx welcome page (was previously connection refused).kubectl -n demo port-forward svc/nginx-alpine 8111:8111followed bycurl http://localhost:8111returns the nginx welcome page from the host.