Deploy the banzaicloud-logging-operator-monitoring helm chart on Azure Managed Openshift Service
TypeScriptTo deploy the
banzaicloud-logging-operator-monitoring
Helm chart on an Azure Managed OpenShift service using Pulumi, you will follow these steps:- Create an OpenShift Managed Cluster in Azure.
- Deploy the Helm chart to the OpenShift cluster.
We'll use two Pulumi resources from the
azure-native
andkubernetes
packages to achieve this. Theazure-native.containerservice.OpenShiftManagedCluster
resource will represent the Azure OpenShift Managed Cluster. Thekubernetes.helm.v3.Chart
(from the@pulumi/kubernetes
package) resource will be used to deploy the Helm chart on the cluster once it's up and running.Here is the TypeScript program that accomplishes this deployment:
import * as pulumi from "@pulumi/pulumi"; import * as azure_native from "@pulumi/azure-native"; import * as k8s from "@pulumi/kubernetes"; // Step 1: Set up the Azure Managed OpenShift Cluster // Create a new resource group if you don't have one already const resourceGroupName = "openshiftResourceGroup"; const resourceGroup = new azure_native.resources.ResourceGroup(resourceGroupName); // Specify the location to deploy the resources const location = "West Europe"; // Create the OpenShiftManagedCluster const clusterName = "myManagedOpenShiftCluster"; const openshiftManagedCluster = new azure_native.containerservice.OpenShiftManagedCluster(clusterName, { resourceGroupName: resourceGroup.name, // See more options in the docs: https://www.pulumi.com/registry/packages/azure-native/api-docs/containerservice/openshiftmanagedcluster/ location, openShiftVersion: "v3.11", networkProfile: { // Add your network details here vnetId: "/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet1", peerVnetId: "/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet2", }, masterPoolProfile: { name: "master", count: 3, vmSize: "Standard_D4s_v3", }, // More properties here... }); // Step 2: Deploy the banzaicloud-logging-operator-monitoring Helm chart // Retrieve the Kubeconfig from the created OpenShift cluster to set up the Kubernetes Provider const kubeconfig = openshiftManagedCluster.kubeconfig.apply(cfg => Buffer.from(cfg, "base64").toString()); // Create a Kubernetes provider instance using the Kubeconfig from the OpenShift cluster const k8sProvider = new k8s.Provider("k8sProvider", { kubeconfig, }); // Deploy the banzaicloud-logging-operator-monitoring Helm chart on the created cluster const loggingOperatorMonitoringChart = new k8s.helm.v3.Chart("banzaicloud-logging-operator-monitoring", { chart: "banzaicloud-logging-operator-monitoring", version: "3.9.4", // Specify the chart version you want to deploy // Replace 'repoURL' with the URL where the chart is hosted repositoryOpts: { repo: "https://banzaicloud.com", }, // Provide values for the Helm chart or use a values file values: { // Specify the values according to the Helm chart you are deploying }, }, { provider: k8sProvider }); // Export the cluster's Kubeconfig export const kubeConfig = kubeconfig;
Explanation
- Resource Group: The
ResourceGroup
resource in this program is created to organize all related Azure resources for the OpenShift cluster. - OpenShift Managed Cluster: The
OpenShiftManagedCluster
is the core resource that represents the OpenShift cluster on Azure. You'll need to adjust properties likeopenShiftVersion
,networkProfile
,agentPoolProfiles
, etc., according to your specific requirements. - Kubernetes Provider: The Kubeconfig output of
OpenShiftManagedCluster
is converted from a base64 string to a regular string and is used to create an instance ofk8s.Provider
. This is required for Pulumi to communicate with your Kubernetes cluster. - Helm Chart: The
Chart
resource is where thebanzaicloud-logging-operator-monitoring
Helm chart is applied to the Kubernetes cluster. Replaceversion
,repositoryOpts
, andvalues
with appropriate values for your deployment. The chart resources will be created, managed, and versioned in sync with your deployment lifecycle by Pulumi. - Kubeconfig Export: Finally, the program exports the kubeconfig needed to interact with the Kubernetes cluster, so you can use
kubectl
or other Kubernetes tools with your new OpenShift cluster.
When running this Pulumi program, ensure that you have the necessary Azure credentials configured in your environment, and you have installed the
@pulumi/azure-native
and@pulumi/kubernetes
packages. To actually execute the deployment, you would runpulumi up
from your command line in the directory where this Pulumi program is saved.