Installing Grafana with ingress

Danushka Fernando
2 min readOct 12, 2019

--

If you are deploying Prometheus and Grafana in Kubernetes, easiest way would be to use helm charts. But when you are deploying the helm chart, You will need to provide custom parameters mainly for storage configuration and service configuration to expose Grafana UI to outsiders.

In this blog I will share the artifacts I used in the AWS EKS. But if someone wants to change it to use in any other platform or a custom installation, just change the ingress annotations and you will be good.

For the basic installation I used eks workshop[1] to start with. Here everything is provided in command line. Instead I used yaml files and used the file with -f option of the helm command. My sample helm command would be like below.

helm install --name promethues stable/prometheus -f prometheus.yaml --namespace prometheus

My prometheus.yaml will be like below. Here I haven’t changed anything from eks workshop other than taking everything to yaml file. But if you intend to change something you can do so by adding more content to this yaml according to the structure of prometheus values.yaml[2].

alertmanager:
persistentVolume:
storageClass: "gp2"
server:
persistentVolume:
storageClass: "gp2"

Tricky part would be to adding ingress to Grafana installation. I obviously followed the same path. I just customized values according to values.yaml of Grafana Helm chart[3].

Here some important notes are ingress.enabled should set to true. And then ingress.path should set to “/*” support Grafana UI. Other annotations set here are to support ALB ingress controller and to enable SSL to ALB and to use External DNS with Route 53. But if you are using some other cloud service or on premise installation then remove them and use your annotations.

Another important thing is I set to persistence enabled and I removed admin password so password will be generated at the deployment time.

And you can customize any other thing following format of the values.yaml of the chart.

persistence:
storageClassName: "gp2"
enabled: true
ingress:
enabled: true
path: /*
annotations:
alb.ingress.kubernetes.io/scheme: internet-facing
kubernetes.io/ingress.class: alb
alb.ingress.kubernetes.io/certificate-arn: arn:aws:iam::xxxxxxxxx:server-certificate/aws
alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS":443}]'
alb.ingress.kubernetes.io/actions.ssl-redirect: '{"Type": "redirect", "RedirectConfig": { "Protocol": "HTTPS", "Port": "443", "StatusCode": "HTTP_301"}}'
external-dns.alpha.kubernetes.io/hostname: grafana.xxxx.xxx.xxx
service:
annotations:
alb.ingress.kubernetes.io/target-type: ip
datasources:
datasources.yaml:
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
url: http://prometheus-server.prometheus.svc.cluster.local
access: proxy
isDefault: true

You can find the Grafana admin password by executing following command.

kubectl get secret --namespace grafana grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo

Hope this helps!!!.

References

[1] https://eksworkshop.com/monitoring/

[2] https://github.com/helm/charts/blob/master/stable/prometheus/values.yaml

[3] https://github.com/helm/charts/blob/master/stable/grafana/values.yaml

--

--