Deploy the autospotting helm chart on Azure Managed Openshift Service
TypeScriptTo deploy the Autospotting Helm chart on Azure Managed OpenShift Service using Pulumi, we will need to carry out the following steps:
- Provision an Azure Managed OpenShift cluster.
- Install the Helm chart for Autospotting on the managed OpenShift cluster.
We'll be leveraging two key resources from the
azure-native
andkubernetes
Pulumi packages in this program:azure-native.containerservice.OpenShiftManagedCluster
: Creates and manages an Azure Red Hat OpenShift Managed Cluster.kubernetes.helm.v3.Chart
: Allows deploying Helm charts to a Kubernetes cluster (in our case, the managed OpenShift cluster).
Here's how the Pulumi TypeScript program would look:
import * as pulumi from "@pulumi/pulumi"; import * as azure_native from "@pulumi/azure-native"; import * as k8s from "@pulumi/kubernetes"; import * as azuread from "@pulumi/azuread"; const config = new pulumi.Config(); const resourceGroupName = config.require("resourceGroupName"); const location = config.require("location"); const clusterName = config.require("clusterName"); const appId = config.require("appId"); const password = config.require("password"); const tenantId = config.require("tenantId"); // Step 1: Provision an Azure Managed OpenShift cluster const openshiftManagedCluster = new azure_native.containerservice.OpenShiftManagedCluster(clusterName, { resourceName: clusterName, resourceGroupName: resourceGroupName, location, openShiftVersion: "v3.11", // Replace with the desired OpenShift version networkProfile: { vnetCidr: "10.0.0.0/8", }, masterPoolProfile: { count: 3, // 3 master nodes for high availability vmSize: "Standard_D4s_v3", // Replace with the desired VM size }, agentPoolProfiles: [{ name: "agentpool", count: 3, vmSize: "Standard_D4s_v3", // Replace with the desired VM size osType: "Linux", role: "compute", }], authProfile: { identityProviders: [{ name: "Azure AD", provider: { clientId: appId, clientSecret: password, tenantId: tenantId, }, }], }, }); // Step 2: Install the Helm chart for Autospotting on the managed OpenShift cluster const autospottingChart = new k8s.helm.v3.Chart("autospotting", { chart: "autospotting", version: "0.1.0", // Replace with the correct chart version fetchOpts: { repo: "https://autospotting.io/helm", // Replace with the actual Helm repository URL }, }, { provider: openshiftManagedCluster }); // Exports (if needed) export const clusterId = openshiftManagedCluster.id; export const autospottingChartName = autospottingChart.metadata.name;
In the above code, we create an instance of
OpenShiftManagedCluster
that provisions an Azure OpenShift cluster with three master nodes for high availability and a three-node agent pool for running workloads. This cluster uses Azure Active Directory for authentication.Once the cluster is ready, we deploy the Autospotting Helm chart using the
Chart
resource from Pulumi's Kubernetes package. We don't need to set up a Kubernetes provider explicitly as we are assuming the Kubernetes cluster being targeted is the same one where the Pulumi program is executed ({ provider: openshiftManagedCluster }
).To use this Pulumi program, you will need to:
- Install Pulumi.
- Configure Azure credentials using
az login
or by setting theARM_CLIENT_ID
,ARM_CLIENT_SECRET
, andARM_TENANT_ID
environment variables. - Create a Pulumi stack with
pulumi stack init
. - Set the required configuration for the OpenShift cluster using
pulumi config set
. - Run
pulumi up
to create the resources.
Please ensure that you replace placeholders such as the agent pool's
vmSize
, and theversion
, andrepo
in theChart
resource with the appropriate values for your use case. Make sure that the OpenShift version and VM sizes specified are supported by Azure at the time you are deploying.