This is the process I used to connect to the Grafana web server that gets deployed when adding the Prometheus Operator from the Civo Kubernetes Marketplace. If you want to dive straight in, you can use the quick start below, or see the steps to get to that point by following along with the guide.
Quick Start
If you already have a Kubernetes cluster running Prometheus Operator, the command to access it at http://localhost:8080 will be:
PowerShell:
kubectl port-forward $(kubectl get pods -n monitoring -o name | sls grafana) 8080:3000 -n monitoring
Bash
kubectl port-forward $(kubectl get pods -n monitoring -o name | grep grafana) 8080:3000 -n monitoring
Prerequisites
- Have
kubectl
command line tool installed - Deploy a kubernetes cluster with the Prometheus Operator app selected.
- Have the config file for your cluster downloaded. You can either do this through the web UI:
Or, alternatively, you can use the Civo CLI tool and run civo k8s config
Add the configuration file to your shell:
PowerShell:
Set the path to $Env:KUBECONFIG='<path to config file downloaded in previous step>'
)
Bash:
export KUBECONFIG=<path to config file downloaded in previous step>
Make sure your resources are healthy: kubectl get pods -A
Everything should be in "Running" State. Mine looked like this:
Steps
- Get the Grafana pod name. In Powershell use
kubectl get pods -n monitoring -o name | select-string grafana
and in bash terminals usekubectl get pods -n monitoring -o name | grep grafana
- Create a port forward session to the Grafana pod which is exposed on port 3000:
kubectl port-forward --namespace monitoring <pod name> <local port>:3000
- Access the Grafana web application in a browser at:
http://localhost:<local port>
Here are the steps from my testing in action:
In the browser you should see the Grafana log in screen, something like the below:
Log in with default credentials:
username: admin, password: prom-operator
Obviously these are insecure and the kubernetes default should not be used for anything other than testing
Once you're logged in there is a plethora of available dashboards out of the box to explore. You can also create your own!
clicking the "Home" button at the top gies you a list:
Wrap-Up
You probably want to kill your proxy so it's not running, you can always use the same steps to turn it back on. Simply Ctrl-C
in the terminal with the port forward running to stop it.