Deploy the strimzi-topic-operator helm chart on Rancher
TypeScriptTo deploy the Strimzi topic operator Helm chart on a Kubernetes cluster managed by Rancher, you would first need to ensure that you have a Kubernetes cluster up and running on Rancher. For this Pulumi program, we will assume that you have already created a Kubernetes cluster using Rancher and have access to it.
To interact with your Rancher instance, you'll use the
rancher2
provider in Pulumi, which allows you to manage Rancher 2.x resources. If you don't have therancher2
provider already set up, you will need to configure it with the necessary credentials.The
rancher2
provider doesn't include native support for deploying Helm charts directly, so we'll need to deploy the Helm chart by applying its manifests through Kubernetes resources. To do this, you can fetch the Helm chart's manifests using the Helm CLI, and then apply those manifests using Pulumi'skubernetes
provider.Here's a step-by-step guide on how you would proceed:
-
Install Helm: Make sure you have Helm installed on your local machine, as you'll need it to generate the Kubernetes manifests from the Helm chart.
-
Fetch Helm Chart Manifests: Use Helm to render the Strimzi topic operator Helm chart into raw Kubernetes manifests. You would do this outside of Pulumi using a command line:
helm repo add strimzi https://strimzi.io/charts/ helm template strimzi-topic-operator strimzi/strimzi-kafka-operator > strimzi-topic-operator-manifests.yaml
-
Load Manifests into Pulumi: Read the manifests into your Pulumi program and use the
kubernetes.yaml.ConfigGroup
resource to apply them.
Let's go ahead and write the Pulumi TypeScript program for this:
import * as pulumi from "@pulumi/pulumi"; import * as k8s from "@pulumi/kubernetes"; import * as fs from "fs"; // Read the Kubernetes YAML manifests for the Strimzi topic operator Helm chart. const strimziTopicOperatorManifests = fs.readFileSync("strimzi-topic-operator-manifests.yaml").toString(); // Set up the Kubernetes provider to connect to your Rancher-managed cluster. // Ensure that your KUBECONFIG is set up correctly to point to your Rancher cluster. const k8sProvider = new k8s.Provider("k8s", {}); // Create resources from the Strimzi topic operator Helm chart manifests. const strimziTopicOperatorResources = new k8s.yaml.ConfigGroup("strimzi-topic-operator", { yaml: strimziTopicOperatorManifests, }, { provider: k8sProvider }); // Export the status of the deployed resources export const status = strimziTopicOperatorResources.status;
Before running the Pulumi program, ensure your
KUBECONFIG
is pointed to the correct Kubernetes cluster managed by Rancher:export KUBECONFIG=/path/to/your/rancher/kubeconfig
Next, run the following commands to initiate Pulumi deployment:
pulumi stack init dev pulumi up
This will provision the Strimzi topic operator according to the manifests you generated with Helm. Remember to verify that the Strimzi topic operator is up and running by checking the resources within your Kubernetes cluster.
kubectl get all -n namespace-where-strimzi-was-deployed
Replace
namespace-where-strimzi-was-deployed
with the actual namespace used by the Strimzi topic operator.Please fill in
strimzi-topic-operator-manifests.yaml
with the correct file path if it is located in a different directory.-