Deploy the postgres-with-operator helm chart on Azure Managed Openshift Service
TypeScriptTo deploy a Helm chart on Azure Managed OpenShift, you'll use the Pulumi
kubernetes
package to interact with your Kubernetes cluster and manage the deployment. Before you can deploy the Helm chart, you need an existing OpenShift cluster. We'll also need to ensure we have access to it by setting the appropriate context.Here's a step-by-step approach to accomplish this:
-
Set up an OpenShift cluster: You would typically use the
azure-native.containerservice.OpenShiftManagedCluster
Pulumi resource to create an Azure Managed OpenShift Cluster. However, this step is quite involved and would require a number of settings like network profiles, authentication profiles, etc., that are specific to your environment. Given that the cluster setup is out of the scope for this guide, let's assume you already have a cluster running and have the necessarykubeconfig
file to access it. -
Configure access to the cluster: Make sure your
kubeconfig
file is correctly set up, and Pulumi can access the OpenShift cluster by using theKUBECONFIG
environment variable or by ensuring the default kubeconfig file (~/.kube/config
) has the correct context set as the current context. -
Deploy the Helm chart: We will use the Pulumi
kubernetes.helm.v3.Chart
resource to deploy the PostgreSQL Helm chart.
Assuming you have the cluster ready and
kubeconfig
in place, let's look at the Pulumi TypeScript code that would deploy thepostgres-with-operator
Helm chart:import * as k8s from "@pulumi/kubernetes"; // Replace these variables with the appropriate values for your setup. const clusterName = "my-openshift-cluster"; const chartName = "postgres-with-operator"; const chartRepo = "example-repo"; // The Helm chart repository where `postgres-with-operator` exists. const chartVersion = "x.y.z"; // The version number of the chart you want to deploy. // You can specify more detailed configurations for your PostgreSQL deployment in this object. const postgresChartValues = { // The values that the Helm chart accepts for configuring PostgreSQL. // Check the Helm chart's values.yaml file for the full list of configurable options. }; const postgresqlChart = new k8s.helm.v3.Chart(chartName, { chart: chartName, version: chartVersion, fetchOpts: { repo: chartRepo, }, values: postgresChartValues, }); export const chartStatus = postgresqlChart.status;
Now let's break down what the main parts of this script are doing:
- We import the Kubernetes package from Pulumi, which allows us to interact with Kubernetes clusters and their resources.
- We define variables for values that you need to specify based on your own setup, such as the chart name, Helm repository, and specific version of the chart.
- We create an instance of
k8s.helm.v3.Chart
, which represents the Helm chart we wish to install. This resource requires the name of the chart, the repository where it's located, and optionally, a specific version and custom values. - Lastly, we export the status of the Helm chart, which can be used to check the deployment's success or failure after running the Pulumi program.
To run this Pulumi program, follow these general steps:
- Ensure Pulumi CLI is installed and you're logged in to the Pulumi service (or configured for local or alternative state storage).
- Ensure the Azure CLI is installed and you're logged in to your Azure account with
az login
. - Make sure your OpenShift cluster is up and running, and you have
kubeconfig
set up on your local machine. - Save the TypeScript code in a file named
index.ts
. - Run
pulumi up
in the directory where you saved yourindex.ts
to initiate the deployment. - Check the outputs and if the deployment is as expected, confirm the update to proceed and let Pulumi apply the changes.
Please replace placeholder strings like
example-repo
and the chart versionx.y.z
with the actual values for the PostgreSQL Helm chart you want to deploy. The Helm repository URL should be structured ashttps://my-charts.example.com/
based on where thepostgres-with-operator
chart is hosted.Remember that using Helm charts and OpenShift involves understanding the particular settings and parameters that your chosen Helm chart and OpenShift cluster setup may require. Always review the documentation for a Helm chart to understand the configurable values and expected behavior.
Lastly, Helm itself must be installed on your system where you run Pulumi commands, as it uses the Helm binary for some operations like fetching charts from repositories.
-