Deploy the tsorage helm chart on Oracle Kubernetes Engine (OKE)
TypeScriptTo deploy a Helm chart onto Oracle Kubernetes Engine (OKE) using Pulumi, you will follow these steps:
- Set up an instance of the OKE cluster using Pulumi's OCI (Oracle Cloud Infrastructure) provider.
- Install the Helm chart on your Kubernetes cluster.
Initially, you will need to have Pulumi and the required cloud provider CLI installed and configured on your local machine. Oracle Cloud Infrastructure's
oci
CLI should be set up, and you should have credentials configured for use with Pulumi. Once that's in place, you can proceed with writing the Pulumi program.Here's a TypeScript program that accomplishes the deployment of the "tsorage" Helm chart onto Oracle Kubernetes Engine:
import * as oci from "@pulumi/oci"; import * as k8s from "@pulumi/kubernetes"; const compartmentId = "ocid1.compartment.oc1..xxxx"; // Replace with your actual compartment OCID const vcnId = "ocid1.vcn.oc1..xxxx"; // Replace with your actual VCN OCID const kubernetesVersion = "v1.20.8"; // Use a supported Kubernetes version for OKE // Create an OKE cluster. const cluster = new oci.containerengine.Cluster("oke_cluster", { compartmentId: compartmentId, kubernetesVersion: kubernetesVersion, options: { // Other options can be configured as per requirement. serviceLbSubnetIds: [], // Replace with actual subnet IDs for load balancers }, vcnId: vcnId, }); // Retrieve the kubeconfig for the created cluster. const kubeconfig = cluster.kubeconfig({}, { async: true }).then(c => c.content); // Create a Kubernetes Provider using the kubeconfig from the OKE cluster. const k8sProvider = new k8s.Provider("oke_k8s", { kubeconfig: kubeconfig, }); // Deploy the "tsorage" Helm chart onto the OKE cluster using the Helm provider. const tsorageChart = new k8s.helm.v3.Chart("tsorage", { chart: "tsorage", // Specify the chart name. The chart name must match the chart name on the repository. // Set appropriate repository information if the chart is not available in the Helm stable repository. values: { // Specify any values required for the deployment. // These values should correspond to the ones declared in the values.yaml of the Helm chart. }, }, { provider: k8sProvider }); export const kubeconfigContent = kubeconfig; // Export the kubeconfig to be used externally if required. export const tsorageChartVersion = tsorageChart.version; // Export the deployed chart version.
Explanation
- We first import the necessary modules from Pulumi for working with OCI and Kubernetes.
- Then we specify information such as the compartment OCID and VCN OCID which is necessary to create the OKE cluster in the specific compartment and VCN.
- Using
oci.containerengine.Cluster
, an OKE cluster is declared. - We then retrieve the kubeconfig for the created OKE cluster, which will allow us to interact with the cluster using the Kubernetes API.
- A Pulumi Kubernetes provider is instantiated using that kubeconfig. This provider acts as an interface to deploy resources onto our OKE cluster.
- A Helm chart called "tsorage" is declared to be installed onto the cluster. You would need to replace
"tsorage"
with the actual chart name and chart repository options if it's not within the default Helm chart repositories. - The values object in the
Chart
resource is used to set any specific configuration needed for the Helm chart. This might correspond to what you would manually insert into avalues.yaml
file or pass through the--set
CLI option. - The
export
statements at the end are used to output the kubeconfig and the Helm chart version as Pulumi stack outputs. These values can then be accessed from the command line or used in other programs.
Note that
tsorage
is assumed to be the name of the Helm chart you want to deploy. If the chart is located in a private or custom Helm repository, you need to provide therepo
attribute with the URL of that repository. You also may need to provide otherfetchOpts
such as credentials if required.Remember, Pulumi stores state information about your infrastructure, which means you can safely apply changes and Pulumi can compute the minimal diff to achieve your desired state. To apply these configurations, run
pulumi up
and Pulumi will handle the provisioning and updating of resources.