Deploy the redpanda-operator helm chart on Oracle Kubernetes Engine (OKE)
TypeScriptTo deploy the
redpanda-operator
Helm chart on the Oracle Kubernetes Engine (OKE), we can use the Pulumi Kubernetes provider. This provider allows us to operate Kubernetes resources using Pulumi's infrastructure-as-code approach.First, we need to set up a Kubernetes cluster on OKE. Then, we'll use the Pulumi Kubernetes provider to deploy the
redpanda-operator
onto that cluster via a Helm chart.Below is a Pulumi TypeScript program that deploys a Kubernetes cluster using the Oracle Cloud Infrastructure (OCI) Container Engine for Kubernetes (OKE), and then deploys the
redpanda-operator
using a Helm chart.Ensure you've installed the following prerequisites before running the program:
- Pulumi CLI
- Oracle Cloud Infrastructure (OCI) CLI and configured it with the appropriate credentials.
- Node.js and NPM to run the Pulumi program in TypeScript.
Here's how to perform the deployment:
Step 1: Define Dependencies
The first step is to set up the Pulumi project and define our dependencies. Create a new directory for your Pulumi project and navigate into it. Then, run
pulumi new typescript
to initialize a new Pulumi TypeScript project. Install the necessary packages using npm:npm install @pulumi/pulumi @pulumi/oci @pulumi/kubernetes
Step 2: Create the Pulumi TypeScript Program
Create a file named
index.ts
and include the following code:import * as pulumi from "@pulumi/pulumi"; import * as oci from "@pulumi/oci"; import * as k8s from "@pulumi/kubernetes"; // Define your Oracle Cloud Infrastructure (OCI) Compartment ID const compartmentId = "oci-compartment-id"; // Provision an OKE cluster (Oracle Cloud Infrastructure Container Engine for Kubernetes) const cluster = new oci.containerengine.Cluster("redpanda-cluster", { compartmentId: compartmentId, kubernetesVersion: "v1.21.5", // You can choose the version you desire name: "redpandacluster", options: { serviceLbSubnetIds: [], kubernetesNetworkConfig: { podsCidr: "10.244.0.0/16", servicesCidr: "10.96.0.0/16" }, addOns: { isKubernetesDashboardEnabled: false, // Disable if not needed isTillerEnabled: false, // Disable Tiller }, }, }); // Obtain the kubeconfig from the generated OKE cluster const kubeconfig = pulumi. all([cluster.name, cluster.id]). apply(([name, id]) => oci.containerengine.getClusterKubeconfig({ name: name, clusterId: id, compartmentId: compartmentId, })); // Create a Kubernetes provider instance with the given kubeconfig const k8sProvider = new k8s.Provider("redpanda-k8s", { kubeconfig: kubeconfig.content, }); // Define the Helm chart for the Redpanda operator const redpandaChart = new k8s.helm.v3.Chart( "redpanda-operator-chart", { chart: "redpanda-operator", version: "latest", // Optionally, specify the chart version you wish to deploy fetchOpts: { repo: "https://charts.vectorized.io/", // The repository URL where the chart is located }, }, { provider: k8sProvider, // Specify the Kubernetes provider }, ); // Export the cluster name and the Kubeconfig raw content to access your cluster export const redpandaClusterName = cluster.name; export const kubeconfigRaw = kubeconfig.content;
Step 3: Deploy Your Infrastructure
To deploy the infrastructure, run
pulumi up
. Pulumi will show a preview of the resources that will be created and ask for confirmation before proceeding. If everything looks correct, confirm the deployment.Explanation of the Program
- We start by importing the necessary Pulumi packages for Oracle Cloud (
@pulumi/oci
) and Kubernetes (@pulumi/kubernetes
). - We then create an Oracle Kubernetes Engine (OKE) cluster by defining a
oci.containerengine.Cluster
resource. - The
fetchOpts
attribute inside thek8s.helm.v3.Chart
resource constructor specifies the Redpanda Helm chart repository. - We also need to create a Kubernetes provider that knows how to communicate with our newly created OKE cluster, using the kubeconfig we've obtained from the OKE API.
- We deploy the
redpanda-operator
chart through Pulumi’s Kubernetes provider by defining ak8s.helm.v3.Chart
resource. This resource points to the Helm chart we want to deploy, and we specify its