How to Install Grafana-Prometheus on Azure Kubernetes Service

Çiğdem Kadakoğlu
4 min readFeb 21

--

AKS-Grafana-Prometheus-Azure-Helm

Hi everyone,

I’ll show you how to install the grafana-prometheus stack for existing AKS in this article.

Let’s begin by importing the helm repo into our Azure DevOps repository. Because of versions and changes, we must import the existing version into our own repository to avoid problems later.

kadakoglucigdem

Import → https://github.com/prometheus-community/helm-charts/tree/main

kadakoglucigdem

This process may take some time.

kadakoglucigdem

When this process is complete, you will be able to select the main branch by default. Because we’ll be following the main branch.

kadakoglucigdem

Now it’s time to create our azure-pipelines yaml file!

kadakoglucigdem

Pipelines → Create Pipeline

Azure Repos Git →

kadakoglucigdem

Prometheus Community →

kadakoglucigdem

Starter Pipeline →

kadakoglucigdem

Now we can edit the pipeline. Make sure that you have a connection for AKS.

First, we’ll create a namespace called monitoring. Let’s add it with the Kubernetes task.

- task: Kubernetes@1
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceEndpoint: 'aks-connection'
command: 'create'
arguments: 'namespace monitoring'

Installing our chart with the helm is the next step.

- task: HelmDeploy@0
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceConnection: 'aks-connection'
namespace: 'monitoring'
command: 'install'
chartType: 'FilePath'
chartPath: 'charts/kube-prometheus-stack'
releaseName: 'prometheus'
arguments: '--dependency-update'

The “ — dependency-update” argument is important here; because it also allows other dependencies to be installed.

Click the “Save&Run” button.

kadakoglucigdem

By default, the Grafana service uses ClusterIP. Change this to open our service from our repository.

Let’s make the following update to line 894 in the values.yaml file for charts/kube-prometheus-stack.

kadakoglucigdem

The upgrade task should now be added to our pipeline.

- task: HelmDeploy@0
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceConnection: 'aks-connection'
namespace: 'monitoring'
command: 'upgrade'
chartType: 'FilePath'
chartPath: 'charts/kube-prometheus-stack'
releaseName: 'prometheus'
arguments: '--dependency-update'

The other 2 tasks can be disabled so that we can run the pipeline again.

kadakoglucigdem

As you can see, it has been upgraded.

Here, you may view the IP reserved for Grafana through the Azure Portal or via the pipeline.

The default username and password for Grafana are as follows:

username : admin

password : prom-operator

If you’d like, you can modify them on the chart.

kadakoglucigdem

After logging in, you can see that the Dashboards tab has a lot of dashboards already installed.

kadakoglucigdem

Here is our final YAML file:

trigger:
- none

pool:
vmImage: ubuntu-latest

steps:
- task: Kubernetes@1
enabled: false
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceEndpoint: 'aks-connection'
command: 'create'
arguments: 'namespace monitoring'

- task: HelmDeploy@0
enabled: false
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceConnection: 'aks-connection'
namespace: 'monitoring'
command: 'install'
chartType: 'FilePath'
chartPath: 'charts/kube-prometheus-stack'
releaseName: 'prometheus'
arguments: '--dependency-update'

- task: HelmDeploy@0
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceConnection: 'aks-connection'
namespace: 'monitoring'
command: 'upgrade'
chartType: 'FilePath'
chartPath: 'charts/kube-prometheus-stack'
releaseName: 'prometheus'
arguments: '--dependency-update'

Hope you find my article helpful. I wish everyone an awesome day!

Pray for Turkiye 🙏🏻

--

--

Çiğdem Kadakoğlu

Senior Cloud&DevOps Engineer | Instructor | Docker Captain | Azure Solutions Architect | CK{A|AD}-AZ{104|204|305|400|800|801|900}-DP900🐧🐳🌼☕🍋🦆🐙