1. Deploy the grafana-storage helm chart on Azure Managed Openshift Service

    TypeScript

    To deploy the Grafana storage Helm chart on Azure Managed OpenShift Service using Pulumi, you will follow these general steps:

    1. Set up an Azure Managed OpenShift cluster.
    2. Install the Grafana Helm chart to the OpenShift cluster.

    In this program, we'll be using two main Pulumi resources. Firstly, the azure-native.containerservice.OpenShiftManagedCluster resource from the azure-native provider is used to create and manage an Azure Red Hat OpenShift cluster. Secondly, we'll deploy Grafana using the Helm chart resource kubernetes.helm.v3.Chart from the kubernetes provider, which allows you to deploy Helm charts on your Kubernetes cluster.

    Here's a detailed program that achieves this:

    import * as pulumi from "@pulumi/pulumi"; import * as azureNative from "@pulumi/azure-native"; import * as k8s from "@pulumi/kubernetes"; // Step 1: Create an Azure Managed OpenShift cluster const openShiftManagedCluster = new azureNative.containerservice.OpenShiftManagedCluster("myOpenShiftCluster", { // You need to replace the following with your own details. // Specify the resource group name where the cluster will be created. resourceGroupName: "myResourceGroup", // The location of the resource group. location: "East US", // The name of the OpenShift cluster. resourceName: "myOpenShiftCluster", openShiftVersion: "4.3", // Specify the desired OpenShift version // Define the master and agent pool profiles according to your requirements. masterPoolProfile: { count: 3, // Recommend a minimum of 3 master nodes for HA vmSize: "Standard_D4s_v3", subnetCidr: "10.0.0.0/24", }, agentPoolProfiles: [{ name: "agentpool", count: 3, vmSize: "Standard_D4s_v3", role: "compute", // This indicates the pool is for compute resources }], }); // Wait for the OpenShift cluster to be created and retrieve the kubeconfig. const kubeconfig = pulumi. all([openShiftManagedCluster.name, openShiftManagedCluster.resourceGroupName]). apply(([resourceName, resourceGroupName]) => { return azureNative.containerservice.listOpenShiftManagedClusterAdminCredentials({ resourceName: resourceName, resourceGroupName: resourceGroupName, }); }). apply(credentials => credentials.kubeconfig); // Step 2: Deploy the Grafana storage Helm chart into the OpenShift cluster const grafanaChart = new k8s.helm.v3.Chart("grafana-storage", { // Specify the repository and chart details along with any custom values. chart: "grafana", version: "6.1.9", // Use the version compatible with your requirements. fetchOpts: { repo: "https://grafana.github.io/helm-charts", // Helm repo for Grafana charts }, // Assuming you have a custom `values.yaml` that includes storage configurations. // If you have specific values to override, pass them as an object instead. values: { persistence: { enabled: true, storageClassName: "managed-premium", // Assuming Azure managed-premium storage class size: "10Gi", }, }, }, { provider: new k8s.Provider("k8sProvider", { kubeconfig }) }); // Export the cluster name and Grafana service URL for easy access. export const clusterName = openShiftManagedCluster.name; export const grafanaServiceUrl = grafanaChart.getResourceProperty("v1/Service", "grafana-storage", "status").apply(status => status.loadBalancer.ingress[0].ip);

    Explanation:

    • azure-native.containerservice.OpenShiftManagedCluster: This resource sets up a Managed OpenShift cluster. You have to provide it with configurations such as the location, resource group, and properties for master and agent nodes.

    • Kubeconfig: After the OpenShift cluster is provisioned, we retrieve the kubeconfig, which is necessary to authenticate against the cluster's Kubernetes API server.

    • k8s.helm.v3.Chart: The Chart resource from the Kubernetes package deploys the Helm chart to the cluster. We are deploying the Grafana Helm chart along with custom values for persistence that are suitable for a production environment, such as enabling storage and setting the storage class to Azure's managed-premium.

    • Exports: Finally, the program exports the cluster name and Grafana service URL which you can use to access the Grafana dashboard.

    Make sure to replace any placeholder values with real values fitting your scenario. Before running this program, ensure that you are authenticated with Azure and have the Pulumi CLI installed and configured. To deploy this program, simply use the Pulumi CLI command pulumi up. After confirming the preview, the resources will be provisioned in your Azure account.