1

I need a little help if someone can advise where I am doing some mistake. I am trying to Setup Prometheus & Grafana Monitoring on Kubernetes Using Helm. Installation of Prometheus and Grafana done successfully. Installation of Prometheus and Grafana done successfully

All the pods and services running as expected All the pods and services running as expected

Both Grafana and Prometheus Servers up and running on respective ports. Both Grafana and Prometheus Servers up and running on respective ports.

However, when I want to access Grafana server from browser then facing issue. I suppose that the obvious reason is that we don’t have Node Port exposed in Grafana which is necessary to get access from outside. We can see in last screen shot that Grafana server showing internal cluster IP but not the Node Port IP To get Node Port exposed I use this : Kubectl expose service grafana-server --type=Nodeport --target-port=3000 --name=grafana-server-ext However still not getting NodePort so unable to get access Grafana using browser.

coolbaba
  • 11
  • 3
  • Hi @coolbaba, the screenshots are not showing as images but rather as links. Anyway, the installation comes along with some network policies that prevent access via nodeport. You will need to delete them to access both via the browser. This is however not recommended for production – Mike Mwanje Jan 24 '23 at 08:44

2 Answers2

0

Not the best way, but a quick dirty way to expose it (for testing) can be achieved with kubectl port-forward.

kubectl --namespace <yournamespace> port-forward svc/<nameofyougrafanaservice> <portonlocalmachine>:<portofserviceink8s> --address 0.0.0.0

exmpl.

kubectl --namespace monitoring port-forward svc/grafana-1654184440 30001:3000 --address 0.0.0.0

This will open the port on your local machine from which you are running the kubectl port-forward and you can reach it on url http://<YOUR_LOCAL_MACHINE_IP>:30001

The command will occupy the terminal

Also, firewall settings on that local machine should permit connections from outside, you need to open the port 30001

mirpop
  • 1
  • 2
0

There are network policies that are blocking this. You can view all of them by running the command below;

kubectl get networkpolicies -n monitoring

You may proceed to delete all of them or preferably only that for grafana.
Note that deleting any of these network policies is not recommended in production. Run the command below to delete grafana network policy

kubectl -n monitoring delete networkpolicies.networking.k8s.io grafana

or run the one below to delete all the network policies in the monitoring namespace.

kubectl -n monitoring delete networkpolicies.networking.k8s.io --all

That should enable you access the Grafana through Nodeport in your browser.

Mike Mwanje
  • 63
  • 1
  • 13