Anybody know why I keep getting service unavailable for the below YAML code. The ingress points to the service which points to the container and it should be working. For this example I am just using an NGINX container to test.
apiVersion: v1
kind: Service
metadata:
name: frontend
spec:
selector:
k8s-app: traefik-ingress-lb
app: nginx
ports:
- name: web
port: 80
targetPort: 80
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: frontend
spec:
rules:
- host: test.example.services
http:
paths:
- path: /
backend:
serviceName: frontend
servicePort: web
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.15.4
ports:
- containerPort: 80
---
If you using traefik as ingress controller then, documentation might be misleading. Below you can see an example of ingress controller form traefik website. The same configuration returned 503 error for my application. It turned out that, I had to change servicePort: http
to servicePort: 80
and this change fixed the problem!
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: cheese
annotations:
kubernetes.io/ingress.class: traefik
spec:
rules:
- host: stilton.minikube
http:
paths:
- path: /
backend:
serviceName: stilton
servicePort: http
...
The service had a selector which the app didn't. Once the label k8s-app: traefik-ingress-lb
was removed everything worked fine.
Thanks to Daniel Tomcej on the Traefik Slack channel for helping me out here.