Kubernetes: why i can not reach the app when i hit <WORKER_PUBLIC_IP>:<PORT>?

3/5/2022

I created a kubernetes cluster using kubeadm, I initiated it using kubeadm init --pod-network-cidr=192.168.0.0/16 and the returned token looks like: kubeadm join 172.31.103.17:6443 --token 3e0aiz.qvzldzk6fskjvfmk --discovery-token-ca-cert-hash sha256:a295f...0d

PS: Notice 172.31.103.17 is a private IP of my master node. I tried to use --apiserver-advertise-address=<MASTER_PUBLIC_IP>, but kubeadm init command stuck.

I deloyed nginx pod and I exposed it using nodePort service. When I hit <localhot>:30162 from the browser of the worker it works fine, but when I use the browser of my physical machine using <WORKER_PUBLIC_IP>:30162 , so it does not work.

I would like to know why ?

PS: The VMs of my cluster are deployed on my cloud guru account (using ubuntu20.04 images)

Any help would be really appreciated! Thank you in advance

-- Mohamed
kubeadm
kubernetes
kubernetes-ingress
kubernetes-service
service-node-port-range

1 Answer

3/5/2022

You can make a port forward with your service:

kubectl port-forward service/your-service 8081:30162
-- sbrienne
Source: StackOverflow