Skip to content

Fix nginx-alpine Service targetPort (8111 -> 80)#127

Merged
SudKul merged 1 commit into
mainfrom
fix/service-targetport-issue-94
Apr 28, 2026
Merged

Fix nginx-alpine Service targetPort (8111 -> 80)#127
SudKul merged 1 commit into
mainfrom
fix/service-targetport-issue-94

Conversation

@SudKul

@SudKul SudKul commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Summary

exercises/manifests/service.yaml sets targetPort: 8111 on the nginx-alpine Service, but the corresponding Deployment runs the stock nginx:alpine image with no containerPort override 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: 80 so the Service forwards traffic to the port nginx is actually listening on. The cluster-facing port stays at 8111 to keep the existing course material consistent (clients still hit nginx-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-alpine lists 3 endpoints, each on :80 (matching the 3 nginx pods).
  • From inside the cluster, curl http://nginx-alpine.demo:8111 returns the default nginx welcome page (was previously connection refused).
  • kubectl -n demo port-forward svc/nginx-alpine 8111:8111 followed by curl http://localhost:8111 returns the nginx welcome page from the host.

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>
@SudKul SudKul requested a review from a team as a code owner April 28, 2026 05:38
@SudKul SudKul requested review from sarah-udacity and removed request for a team April 28, 2026 05:38
@Dhadhazi

Copy link
Copy Markdown
Contributor
Screenshot 2026-04-28 102940 Screenshot 2026-04-28 103005

Tests are all passed!

@SudKul SudKul merged commit d6ee307 into main Apr 28, 2026
1 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

service port change

2 participants