Deploy the voting-app helm chart on Oracle Kubernetes Engine (OKE)
TypeScriptTo deploy a Helm chart on Oracle Kubernetes Engine (OKE), you will need to use Pulumi's Kubernetes provider to interact with your Kubernetes cluster and Helm support to deploy the chart.
I'll provide you with a Pulumi program that accomplishes this task. The program will:
- Import necessary Pulumi packages for Kubernetes and OCI (Oracle Cloud Infrastructure).
- Set up a reference to your Kubernetes cluster in OKE.
- Deploy the
voting-app
Helm chart to your Oracle Kubernetes Engine cluster.
Before you begin, make sure you have the following prerequisites in place:
- An Oracle Kubernetes Engine (OKE) cluster running and accessible.
- A kubeconfig file with the configuration of your OKE cluster. This file allows Pulumi to interact with your Kubernetes cluster.
- The
voting-app
Helm chart URL or a path to where it is located.
Here's a step-by-step Pulumi program that deploys the
voting-app
Helm chart to your OKE cluster:import * as pulumi from "@pulumi/pulumi"; import * as k8s from "@pulumi/kubernetes"; import * as oci from "@pulumi/oci"; // Step 1: Configure OCI provider to interact with Oracle Cloud Infrastructure. // Ensure you have the required OCI configuration set in your environment or Pulumi config, // such as tenancyOCID, userOCID, privateKey, fingerprint, and region. const ociProvider = new oci.Provider("oci", {/* Use your OCI configuration */}); // Step 2: Get the kubeconfig for your OKE cluster. // Replace the placeholders with the actual values for your OKE cluster. const okeCluster = new oci.ContainerEngine.Cluster("myOkeCluster", { name: "my-cluster-name", // Replace with your cluster name compartmentId: "my-compartment-id", // Replace with your compartment ID vcnId: "my-vcn-id", // VCN ID where OKE is deployed kubernetesVersion: "v1.20.8", // Specify your Kubernetes version // ... other necessary OKE cluster configuration }, { provider: ociProvider }); // Ensure that you have permissions to manage clusters and workloads. // Step 3: Instantiate a Kubernetes provider instance using the kubeconfig from the OKE cluster. // This step assumes that you have your kubeconfig properly configured in your environment. const k8sProvider = new k8s.Provider("k8sProvider", { kubeconfig: okeCluster.kubeconfig, }); // Step 4: Deploy the voting-app Helm chart using Pulumi's Helm support. const votingAppChart = new k8s.helm.v3.Chart("voting-app", { // Replace with the actual chart name or URL where the voting-app chart can be found. chart: "voting-app", // You may need a repo or a local path if the chart is not packaged with the app. // repo: "https://my-helm-chart-repo", // Uncomment and replace if necessary. // path: "./path-to-local-chart", // Uncomment and replace if necessary. version: "1.0.0", // Replace with your desired chart version. namespace: "default", // Optionally specify the namespace. If not specified it defaults to 'default'. values: { // Specify any values required by the chart, this may include configuration // options for different application components. }, }, { provider: k8sProvider }); // Step 5: Export the public endpoint of the voting-app if available. export const endpoint = votingAppChart.getResourceProperty("v1/Service", "voting-app", "status").apply(status => status.loadBalancer.ingress[0].hostname || status.loadBalancer.ingress[0].ip);
In this program:
- We first configure the Oracle Cloud Infrastructure (OCI) provider with necessary credentials and settings.
- We use the OCI provider to retrieve the kubeconfig for the OKE cluster, which lets us interact with the cluster.
- A new Kubernetes provider instance is instantiated using the kubeconfig.
- The
voting-app
Helm chart is deployed using theChart
resource from Pulumi's Helm package. You can also specify Helm chart values to configure the app as needed. - Finally, if the chart exposes a public endpoint, we export that to be accessible after deployment.
Make sure you replace the placeholders with your actual OKE cluster details and Helm chart details.
When you're ready to deploy this application, save the code in a file named
index.ts
, then run the following commands:pulumi stack init dev
to create a new stack calleddev
.pulumi up
to preview and deploy the changes.
Upon completion, Pulumi CLI will output any exported values, like the application endpoint.