Deploy the oci-registry helm chart on Oracle Kubernetes Engine (OKE)
TypeScriptTo deploy a Helm Chart, like the
oci-registry
helm chart, on Oracle Kubernetes Engine (OKE) using Pulumi, we'll need to perform a few steps:- Set up an Oracle Kubernetes Engine cluster where we can deploy our Helm chart. For this purpose, we'll use the
oci.ContainerEngine.Cluster
resource. - Once we have our Kubernetes cluster in place, we'll set up a Kubernetes provider that points to our OKE cluster.
- Then, we'll use the
kubernetes.helm.sh/v3.Chart
resource to install theoci-registry
Helm chart on our OKE cluster.
Let's go through a program that manages these resources in TypeScript.
First, ensure you have the following installed:
- Pulumi CLI
- Oracle Cloud Infrastructure (OCI) CLI
- An OCI account with proper permissions to create resources
Next, configure your Pulumi for OCI authentication. You can use the
pulumi config set
command to set up your credentials and the desired region, for example:pulumi config set oci:tenancyOcid <TENANCY_OCID> pulumi config set oci:userOcid <USER_OCID> pulumi config set oci:fingerprint <FINGERPRINT> pulumi config set oci:region <REGION> pulumi config set --secret oci:privateKey <PRIVATE_KEY_PATH_OR_CONTENT>
This ensures your Pulumi program can authenticate against OCI.
Here's the TypeScript program for deploying the
oci-registry
helm chart:import * as oci from "@pulumi/oci"; import * as k8s from "@pulumi/kubernetes"; import * as pulumi from "@pulumi/pulumi"; // This project assumes you have configured your provider // See: https://www.pulumi.com/registry/packages/oci/installation-configuration/ // Create an OKE cluster const okeCluster = new oci.ContainerEngine.Cluster("okeCluster", { // Required properties: compartmentId: oci.identity.getCurrentCompartment().then(c => c.id), kubernetesVersion: "v1.20.8", // Use an appropriate version for your use case name: "oke-cluster-demo", vcnId: "ocid1.vcn.oc1.iad.aaaaaaaasomerequiredexamplevcnid", // The OCID of the VCN in which to create the cluster options: { // Specify additional options if needed }, // Managing tags, if required }); // Create a default Node Pool for the OKE Cluster const nodePool = new oci.ContainerEngine.NodePool("nodePool", { // Required properties: clusterId: okeCluster.id, compartmentId: oci.identity.getCurrentCompartment().then(c => c.id), kubernetesVersion: okeCluster.kubernetesVersion, nodeShape: "VM.Standard.E2.1", // Use an appropriate shape for your use case nodeShapeConfig: { // Specify additional shape configuration if needed }, nodeSource: { // Specify the source details }, subnetIds: ["ocid1.subnet.oc1.iad.someexamplesubnetid"], // Subnets for nodes quantityPerSubnet: 1, // Number of nodes per subnet // Managing tags, if required }); // Expose the kubeconfig for the OKE cluster export const kubeconfig = okeCluster.kubeconfig; // Create a Kubernetes provider instance const k8sProvider = new k8s.Provider("okeK8sProvider", { kubeconfig: okeCluster.kubeconfig, }); // Use the template helm chart as the "oci-registry" const ociRegistryChart = new k8s.helm.sh.v3.Chart("ociRegistryChart", { chart: "oci-registry", // Assuming the oci-registry chart exists, replace with correct chart name/location // You might need additional configuration such as `repo`, `version`, and `values`. // Example for setting values: // values: { // service: { // type: "LoadBalancer" // } // } }, { provider: k8sProvider }); // Optionally, export outputs related to our resources export const okeClusterName = okeCluster.name; export const nodePoolName = nodePool.name; export const helmReleaseStatus = ociRegistryChart.status;
This program creates an Oracle Kubernetes Engine cluster and a node pool with compliance to the specifics required by Oracle Kubernetes Engine. It also sets up the Kubernetes provider to point at this newly created cluster, then deploys the Helm chart for
oci-registry
onto the cluster.To run the above Pulumi program:
- Save it into a file with a
.ts
extension (for example,deployOciRegistry.ts
). - Initialize a new Pulumi project in an empty directory using
pulumi new
. - Install the required npm packages:
npm install @pulumi/oci @pulumi/kubernetes
- Run
pulumi up
to execute the program and create the resources.
Remember to replace placeholder values like
<TENANCY_OCID>
,<USER_OCID>
, and other OCI related variables with actual values from your Oracle cloud account. Also, make sure to specify the actual Helm chart name and the location of the chart if it's not in the default Helm repository.Once the
pulumi up
command has finished running, it will output the status of your OKE cluster, along with the status of your Helm chart deployment. If you want, you can visit the Oracle Cloud Infrastructure Console to confirm that the resources have been deployed successfully.- Set up an Oracle Kubernetes Engine cluster where we can deploy our Helm chart. For this purpose, we'll use the