Deploy Metric Insights on Azure Kubernetes Service (AKS)

Architecture Diagram

1. Configure Kubernetes Cluster in Azure Kubernetes Service

1.1. Create New Kubernetes Cluster

Access Microsoft Azure > Kubernetes services > Overview

Under Kubernetes cluster, click [Create].

1.2. Configure Basic Settings

NOTE:

  • Most values can be left at their defaults.
  1. Select Resource group.
  2. Enter Kubernetes cluster name.
  3. Once the basic configuration is finished, click [Next].

1.3. Configure Networking Settings

Keep default networking unless you have requirements for private cluster, custom CNI, or restricted egress. Proceed to [Next].

1.4. Configure Integrations Settings

Review integrations (e.g., Azure Monitor, policy) based on your org standards, then proceed to [Review + create].

1.5. Configure Kubectl to Connect to the Cluster via API

After the cluster is created, configure kubectl to connect to the cluster via API:

  1. Log in to the Azure CLI, or skip this step and log in to the Cloud Shell:
az login
  1. Set the correct subscription (if needed):
az account set --subscription <subscription-id-or-name>
  1. Fetch kubeconfig credentials:
az aks get-credentials --resource-group <rg-name> --name <aks-name> --overwrite-existing
  1. Verify access:
kubectl get nodes

2. Provision Azure Database for MySQL

See MySQL Deployment in Azure for instructions.

3. Provision Shared Storage

For shared persistent storage on AKS, use Azure Files via the Azure Files CSI driver. This provides ReadWriteMany access, which is suitable for multi-node workloads.

First, create a file share that will be mounted to Metric Insights as Persistent Volume Claim. You will pass the PVC name to the Metric Insights installer via: --persistent-volume-claim.

3.1. Create Azure File Share

# Change these four parameters as needed for your own environment AKS_PERS_STORAGE_ACCOUNT_NAME=mystorageaccount$RANDOM 
AKS_PERS_RESOURCE_GROUP=myAKSShare 
AKS_PERS_LOCATION=eastus 
AKS_PERS_SHARE_NAME=aksshare 

# Create a resource group
az group create --name $AKS_PERS_RESOURCE_GROUP --location $AKS_PERS_LOCATION 

# Create a storage account 
az storage account create -n $AKS_PERS_STORAGE_ACCOUNT_NAME -g $AKS_PERS_RESOURCE_GROUP -l $AKS_PERS_LOCATION --sku Standard_LRS 

# Export the connection string as an environment variable, this is used when creating the Azure file share 
export AZURE_STORAGE_CONNECTION_STRING=$(az storage account show-connection-string -n $AKS_PERS_STORAGE_ACCOUNT_NAME -g $AKS_PERS_RESOURCE_GROUP -o tsv) 

# Create the file share 
az storage share create -n $AKS_PERS_SHARE_NAME --connection-string $AZURE_STORAGE_CONNECTION_STRING 

# Get storage account key 
STORAGE_KEY=$(az storage account keys list --resource-group $AKS_PERS_RESOURCE_GROUP --account-name $AKS_PERS_STORAGE_ACCOUNT_NAME --query "[0].value" -o tsv)

# Echo storage account name and key 
echo Storage account name: $AKS_PERS_STORAGE_ACCOUNT_NAME 
echo Storage account key: $STORAGE_KEY

3.2. Create Azure Secret

kubectl create secret generic azure-secret --from-literal=azurestorageaccountname=$AKS_PERS_STORAGE_ACCOUNT_NAME --from-literal=azurestorageaccountkey=$STORAGE_KEY

3.3. Modify YAML to Create Persistent Volume and Persistent Volume Claim

Create a PersistentVolume (PV) and PersistentVolumeClaim (PVC) backed by Azure Files (CSI). The mount options set UID/GID to 33, which matches the service user used by Metric Insights containers. Update the placeholders below:

  • resourceGroup: <AKS_PERS_RESOURCE_GROUP>
  • shareName: <AKS_PERS_SHARE_NAME>
  • volumeHandle: <unique-id> (must be unique in the cluster)

Save as volume.yml and apply:

kubectl apply -f volume.yml

---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: azurefile
spec:
  capacity:
    storage: 200Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  storageClassName: azurefile-csi
  csi:
    driver: file.csi.azure.com
    readOnly: false
    volumeHandle: unique-volumeid  # make sure this volumeid is unique in the cluster
    volumeAttributes:
      resourceGroup: myAKSShare  # optional, only set this when storage account is not in the same resource group as agent node
      shareName: aksshare
    nodeStageSecretRef:
      name: azure-secret
      namespace: default
  mountOptions:
    - dir_mode=0755
    - file_mode=0644
    - uid=33
    - gid=33
    - mfsymlinks
    - cache=strict
    - nosharesock
    - nobrl
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: azurefile
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: azurefile-csi
  volumeName: azurefile
  resources:
    requests:
      storage: 200Gi

Note the PVC name, it will be required for Metric Insights Installer for generating the deployment manifest.

4. Deploy Metric Insights to Kubernetes

4.1. Download Metric Insights Installation Package

4.2. Unpack the Installation Package

tar xvf MetricInsights-Installer-v7.X.X-Lite.tar.gz

4.3. Generate Secrets and Finish Deployment

Run the installer to generate Kubernetes manifests and secret files locally. Then create Kubernetes secrets from the generated files and apply the deployment manifest: kubectl --namespace default apply -f deployment.yml

./installer.py kubernetes --persistent-volume-claim azurefile --db-hostname testkubernetes.mysql.database.azure.com --db-user dashboard_admin --db-password 'enter_your_password_here' -o deployment.yml --images-pull-secret-name metricinsights-docker-registry
CONGRATULATIONS! Configuration and credential files are ready to deploy into Kubernetes.

        Use the following commands to deploy Metric Insights application:
        ...
        $kubectl create namespace default
        $kubectl create secret generic --namespace default metricinsights-mysql-root-password --from-file mysql.secret
        $kubectl create secret generic --namespace default metricinsights-data-analyzer --from-file data-analyzer.env
        $kubectl create secret generic --namespace default metricinsights-dataprocessor --from-file dataprocessor.env
        $kubectl create secret generic --namespace default metricinsights-console --from-file console.env
        $kubectl create secret generic --namespace default metricinsights-image-generator --from-file image-generator.env
        $kubectl create secret generic --namespace default metricinsights-web --from-file web.env
        $kubectl create secret generic --namespace default metricinsights-redis --from-file redis.env
        $kubectl create secret docker-registry --namespace default metricinsights-docker-registry --docker-server docker.metricinsights.com --docker-username <registry login> --docker-password <registry password> --docker-email <[email protected]>
        $kubectl --namespace default apply -f deployment.yml
        $kubectl get deployments --namespace default