vSphere Supervisor - Migrating Grafana PKGI to Helm
search cancel

vSphere Supervisor - Migrating Grafana PKGI to Helm

book

Article ID: 390111

calendar_today

Updated On:

Products

VMware vSphere Kubernetes Service vSphere with Tanzu Tanzu Kubernetes Runtime

Issue/Introduction

This KB article is written to provide instructions for moving Grafana as a package install (PKGI) on a vSphere Kubernetes cluster to a Helm deployment.

Please note that this KB article does not apply to Grafana as a Supervisor service.

 

The grafana package is removed in the VKS Standard Package Repository v1.23.

It is recommended to move Grafana to a Helm deployment prior to using the v1.23 VKS Standard Package Repository.

Environment

vSphere Supervisor

Workload Cluster using VKS standard packages v1.22 and earlier

Cause

The Grafana package was removed from the VKS Standard Package Repository starting in VKS-Standard-Packages version v1.23.

Resolution

High Level Steps

  1. Export the Grafana Dashboard
  2. Delete the existing Grafana package deployment
  3. Configure the Helm Grafana values.yaml
  4. Re-install Grafana through Helm
  5. Access the Grafana UI
  6. Import the Grafana Dashboard

 

Export the Grafana Dashboard

Each dashboard will need to be exported individually.

  1. Login to the Grafana web UI

  2. Navigate to the dashboard to export

  3. Click on the "Share dashboard or panel" button  and save the dashboard to a file:


  4. Open the exported Grafana dashboard file and note down the data source UID:
    • "datasource": {

             "type": "prometheus",

            "uid": "a1b23cde-4567-8fg9-h011-i1j2k3l4m5n6"

             "type": "prometheus"

             },
  5. Remove all instances of the data source UID in the exported Grafana dashboard file:
    • Note: Grafana does not support duplicate UIDs. This step is to remove all references of the UID to avoid potential duplicate UID conflicts on import.
    • "datasource": {

             "type": "prometheus",

            "uid": "a1b23cde-4567-8fg9-h011-i1j2k3l4m5n6"

             "type": "prometheus"



             },
      "targets": [
               {
                 "datasource": {
                 "type": "prometheus",
                 "uid": "a1b23cde-4567-8fg9-h011-i1j2k3l4m5n6"
                 "type": "prometheus"
                 },
                 "refId": "A"
               }

 

Delete the Existing Grafana Package Deployment

  1. Connect to the vSphere Kubernetes cluster context where the Grafana PKGI is installed

  2. Delete the Grafana PKGI using the tanzu CLI:

    • tanzu package installed list 
    • tanzu package installed delete <grafana package name> -y
  3. Confirm that the Grafana PKGI was deleted successfully:
    • tanzu package installed list
    • kubectl get all -n <grafana package namespace>

 

Configure the Helm Grafana values.yaml

  1. Download the Helm chart Grafana values.yaml:
  2. Optional: Edit the values.yaml to use NodePort, as necessary:
    • service:
      enabled: true
      type: NodePort
  3. Edit the values.yaml to set up persistent storage, replacing "CHANGE-ME" with the desired storage class available in the cluster:
    • While connected to the vSphere Kubernetes cluster context, the following kubectl CLI command can be run to list all storageclasses available in the cluster:
      • kubectl get sc -A
    • persistence:

        type: pvc

        enabled: true

       storageClassName: CHANGE-ME

        accessModes:

          - ReadWriteOnce

        size: 10Gi

  4. Edit the values.yaml to include the exported datasource, the below example datasource is Prometheus:
    • datasources: 

        datasources.yaml:

          apiVersion: 1

          datasources:

          - name: Prometheus

            type: prometheus

            url: http://prometheus-server.tanzu-system-monitoring.svc.cluster.local

            access: proxy

            isDefault: true



        datasources:

          enabled: true

       

Re-install Grafana through Helm

  1. Connect into the vSphere Kubernetes cluster context to re-install Grafana through Helm

  2. Create the namespace to deploy Grafana into:
    • kubectl create namespace <grafana-namespace-name>
  3. Label the above namespace to bypass built-in PSA:
    • Note: The following label bypasses PSA setup in the cluster. This namespace should be configured with proper PSA according to your cluster's security needs.
    • kubectl label ns <grafana-namespace-name> pod-security.kubernetes.io/enforce=privileged
  4. Install Helm with the edited values.yaml from the previous section:
    • helm install <grafana chart name> grafana/grafana --namespace <grafana-namespace-name> --values values.yaml
    • Explanation of arguments:
      • helm install: Installs the chart by deploying it on the Kubernetes cluster
      • <grafana chart name>: The logical chart name that you provided
      • grafana/grafana: The repository and package name to install
      • --namespace: The Kubernetes namespace (<grafana-namespace-name>) where you want to deploy the chart
      • --values: The YAML file to pull values from
  5. Monitor and allow for the deployment to complete:
    • helm list -n <grafana-namespace-name>
    • kubectl get all -n <grafana-namespace-name>
  6. If you encounter issues, check the deployment's logs and refer to the Grafana Troubleshooting community documentation

 

Access the Grafana UI

  1. Connect to the vSphere Kubernetes cluster context where Grafana was installed successfully through Helm

  2. The following command will provide information on how to access the Grafana service in a web browser:
    • helm get notes <grafana chart name> -n <grafana-namespace-name>
  3. Retrieve the Grafana admin password:
    • kubectl get secret --namespace <grafana-namespace-name> <grafana chart name> -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
  4. Export the node port and node IP for the Grafana Helm deployment and echo the address:
    • export NODE_PORT=$(kubectl get --namespace <grafana-namespace-name> -o jsonpath="{.spec.ports[0].nodePort}" services <grafana chart name>)
    • export NODE_IP=$(kubectl get nodes --namespace <grafana-namespace-name> -o jsonpath="{.items[0].status.addresses[0].address}")
    • echo http://$NODE_IP:$NODE_PORT

 

Import the Grafana Dashboard

  1. Access the Grafana UI in a web browser as per the above section
  2. Add a new data source:
  3. Save & Test to confirm functionality of the new data source:
  4. Navigate to Dashboards and select Import dashboard:
  5. Confirm that the dashboard imported successfully

Additional Information

If the VKS Standard Package is upgraded to v1.23 before migrating Grafana PKGI into a Helm deployment, the Grafana PKGI will be in Reconcile Failed state.

 

Grafana can be re-installed through Helm using default values initially then later configured with the edited values.yaml through the following steps:

  1. Connect into the vSphere Kubernetes context to re-install Grafana through Helm

  2. Create a namespace to install Grafana into:
    • kubectl create namespace <grafana-namespace-name>
  3. Confirm that the namespace was successfully created:
    • kubectl get ns
  4. Search through helm for the grafana repository:
    • helm search repo grafana/grafana
  5. Install the Grafana Helm Chart in the namespace created in Step 2 above with the desired version found in the previous step:
    • helm install <grafana chart name> grafana/grafana --namespace <grafana-namespace-name> --version <chart version>
    • Explanation of arguments:

      • helm install: Installs the chart by deploying it on the Kubernetes cluster
      • <grafana chart name>: The logical chart name that you provided
      • grafana/grafana: The repository and package name to install
      • --namespace: The Kubernetes namespace (<grafana-namespace-name>) where you want to deploy the chart
      • --version string: Specify a version constraint for the chart version to use. This constraint can be a specific tag (e.g. 1.1.1) or it may reference a valid range (e.g. ^2.0.0). If this is not specified, the latest version is used
  6. Monitor the deployment and allow for it to complete:
    • helm list -n <grafana-namespace-name>
    • NAME                   NAMESPACE                    REVISION     UPDATED                        STATUS          CHART           APP VERSION 
      <grafana chart name>   <grafana-namespace-name>      1           YYYY-MM-DD HH:MM:SS +0000 UTC deployed        grafana-X.X.X   XX.X.X
    • kubectl get all -n <grafana-namespace-name>
  7.  Apply the values.yaml edited in the above section "Configure the Helm Grafana values.yaml" where values.yaml is the name of the edited values.yaml file:
    • helm upgrade <grafana chart name> grafana/grafana -f values.yaml -n <grafana-namespace-name>
  8. If you encounter issues, check the deployment's logs and refer to the Grafana Troubleshooting community documentation