I'm facing this issue for the last 3 days and still can't figure out why I can't access NodePort outside k8s cluster using NodePort service type.
Basically I have set up a 3 node cluster in rhel8, I followed this tutorial https://www.tecmint.com/install-a-kubernetes-cluster-on-centos-8/ but faced some issues in weavenet network that's why I'm doing it again but this time with calico.
I installed calico latest version for the network addon and as you can see all kube pods are healthy and running.
Now here's my deployment file
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-k8s
spec:
selector:
matchLabels:
app: hello-k8s
replicas: 1
template:
metadata:
labels:
app: hello-k8s
spec:
containers:
- name: spring-boot
image: fuzzy28/hello-k8s:v3
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: hello-k8s-svc
spec:
selector:
app: hello-k8s
ports:
- protocol: TCP
port: 8080
targetPort: 8080
type: NodePort
I deployed it and it's running fine in the node that is highlighted below.
If we check the service, it's running in 32020 port.
I opened the ports in all nodes using below command
firewall-cmd --permanent --add-port=30000-32767/tcp
So the moment of truth, after checking this on the browser outside the k8s cluster it's not accessible.
I tried this in all nodes IP address but not accessible.
The weird thing is the URL is accessible only inside the pod from where it's deployed.
I really don't understand what's happening here, here's my network interfaces in case you want to see.