I have transferred my microk8s setup to a new server and found that the once-working ingress setup my trial setup stopped working.
I am running this minimal whoami-app:
apiVersion: apps/v1
kind: Deployment
metadata:
name: whoami
namespace: default
labels:
app: whoami
spec:
selector:
matchLabels:
app: whoami
template:
metadata:
labels:
app: whoami
spec:
containers:
- name: whoami
image: containous/whoami
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: whoami
namespace: default
spec:
selector:
app: whoami
ports:
- protocol: TCP
port: 80
targetPort: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: whoami
namespace: default
annotations:
kubernetes.io/ingress.class: public
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: whoami
port:
number: 80
Pod is up and running, service exposed it properly, but the ingress is not working:
kubectl get services whoami
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
whoami ClusterIP 10.152.183.184 <none> 80/TCP 26m
curl 10.152.183.184
Hostname: whoami-567b85d54d-qbbd5
IP: 127.0.0.1
IP: ::1
IP: 10.1.76.7
IP: fe80::e850:aaff:fe72:91c4
RemoteAddr: 192.168.0.102:21910
GET / HTTP/1.1
Host: 10.152.183.184
User-Agent: curl/7.68.0
Accept: */*
kubectl get ingress whoami
NAME CLASS HOSTS ADDRESS PORTS AGE
whoami <none> * 127.0.0.1 80 28m
The nginx-ingress-controller log shows these entries:
controller.go:1076] Service "default/whoami" does not have any active Endpoint.
But again, accessing through the clusterIP works, so both the Pod and the Service are doing their job.