Deploy the elasticsearch-exporter helm chart on Azure Managed Openshift Service
TypeScriptTo deploy the
elasticsearch-exporter
Helm chart on an Azure Managed OpenShift Service, you will need to perform the following steps:-
Set up Azure Managed OpenShift Cluster: This involves creating an OpenShift cluster in Azure. The
azure-native.containerservice.OpenShiftManagedCluster
resource is used for this purpose. -
Install the Helm Chart: Once the OpenShift cluster is ready, you can deploy the
elasticsearch-exporter
Helm chart using thekubernetes.helm.v3.Chart
resource, which is designed to work with the Helm package manager on a Kubernetes cluster.
Below is a detailed Pulumi program in TypeScript that demonstrates the steps to perform above tasks. The code assumes that you have the necessary permissions to create resources in Azure and that you are logged into the Azure CLI.
import * as azureNative from "@pulumi/azure-native"; import * as kubernetes from "@pulumi/kubernetes"; import * as pulumi from "@pulumi/pulumi"; // Step 1: Create an Azure Managed OpenShift Cluster const resourceGroup = new azureNative.resources.ResourceGroup("myResourceGroup"); const openShiftCluster = new azureNative.containerservice.OpenShiftManagedCluster("myOpenShiftCluster", { resourceGroupName: resourceGroup.name, openShiftVersion: "4.3", // Specify your desired OpenShift version // Define the network profile networkProfile: { vnetCidr: "10.0.0.0/8", }, // Define the master and worker node profiles masterPoolProfile: { name: "master", count: 3, vmSize: "Standard_D4s_v3", }, agentPoolProfiles: [{ name: "worker", count: 3, role: "compute", vmSize: "Standard_D4s_v3", }], // ... other necessary configuration ... }, { dependsOn: resourceGroup }); // Fetch the Kubeconfig once the cluster is created to configure Kubernetes provider const creds = pulumi.all([resourceGroup.name, openShiftCluster.name]).apply(([resourceGroupName, clusterName]) => azureNative.containerservice.listOpenShiftManagedClusterAdminCredentials({ resourceGroupName: resourceGroupName, resourceName: clusterName, }) ); const kubeconfig = creds.apply(c => c.kubeconfigs[0].value); // Step 2: Install the Elasticsearch Exporter Helm Chart const elasticsearchExporterChart = new kubernetes.helm.v3.Chart("elasticsearch-exporter", { chart: "elasticsearch-exporter", version: "1.14.3", // specify the version of the chart you wish to deploy fetchOpts: { repo: "https://prometheus-community.github.io/helm-charts", }, // Define values for the Helm chart here values: { // ... include any specific configuration here ... } }, { provider: new kubernetes.Provider("k8sProvider", { kubeconfig }) }); // Export the OpenShift Managed Cluster's name and the Helm chart status export const openShiftClusterName = openShiftCluster.name; export const elasticsearchExporterChartStatus = elasticsearchExporterChart.status;
Explanation
-
We define the
resourceGroup
to be used for all resources and theOpenShiftManagedCluster
to create an Azure Managed OpenShift Cluster. Note that you must specify theopenShiftVersion
,masterPoolProfile
, andagentPoolProfiles
with the desired configuration. -
Next, we use a dynamic
kubeconfig
obtained from the newly created OpenShift cluster, which is required to interact with the cluster using Kubernetes commands. -
We then create a new
Chart
resource, which represents the elasticsearch-exporter Helm chart. Specify the chart name, version, and repository URL asfetchOpts
. -
The provider
k8sProvider
uses the dynamickubeconfig
. This step is critical to ensure that Pulumi uses the correct context to interact with the Kubernetes cluster hosted in Azure. -
Finally, we export some of the essential outputs like the OpenShift cluster's name and the Helm chart status for easy access and visibility.
Make sure to replace the placeholder values for the chart version, repository, and any other relevant values with those specific to your needs. Once you complete this Pulumi program, you can run it with Pulumi CLI commands such as
pulumi up
to provision the resources.Ensure that you have Pulumi installed and setup correctly, and you are logged into the Azure CLI to be able to authenticate the deployment requests.
-