I am working on fixing some errors in an existing Kubernetes multi-container one pod deployment. I have part of it fixed; I just am missing the syntax to route the traffic from the 'frontend' container to the 'backend' one.
The YAML file:
apiVersion: apps/v1
kind: Deployment
metadata:
name: minikube-hello-world
labels:
app: hello-world
spec:
replicas: 1
selector:
matchLabels:
app: hello-world
template:
metadata:
labels:
app: hello-world
spec:
containers:
- name: hello-world-frontend
image: frontend:latest
imagePullPolicy: Never
ports:
- containerPort: 80
- name: hello-world-backend
image: backend:latest
imagePullPolicy: Never
ports:
- containerPort: 80
---
kind: Service
apiVersion: v1
metadata:
name: hello-world-service
spec:
selector:
app: hello-world
ports:
- protocol: TCP
port: 80
targetPort: 80
nodePort: 31443
type: LoadBalancer
When I run minikube service hello-world-service I get the web page itself, but the backend service doesn't connect correctly, Nginx instead showing a 502 Bad Gateway error.
I've drilled down into the Kubenetes documentation and I've tried hostPort various places but I still don't have it right.
Any help would be much appreciated!