The front end, Docker's Nginx 75 image, proxies /api/ to API_UPSTREAM. It gets a Deployment and a NodePort Service on 30080, which Multi-Node Cluster's kind 14,561 config maps to 127.0.0.1:33080:
apiVersion: apps/v1
kind: Deployment
metadata: { name: web, labels: { app: booknest, tier: web } }
spec:
replicas: 2
selector: { matchLabels: { app: booknest, tier: web } }
template:
metadata: { labels: { app: booknest, tier: web } }
spec:
containers:
- name: nginx
image: localhost:33500/booknest-web:1.3
env: [{ name: API_UPSTREAM, value: "api.booknest.svc.cluster.local:3000" }]
ports: [{ name: http, containerPort: 80 }]
---
apiVersion: v1
kind: Service
metadata: { name: web, labels: { app: booknest, tier: web } }
spec:
type: NodePort
selector: { app: booknest, tier: web }
ports: [{ name: http, port: 80, targetPort: http, nodePort: 30080 }]kubectl delete pod client && kubectl delete service api-headless docs
kubectl apply -f k8s/web.yaml && kubectl rollout status deployment/web >/dev/null
kubectl get services
sleep 3; curl -s http://127.0.0.1:33080/api/books/3 | cut -c1-90Output
pod "client" deleted from booknest namespace
service "api-headless" deleted from booknest namespace
service "docs" deleted from booknest namespace
deployment.apps/web created
service/web created
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
api ClusterIP 10.96.121.82 <none> 3000/TCP 40s
db ClusterIP 10.96.28.125 <none> 5432/TCP 27m
web NodePort 10.96.41.131 <none> 80:30080/TCP 2s
{"id":3,"title":"Salt and Saffron","author":"Priya Nair","genre":"Cooking","price":24,"ratThe request crossed every layer: host port, NodePort, a web Pod, CoreDNS 366,312 , the API's ClusterIP and a replica. With the image's Compose 514 default, API_UPSTREAM=api:3000, every /api/ call returned 502 Bad Gateway. In a Windows browser the page is at http://localhost:33080:

Ingress and the Gateway API replaces the NodePort with host- and path-based routing through Ingress and the Gateway API.