Deploy the ucloud-exporter helm chart on Oracle Kubernetes Engine (OKE)
TypeScriptTo deploy the
ucloud-exporter
Helm chart on Oracle Kubernetes Engine (OKE), we'll walk through a Pulumi program in TypeScript. The program accomplishes the following:- Sets up a Kubernetes cluster using Oracle Container Engine for Kubernetes (OKE).
- Deploys the
ucloud-exporter
Helm chart to the OKE cluster.
We'll use the
oci.ContainerEngine.Cluster
resource to create the OKE cluster and thekubernetes.helm.sh/v3.Chart
resource to deploy the Helm chart onto that cluster.First, make sure you have the necessary Pulumi providers for Oracle Cloud (
@pulumi/oci
) and Kubernetes (@pulumi/kubernetes
) installed:npm install @pulumi/oci @pulumi/kubernetes
Additionally, make sure you have configured your Oracle Cloud credentials and the Kubernetes configuration to allow Pulumi to deploy resources on your behalf.
Now, let's start by defining the Pulumi program:
import * as pulumi from "@pulumi/pulumi"; import * as oci from "@pulumi/oci"; import * as k8s from "@pulumi/kubernetes"; import { Input } from "@pulumi/pulumi"; // Create an OCI Container Engine for Kubernetes (OKE) cluster const cluster = new oci.containerengine.Cluster("myOkeCluster", { // Specify the compartment ID where you want your cluster compartmentId: "<YOUR_OCI_COMPARTMENT_ID>", // Point to the VCN where the cluster will reside vcnId: "<YOUR_OCI_VCN_ID>", // Assign Kubernetes version kubernetesVersion: "v1.21.5", // Replace with the version you desire or the latest supported by OKE // Other necessary options... }); // ... Assume you have already configured related Networking (subnets, etc.) and NodePool resources... // Once the cluster is created you can use it to interact with Kubernetes with the standard Kubernetes configuration file // For this example, assume you have a Kubeconfig file set up correctly // Define the provider to interact with your OKE cluster const k8sProvider = new k8s.Provider("k8sProvider", { kubeconfig: cluster.kubeConfig.rawConfig, // Get access config from the cluster you have created }); // Deploy the ucloud-exporter Helm chart onto the OKE cluster const ucloudExporterChart = new k8s.helm.v3.Chart("ucloud-exporter", { chart: "ucloud-exporter", version: "1.0.0", // Replace with the actual chart version you want to deploy // Specify the Helm repository if the chart is not present in the default repos fetchOpts: { repo: "https://example.com/helm/charts", // Replace with the actual charts repository URL }, // Optionally, specify values to customize your Helm chart release values: { // Fill with the necessary values or leave empty to use default chart values }, }, { provider: k8sProvider }); // Indicate that this Helm chart is to be deployed using the OKE cluster // Export the cluster's name and kubeconfig export const clusterName = cluster.name; export const kubeconfig = cluster.kubeConfig.rawConfig;
This program begins by importing the necessary Pulumi OCI and Kubernetes packages. An OCI Kubernetes cluster is created using the
oci.containerengine.Cluster
resource, configuring it with the necessary properties such as your compartment ID and VCN ID. It's important to use the actual parameters that are relevant to your Oracle Cloud setup.After creating the OKE cluster, we define a Pulumi Kubernetes provider to interact with it using the kubeconfig obtained from the cluster creation output. This provider will be used to deploy the Helm chart.
We proceed to instantiate the
kubernetes.helm.v3.Chart
resource, which will deploy theucloud-exporter
Helm chart. You need to specify the exact version of the chart you intend to deploy and the Helm repository where the chart is hosted if it's not available in the default repositories.Finally, we export the cluster's name and kubeconfig file, as they can be useful to perform further operations on the cluster with tools like
kubectl
.Make sure to replace placeholders like
<YOUR_OCI_COMPARTMENT_ID>
and<YOUR_OCI_VCN_ID>
with actual values from your Oracle Cloud Infrastructure. If you have additional configuration to pass to the Helm chart, you can fill out thevalues
object appropriately.