Why is the connection refused each time I try to connect to a nodeport exposed service on MicroK8s?
Here is the following deployment, service and ingress:
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
labels:
app: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx-container
image: 'nginx'
ports:
- containerPort: 80
---
kind: Service
apiVersion: v1
metadata:
name: nginx
labels:
app: nginx
spec:
selector:
app: nginx
ports:
- protocol: TCP
port: 80
targetPort: 80
selector:
app: nginx
type: NodePort
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx.info
labels:
app: 'nginx'
annotations:
kubernetes.io/ingress.class: "nginx"
spec:
rules:
- host: 'nginx.plz'
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: 'nginx'
port:
number: 80
I've included the following line my /etc/hosts
file as well:
127.0.0.1 nginx.plz
However, when I try to reach the site I continue to get the following error:
curl -v -H "host: nginx.plz" 10.152.183.60
* Trying 10.152.183.60...
* TCP_NODELAY set
* Connection failed
* connect to 10.152.183.60 port 80 failed: Operation timed out
* Failed to connect to 10.152.183.60 port 80: Operation timed out
* Closing connection 0
curl: (7) Failed to connect to 10.152.183.60 port 80: Operation timed out
Is anyone familiar with setting this up on microk8s? I did see a few other questions such as this one: https://serverfault.com/questions/1032572/microk8s-deploy-application-not-working but it didn't have a solution
EDIT: I have enabled the microk8s ingress as well.