1. Deploy the base-cronjob helm chart on Oracle Kubernetes Engine (OKE)


    Deploying a Helm chart on a Kubernetes cluster, such as one managed by Oracle Kubernetes Engine (OKE), involves several steps using Pulumi. We will be making use of the kubernetes.helm.v3.Chart resource, which allows us to deploy Helm charts into a Kubernetes cluster.

    The deployment process can be broken down as follows:

    1. Set up the Pulumi Kubernetes Provider: This provider will allow Pulumi to interact with the Kubernetes API to deploy and manage applications.
    2. Use Chart Resource to Deploy the Helm Chart: With the Pulumi Kubernetes Provider configured, we will create a new instance of a Chart resource, which represents a Helm chart deployment in the Kubernetes cluster.

    Below is a Pulumi program written in TypeScript that accomplishes the deployment of a base-cronjob Helm chart on an OKE cluster. Before running this program, you should have already configured access to your OKE cluster using kubectl, as Pulumi relies on the same configuration.

    Here is a detailed Pulumi program to deploy a base-cronjob Helm chart on OKE:

    import * as k8s from "@pulumi/kubernetes"; // This example assumes that you have configured the Kubernetes provider for Pulumi // to communicate with your OKE cluster. The configuration is usually sourced from // the default kubeconfig file located at `~/.kube/config`, or from the environment // variables set on your system. // Deploying a base-cronjob Helm chart into your OKE cluster. const cronJobChart = new k8s.helm.v3.Chart("base-cronjob", { // Specify the chart repository and name. repo: "example-repo", // Replace with your Helm repo name chart: "base-cronjob", // Optionally, you can specify the chart version. // version: "1.2.3", // Uncomment and replace with your chart version, if needed // Values to pass to the Helm chart, which will configure the cron job. // This is where you can specify the schedule, the job to run, etc. values: { // Replace with the specifics of your cron job. // These values will depend on the base-cronjob chart's values.yaml file. schedule: "*/5 * * * *", // Example schedule: every 5 minutes. job: { name: "example-job", image: "ubuntu", args: ["echo", "Hello, Pulumi!"] // Additional job configuration goes here. }, // More configuration values specific to the base-cronjob chart. }, // Setting a namespace for the Helm chart resources. // If not specified, it defaults to the "default" namespace. namespace: "default", // Change this according to your desired namespace in OKE. // If your Helm chart includes CRDs and you want to skip awaiting for them to be ready, // you can set `skipAwait` to `true`. // skipAwait: true, // Uncomment if necessary. // Debugging: Turn this on if you need more verbose logs from the Helm operation. // valuesTransformation: args => { // args["debug"] = true; // return args; // }, }); // Exports can be used to output certain information about the resources created by Pulumi. export const cronJobName = cronJobChart.getResourceProperty("v1/Job", "example-job", "metadata").apply(m => m.name);

    In the above code:

    • We first import the necessary Pulumi Kubernetes package.
    • We then create a new Helm chart resource by instantiating k8s.helm.v3.Chart.
    • We specify the repository and name of the helm chart we wish to deploy—in this case, base-cronjob. You need to replace "example-repo" with the actual repository name where your Helm chart is hosted.
    • The values object contains the configuration for the cron job. It needs to be filled out with the appropriate values that match the values.yaml file for the base-cronjob Helm chart.
    • The namespace parameter specifies the Kubernetes namespace in which you would like to deploy your Helm chart.

    For this program to work correctly, you must provide the correct Helm repository (repo) parameter and ensure that the values match your base-cronjob chart's expected values.

    After the program is set up, run the following commands in your terminal to deploy the cron job:

    1. Initialize a New Pulumi Stack (equivalent to a deployment target/environment):

      pulumi stack init dev
    2. Preview the Deployment (this step allows you to see what changes will occur without performing them):

      pulumi preview
    3. Deploy the Stack (this step actually provisions the resources specified in the Pulumi program):

      pulumi up

    Upon successful deployment, Pulumi will output any exported properties, such as the cron job's name. When you no longer need the cron job, you can tear down the resources using:

    pulumi destroy

    Remember to replace the values provided in the code with actual valid values specific to your deployment scenario based on the values.yaml file from your chart.