I am learning kubernetes and currently am trying to deploy the demo hello-world container and expose it as a service (type NodePort). I have one master and one worker connected to the cluster. Using weavenet as the CNI.
I have been following the official k8s docs for exposing it as a service.
I have one replica running through deployment with it exposed as a service.
Here is the kubectle get all
output:
NAME READY STATUS RESTARTS AGE
pod/hello-world-f9b447754-fthwg 1/1 Running 0 2d7h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/hello-world NodePort 10.96.217.234 <none> 8080:31097/TCP 2d7h
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/hello-world 1/1 1 1 2d7h
NAME DESIRED CURRENT READY AGE
replicaset.apps/hello-world-f9b447754 1 1 1 2d7h
While I am able to curl directly to <worker IP>:<NodePort>
and get the response, I am unable to curl to the service via the <master IP>:<NodePort>
. I am getting the error: curl: (7) Failed to connect to <master-IP> port 31097: No route to host
after a couple seconds of delay. Any other port or via the Cluster IP gets me the error: curl: (7) Failed to connect to 10.96.217.234 port 31097: Connection refused
QUESTION:
What am I missing here? The service should be accessible via the master IP and NodePort outside of the cluster right?
kube-proxy is running on both nodes and the apiserver seems to run fine. Someone mentioned I might need to change the YAML file corresponding to the apiserver although I am not sure how to or what to regarding that.
I need the service to be reachable via the master IP and exposed port. What part of the cluster config should I look at to get this working. I am new and want to learn the working of kubernetes and everything related to containers.
PS
I am trying the curl command within the master node and via my PC's browser. Never works. Same works fine for worker-IP.
I am doing this inside a corporate network that uses proxies but have set no_proxy for the master and worker IPs.
Also here are all of the running pods:
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-6955765f44-hhf7x 1/1 Running 0 2d10h
kube-system coredns-6955765f44-z5vx5 1/1 Running 0 2d10h
kube-system etcd-master-node 1/1 Running 0 2d10h
kube-system kube-apiserver-master-node 1/1 Running 0 2d10h
kube-system kube-controller-manager-master-node 1/1 Running 3 2d10h
kube-system kube-proxy-9m9gk 1/1 Running 0 2d9h
kube-system kube-proxy-nttqg 1/1 Running 0 2d10h
kube-system kube-scheduler-master-node 1/1 Running 3 2d10h
kube-system weave-net-6qlt8 2/2 Running 1 2d10h
kube-system weave-net-fk9nc 2/2 Running 0 2d9h
production hello-world-f9b447754-fthwg 1/1 Running 0 2d8h