Deploy the variant-api helm chart on Oracle Kubernetes Engine (OKE)
TypeScriptTo deploy a Helm chart on Oracle Kubernetes Engine (OKE) using Pulumi, you will need to perform the following steps:
-
Set up an OKE cluster: This will be the environment where your Helm chart will be deployed. The Oracle Container Engine for Kubernetes (OKE) service manages the Kubernetes cluster on Oracle Cloud Infrastructure (OCI).
-
Install the Pulumi CLI and set up the OCI provider: This involves installing the Pulumi CLI on your local machine and setting up the OCI provider so that Pulumi can interact with your Oracle Cloud Infrastructure.
-
Write a Pulumi program to deploy your Helm chart: You will write a TypeScript-based Pulumi program that uses the
oci.ContainerEngine.Cluster
resource to create a Kubernetes cluster and uses the Helm 3 package via thekubernetes.helm.v3.Chart
resource to deploy yourvariant-api
Helm chart onto that cluster.
Below is the detailed Pulumi TypeScript program that carries out these steps. The program assumes you have already configured your OCI credentials for use with Pulumi and that you have the OCI CLI configured with the necessary API key and user information.
import * as pulumi from "@pulumi/pulumi"; import * as oci from "@pulumi/oci"; import * as k8s from "@pulumi/kubernetes"; // Step 1: Create an OKE Cluster const cluster = new oci.ContainerEngine.Cluster("okeCluster", { // Specify the necessary properties for your OKE cluster // For example: // compartmentId: "<YOUR_COMPARTMENT_ID>", // vcnId: "<YOUR_VCN_ID>", // kubernetesVersion: "v1.19.7", // ... and other configuration details ... // For a full list of properties refer to: // https://www.pulumi.com/registry/packages/oci/api-docs/containerengine/cluster/ }); // Step 2: Generate a kubeconfig for the created cluster // This function can be created and invoked to get a kubeconfig file for our OKE cluster const kubeconfig = pulumi.all([cluster.id, cluster.name]).apply(([id, name]) => { // The command retrieves kubeconfig from OCI for the created OKE cluster return oci.containerengine.getClusterKubeconfig({clusterId: id, name: name}); }); // Step 3: Create a Pulumi Kubernetes Provider using the kubeconfig from OKE // This provider is what we will use to install Helm charts const k8sProvider = new k8s.Provider("okeK8sProvider", { kubeconfig: kubeconfig, }); // Step 4: Deploy the `variant-api` Helm chart using the Kubernetes provider const chart = new k8s.helm.v3.Chart("variant-api", { chart: "variant-api", // Specify the chart version if needed // version: "<CHART_VERSION>", // Specify any values to override the defaults set in the Helm chart // values: { /* ... */ }, // Reference the provider created previously fetchOpts: { // Specify the repository containing the `variant-api` chart repo: "https://charts.your-repo.com/", } }, { provider: k8sProvider }); // Step 5: Export the URL of the deployed application (if applicable) // Let's assume your Helm chart creates a Kubernetes Service of type LoadBalancer. // You would be able to access your deployed service at this external address: const frontend = chart.getResourceProperty("v1/Service", "variant-api", "status"); export const frontendIp = pulumi.interpolate`${frontend.apply(status => status.loadBalancer.ingress[0].ip)}`;
This Pulumi program defines a stack that will:
- Create a new cluster in OKE.
- Fetch the kubeconfig from OCI for the created cluster.
- Initialize a Pulumi
Provider
for Kubernetes, which will be used to install Helm charts. - Deploy the
variant-api
Helm chart onto the cluster using thek8s.helm.v3.Chart
resource. - Export the external IP address for the
variant-api
service, allowing you to interact with the application once it’s deployed.
Please replace placeholder values like
<YOUR_COMPARTMENT_ID>
and<YOUR_VCN_ID>
with actual values from your OCI deployment. Also, ensure the Helm chart repository and chart version are specified correctly.After writing this Pulumi program, you would need to run
pulumi up
on your terminal to execute the deployment. The exportedfrontendIp
will display once the deployment is complete, and you can use this IP to access yourvariant-api
application.-