Deploy the hadoop-deployment helm chart on Opensshift
TypeScriptTo deploy a Helm chart on an OpenShift cluster using Pulumi, you'll be working with the Kubernetes provider for Pulumi. Specifically, you will utilize the
Chart
resource which represents a Helm chart in Pulumi's Kubernetes SDK.The
Chart
resource is a higher-level construct that doesn't require you to work with the low-level details of Kubernetes API objects directly. It works similarly to howhelm install
orhelm upgrade
work with Helm CLI. When using theChart
resource, Pulumi will make sure to apply the chart in your OpenShift cluster in the desired state described in your Pulumi program.Here is a step-by-step guide and a TypeScript program that deploys the
hadoop-deployment
Helm chart on an OpenShift cluster:-
Setting Up Your Pulumi Program: Ensure that you have Pulumi installed and configured with access to your OpenShift cluster. This typically involves setting up the
KUBECONFIG
environment variable so that Pulumi can communicate with your cluster. -
Creating the Pulumi Project: You'll start by creating a new directory for your Pulumi project and running
pulumi new kubernetes-typescript
within that directory. This command creates a new Pulumi project with a sample program in TypeScript. -
Writing the Program: Replace the contents of
index.ts
with the code provided below. This represents your Pulumi program. -
Deploying the Chart: You'll run
pulumi up
to preview and deploy the changes to your OpenShift cluster. After confirmation, Pulumi will reach out to the cluster and deploy the Helm chart. -
Observing the Deployment: Once the command completes, you can check the resources in your OpenShift cluster to confirm that the
hadoop-deployment
chart has been deployed.
Below is a Pulumi TypeScript program that deploys a Helm chart named
hadoop-deployment
to an OpenShift cluster:import * as k8s from '@pulumi/kubernetes'; // Create a Kubernetes provider instance that uses our existing cluster configuration. const provider = new k8s.Provider('openshift', { // Assumes the current context in your KUBECONFIG is set to the OpenShift cluster. // Otherwise, specify the kubeconfig or context for the provider. }); // Define the settings for the Helm chart deployment. const hadoopChart = new k8s.helm.v3.Chart('hadoop-deployment', { // If the chart is from a Helm repo, specify `repo` and `chart` values. // In this case, we are deploying a chart called `hadoop-deployment` which should // be replaced with the actual chart name you want to deploy. chart: 'hadoop-deployment', // Replace with the correct namespace if needed, otherwise default will be used. namespace: 'default', // You can specify the chart values here, similar to how you would use // the `-f` flag with helm to provide a values.yaml file. values: { // Suppose your Helm chart has these configurable values. // You can define them as needed for your specific chart. replicaCount: 2, service: { type: 'ClusterIP', }, // ...other values... }, // Specify the version of your chart if you want to lock in a particular version. version: '1.2.3', }, { provider }); // Export any required stack outputs. export const chartName = hadoopChart.metadata.name;
This Pulumi program imports the Kubernetes SDK, sets up a provider to your OpenShift cluster, and then uses the
Chart
resource to declare the desired state, which is to have thehadoop-deployment
Helm chart deployed in the namespacedefault
.It is important that the
hadoop-deployment
Helm chart exists either in a Helm repository or in your file system if you reference it by local path. You will also need to replace theversion
andvalues
in thehadoopChart
with the values appropriate for your specific chart.Note: Before you run
pulumi up
, make sure you have access to your OpenShift cluster viakubectl
oroc
.Remember, managing infrastructure as code with Pulumi is declarative; the Pulumi program defines the desired state and Pulumi makes the cloud environment match that desired state.
After deploying the Helm chart, you can manage its lifecycle using
pulumi
commands. For instance:- To update the chart, you would modify the
values
orversion
fields and runpulumi up
again. - If you want to delete the chart, you would remove the code that defines the
hadoopChart
resource and runpulumi up
, or runpulumi destroy
to delete all resources in the stack.
More detailed documentation on using Helm charts with Pulumi can be found here.
-