Deploy the twampy helm chart on Oracle Kubernetes Engine (OKE)
TypeScriptTo deploy the
twampy
Helm chart on Oracle Kubernetes Engine (OKE), we'll go through a multi-step process, which involves setting up an OKE cluster, configuring the Kubernetes provider to communicate with it, and finally using thehelm.Chart
resource to deploytwampy
.Step 1: Set up an OKE Cluster
Before deploying the Helm chart, you need an OKE cluster. OKE is a managed Kubernetes service that makes it easier to deploy, manage, and scale containerized applications using Kubernetes on Oracle Cloud Infrastructure (OCI).
The Pulumi
oci
package doesn't explicitly provide resources for creating OKE clusters because such actions are typically performed ahead of time or managed separately. You would usually do this through the Oracle Console UI, the OCI CLI, or Terraform with the Oracle provider. For this example, we'll assume that an OKE cluster has already been provisioned, and we have configuration parameters such as the cluster'skubeconfig
file contents available to us.Step 2: Configure the Kubernetes Provider to Connect to OKE
Once your OKE cluster is running, you'll need to configure the Kubernetes provider to authenticate and connect to your cluster. You'll use your cluster's
kubeconfig
file for that. Pulumi's Kubernetes provider understandskubeconfig
files just likekubectl
does.Step 3: Deploy the
twampy
Helm ChartThe
helm.Chart
resource is a component resource that encapsulates deploying a Helm chart into a Kubernetes cluster.Let's assume that
twampy
is available in a Helm repository that is accessible from your machine. You will need the Chart name (twampy
), and you might need additional configuration values specific to this Helm chart.Now, let's write the Pulumi program in TypeScript:
import * as pulumi from '@pulumi/pulumi'; import * as oci from '@pulumi/oci'; import * as kubernetes from '@pulumi/kubernetes'; // Step 1: OKE cluster is assumed to be set up manually outside of Pulumi // Step 2: Configure the Kubernetes provider (make sure to replace `<contents_of_your_kubeconfig>` with your actual kubeconfig content) const kubeconfig = `<contents_of_your_kubeconfig>`; const k8sProvider = new kubernetes.Provider('k8s-provider', { kubeconfig }); // Step 3: Deploy Twampy Helm Chart using `helm.Chart` resource const twampyChart = new kubernetes.helm.v3.Chart('twampy-chart', { chart: 'twampy', // The name of the chart // Here you would specify the Helm repository URL if it's not a stable chart, e.g. // repo: 'http://my-helm-chart-repo.org/', values: { // You can provide your configuration for the chart here, for example: serviceType: 'LoadBalancer', // ... More values based on the Helm chart's values.yaml }, }, { provider: k8sProvider }); // Optional: Export any required outputs, e.g., the load balancer's address export const twampyLoadBalancerIp = twampyChart.getResourceProperty( 'v1/Service', 'twampy-service', 'status').apply(status => status.loadBalancer.ingress[0].ip);
In this program, we import the required modules from Pulumi's
oci
andkubernetes
packages. We set up the Kubernetes provider with thekubeconfig
for the existing OKE cluster. Then a newhelm.Chart
resource is declared to deploy thetwampy
Helm chart.The
values
object is where you would override default settings fromtwampy
'svalues.yaml
file. For instance, settingserviceType: 'LoadBalancer'
might expose yourtwampy
application via a cloud provider's load balancer. Please provide the appropriate values for your specific deployment.Lastly, if you wish to obtain outputs from the Helm deployment, like an external IP address of a service, we utilize
getResourceProperty
method to extract it from the deployed resources. Theexport
statement exposes this information outside of Pulumi for easy access.Make sure to replace
kubeconfig
variable content with the actual configuration of your OKE cluster'skubeconfig
.Please remember always to keep your kubeconfig data secure, especially when checking in your Pulumi code into source control. You should consider using Pulumi secrets for sensitive data encryption.
Run this Pulumi program with the Pulumi CLI by invoking
pulumi up
in your project directory. It will provision the resources as per the configuration specified in the program.