Deploy the sn-chart helm chart on Oracle Kubernetes Engine (OKE)
TypeScriptDeploying a Helm chart on Oracle Kubernetes Engine (OKE) involves a few steps. Pulumi provides a way to automate the deployment of cloud resources, including Kubernetes clusters and Helm charts.
The following Pulumi TypeScript program will illustrate how to deploy a Helm chart on Oracle Kubernetes Engine (OKE).
Here are the steps we will follow in the program:
- Create a Kubernetes cluster using Oracle Kubernetes Engine (OKE).
- Configure Pulumi to use the created OKE cluster.
- Deploy a Helm chart (
sn-chart
) on the OKE cluster.
Before you begin, you need to have Pulumi installed and configured with Oracle credentials.
Here's a detailed Pulumi program to accomplish this:
import * as pulumi from "@pulumi/pulumi"; import * as oci from "@pulumi/oci"; import * as kubernetes from "@pulumi/kubernetes"; // This assumes you have configured Pulumi with your OCI credentials. // Ensure the availability of required properties like compartment ID which you should have before executing the program. const compartmentId = "oci-compartment-id"; // Replace with your actual compartment ID // Create an Oracle Kubernetes Engine (OKE) cluster const cluster = new oci.ContainerEngine.Cluster("okeCluster", { compartmentId: compartmentId, vcnId: "oci-vcn-id", // Replace with your VCN ID kubernetesVersion: "v1.20.8", // Specify the desired Kubernetes version options: { serviceLbSubnetIds: ["oci-lb-subnet-id-1", "oci-lb-subnet-id-2"], // Set LB subnet IDs // Additional OKE configuration options as needed }, // Other required cluster configurations... }); // Create a kubeconfig to interact with the OKE cluster const kubeconfig = pulumi.all([cluster.id, cluster.name]).apply(([id, name]) => oci.ContainerEngine.getClusterKubeconfig({ clusterId: id, }) ); // Create a provider to manage resources in the created cluster const k8sProvider = new kubernetes.Provider("okeK8sProvider", { kubeconfig: kubeconfig.rawConfig // Pulumi uses this kubeconfig to interact with the OKE cluster }); // Deploy the "sn-chart" Helm chart on the OKE cluster const snChart = new kubernetes.helm.v3.Chart("snChart", { chart: "sn-chart", // You can specify the repository if the Helm chart is not in the default Helm repo // repo: "https://my-helm-repo", // Specify any values to override chart defaults values: { // custom values for your Helm chart }, }, {provider: k8sProvider}); // Ensure that the Helm chart is deployed using the OKE cluster // Export the cluster's name and kubeconfig export const clusterName = cluster.name; export const kubeconfigOutput = kubeconfig;
Here's a breakdown of what the code is doing:
- We import the necessary modules from Pulumi.
- Replace the placeholder values with your cloud setup-specific details (
oci-compartment-id
,oci-vcn-id
,oci-lb-subnet-id-1
,oci-lb-subnet-id-2
). - We create an OKE cluster with the
oci.ContainerEngine.Cluster
resource. The version of Kubernetes and subnet IDs are customized. - We retrieve the kubeconfig for the created OKE cluster using
oci.ContainerEngine.getClusterKubeconfig
. - We introduce a Kubernetes provider that utilizes the kubeconfig, allowing Pulumi to manage resources on our OKE cluster.
- We deploy the
sn-chart
Helm chart using thekubernetes.helm.v3.Chart
resource. - We export the cluster name and kubeconfig as stack outputs so that they can be easily accessed after the deployment is complete.
Remember to replace the placeholder values with actual data from your Oracle Cloud Infrastructure, such as your compartment ID, VCN ID, and subnet IDs.
You can run this program using the Pulumi CLI by running
pulumi up
, which will provision the resources on Oracle Cloud. Ensure that you've selected the correct stack that points to the Oracle Cloud environment.After the deployment is successful, you can find the
clusterName
andkubeconfigOutput
in the stack output, which you can use to interact with your cluster usingkubectl
.