Unable to access NodePort ip in Kubernetes cluster

5/4/2021

I have below NodePort grafana and prometheus services running in cluster:

$kubectl get services -n monitoring                          
NAME                 TYPE       CLUSTER-IP     EXTERNAL-IP    PORT(S)          AGE
grafana              NodePort   172.2.5.6   192.168.1.2   3000:32001/TCP   25h
prometheus-service   NodePort   172.2.3.4   <none>         8080:30000/TCP   25h

I am unable to fetch metrics using below command and also unable to open grafana services http://172.2.5.6:32001 from browser.

curl http://172.2.3.4:30000/metrics.

I can only access when i do port forwarding, is it possible to access these services without port forwarding and by using NodePort IP.

Does this cluster have any firewall rules which is blocking access? How to check?

-- witty_minds
grafana
kubernetes
kubernetes-pod
prometheus
sysdig

1 Answer

5/4/2021

A NodePort service is always accessible via the node IP + node port service.

NodePort: Exposes the Service on each Node's IP at a static port (the NodePort). A ClusterIP Service, to which the NodePort Service routes, is automatically created. You'll be able to contact the NodePort Service, from outside the cluster, by requesting NodeIP:NodePort.

Like this: http://node-ip:32001 and http://node-ip:30000

-- Daniel Marques
Source: StackOverflow