Deploy the cyber-center helm chart on Oracle Kubernetes Engine (OKE)
TypeScriptTo deploy the "cyber-center" Helm chart on the Oracle Kubernetes Engine (OKE), we will be completing several steps:
- We will set up an OCI Kubernetes Cluster (OKE) using the
oci.ContainerEngine.Cluster
resource. - Once we have the Kubernetes cluster, we will configure Pulumi to use the Kubernetes provider to interact with it.
- After configuring the provider, we will deploy the "cyber-center" Helm chart using the
kubernetes.helm.v3.Chart
resource.
Here is a Pulumi TypeScript program that accomplishes this. It assumes you have already configured Pulumi with the required OCI credentials and that you have installed the required Pulumi providers for this task.
import * as oci from "@pulumi/oci"; import * as k8s from "@pulumi/kubernetes"; import * as pulumi from "@pulumi/pulumi"; // Create an OCI container engine cluster (OKE) const okeCluster = new oci.containerengine.Cluster("okeCluster", { compartmentId: "ocid1.tenancy.oc1..example", name: "cyber-center-cluster", vcnId: "ocid1.vcn.oc1..example", kubernetesVersion: "v1.21.4", // Specify the Kubernetes version options: { serviceLbSubnetIds: ["ocid1.subnet.oc1..example1", "ocid1.subnet.oc1..example2"] }, }); // Export the Cluster's id export const clusterId = okeCluster.id; // Obtain the kubeconfig for the cluster const kubeconfig = pulumi.all([okeCluster.id, okeCluster.name]).apply(([id, name]) => { const clusterKubeconfig = oci.containerengine.getClusterKubeconfig({ clusterId: id, clusterName: name, }); return clusterKubeconfig.content; }); // Create a provider instance for the cluster const provider = new k8s.Provider("okeProvider", { kubeconfig: kubeconfig, }); // Deploy the "cyber-center" Helm chart on the OKE cluster const helmChart = new k8s.helm.v3.Chart("cyberCenterChart", { chart: "cyber-center", version: "1.0.0", // Use the appropriate chart version namespace: "default", // Specify the namespace if needed, default is used here fetchOpts: { repo: "https://charts.example.com/", // Replace with the actual Helm chart repo URL }, }, { provider: provider }); // Export the Helm chart's status export const helmChartStatus = helmChart.status;
This program starts by importing the necessary Pulumi packages for OCI, Kubernetes, and the Pulumi SDK. It then defines a new OKE cluster with basic configurations, such as the compartment ID, VCN ID, and Kubernetes version. Be sure to replace placeholder strings such as
"ocid1.tenancy.oc1..example"
with actual resource identifiers from your OCI cloud setup.Next, we use Pulumi's programming model to obtain the kubeconfig required to interact with the cluster by calling
oci.containerengine.getClusterKubeconfig
. The cluster ID and name are used here, which are derived from the created OKE cluster.Once we obtain the kubeconfig, we create an instance of the Pulumi Kubernetes provider configured to use this kubeconfig. This step is essential as it directs Pulumi to use the newly created OKE cluster when deploying resources to Kubernetes.
Finally, we define the Helm chart deployment using the
k8s.helm.v3.Chart
resource. We specify the chart name, version, and the namespace for the deployment. You should provide the correct URL to the repository where your Helm chart is stored. Theprovider
option ensures that the Helm chart is deployed using the provider associated with our OKE cluster.By exporting select outputs, such as the cluster ID and Helm chart status, we can easily reference these in the Pulumi console or in subsequent Pulumi programs.
Remember to replace placeholders within this code (noted with "example" or surrounded by "example") with actual values from your environment. Also, make sure to install Pulumi and OCI CLI, log in to the Oracle cloud, and configure your OCI credentials.
- We will set up an OCI Kubernetes Cluster (OKE) using the