Deploy the ververica-sql-template helm chart on Azure Managed Openshift Service
TypeScriptDeploying a Helm chart on an Azure Managed OpenShift Service using Pulumi involves several steps. We will go through the process step-by-step to help you understand how to accomplish this task. We'll use the Pulumi TypeScript language, as it is both expressive and widely used.
Overview
-
Set up an Azure Managed OpenShift Service: Before deploying any applications, you'll need to have an OpenShift cluster running. Pulumi allows you to define such a service declaratively using the
azure-native.containerservice.OpenShiftManagedCluster
resource. -
Deploy the Helm Chart: Once the cluster is set up, you can deploy applications to it using Helm charts. The
kubernetes.helm.v3.Chart
resource from the Pulumi Kubernetes provider will be used for this purpose.
Prerequisites
Ensure you have the following installed:
- Pulumi CLI
- Azure CLI
- kubectl (if interacting with the Kubernetes cluster directly)
Authenticate with Azure CLI and set up the necessary credentials for Pulumi to communicate with Azure. Also, have the Helm chart details ready, including the repository and chart name.
The Pulumi Program
Below is the full Pulumi TypeScript program to deploy an Azure Managed OpenShift Service and then deploy a Helm chart to it.
import * as pulumi from "@pulumi/pulumi"; import * as azureNative from "@pulumi/azure-native"; import * as k8s from "@pulumi/kubernetes"; // Step 1: Set up the Azure Managed OpenShift Service const managedCluster = new azureNative.containerservice.OpenShiftManagedCluster("myOpenShiftManagedCluster", { // Replace these with your specific values resourceGroupName: "myResourceGroup", location: "West US", openShiftVersion: "4.3", // Specify the OpenShift version // Define the network profile, master and agent pool profiles as per your requirements // Refer to the azure-native.containerservice.OpenShiftManagedCluster documentation for full options }); // Export the kubeconfig of the Managed Cluster export const kubeconfig = managedCluster.kubeconfig; // Step 2: Assuming the managed cluster is up and running, create a provider for it const openshiftProvider = new k8s.Provider("openshiftProvider", { kubeconfig: managedCluster.kubeconfig, }); // Deploy the ververica-sql-template Helm chart const chart = new k8s.helm.v3.Chart("ververica-sql-template", { chart: "ververica-sql-template", version: "1.0.0", // Replace with the chart version you want to deploy fetchOpts: { repo: "http://myhelmrepo.com", // Replace with the Helm repository URL }, }, { provider: openshiftProvider }); // Export any information that could be useful for interacting with your application export const chartName = chart.metadata.name; export const chartVersion = chart.metadata.version; export const chartNamespace = chart.metadata.namespace;
Explanation
-
We import the necessary Pulumi packages:
@pulumi/pulumi
for core Pulumi features,@pulumi/azure-native
for the Azure-native provider, and@pulumi/kubernetes
for working with Kubernetes. -
We declare an Azure Managed OpenShift Service using the
OpenShiftManagedCluster
resource. We specify the resource group, location, and OpenShift version among other properties. More configurations can be set based on your requirements. -
Once the OpenShift Cluster is created, we export its kubeconfig. This kubeconfig allows you (or the Pulumi program) to communicate with the Kubernetes API server running on OpenShift.
-
We then set up a Pulumi Kubernetes provider using the kubeconfig from our Managed OpenShift Cluster. This provider is required for deploying Kubernetes resources and Helm charts on the cluster.
-
Finally, we deploy the
ververica-sql-template
Helm chart. If this is a custom Helm chart and not available in the Helm community repository, you must provide therepo
URL where the chart is hosted. We pass the OpenShift provider to the Chart resource to ensure it is deployed on the OpenShift cluster. -
We export certain metadata about the deployed Helm chart which might be useful. This includes the name, version, and namespace of the chart.
Next Steps
After running the Pulumi program, you can further interact with your OpenShift cluster using
kubectl
and Helm commands. Make sure you configurekubectl
with the exported kubeconfig from the above program. To view your deployed Helm chart, you can use thehelm list
command, which will show you the deployed charts and their statuses.Remember, this deployment will take some time, as creating managed Kubernetes services involves provisioning resources which can be a lengthy process.
Running the Program
To run this Pulumi program, save the contents to a file named
index.ts
, install the required dependencies withnpm
oryarn
, and runpulumi up
to execute the Pulumi program and perform the deployment. Make sure you have selected the correct Pulumi stack that targets your Azure account.pulumi up
You will be prompted by the Pulumi CLI to confirm the deployment before any resources are created. After the confirmation, Pulumi will provision the Azure Managed OpenShift Service and deploy the specified Helm chart on it.
-