1. Deploy the cluster-redis helm chart on Oracle Kubernetes Engine (OKE)

    TypeScript

    To deploy the cluster-redis Helm chart on Oracle Kubernetes Engine (OKE), you'll need to follow a series of steps with Pulumi:

    1. Set up Pulumi for Oracle Cloud Infrastructure (OCI): Ensure you have the pulumi and oci CLI tools installed, correctly configured with necessary access keys and regions.

    2. Provision an OKE Cluster: Create a Kubernetes cluster on Oracle Cloud using Pulumi's OCI package.

    3. Install the Helm Chart: Once you have your Kubernetes cluster, you will use Pulumi's kubernetes package to install the cluster-redis Helm chart into your cluster.

    Below you'll find a comprehensive TypeScript program that accomplishes these steps. This example uses Pulumi's OCI and Kubernetes libraries.

    import * as oci from "@pulumi/oci"; import * as k8s from "@pulumi/kubernetes"; import * as pulumi from "@pulumi/pulumi"; // Step 1: Create a new OCI OKE cluster const compartmentId = pulumi.output(oci.core.getCompartment({ compartmentName: "Your Compartment Name" })).id; const vcn = new oci.core.Vcn("okeVcn", { compartmentId: compartmentId, cidrBlock: "10.0.0.0/16", }); const subnet = new oci.core.Subnet("okeSubnet", { compartmentId: compartmentId, vcnId: vcn.id, cidrBlock: "10.0.1.0/24", securityListIds: [], }); const okeCluster = new oci.containerengine.Cluster("okeCluster", { compartmentId: compartmentId, vcnId: vcn.id, kubernetesVersion: "v1.21.2", // specify an available version options: { serviceLbSubnetIds: [subnet.id], }, }); const nodePool = new oci.containerengine.NodePool("okeNodePool", { clusterId: okeCluster.id, compartmentId: compartmentId, subnetIds: [subnet.id], nodeShape: "VM.Standard.E2.1", // specify an available node shape nodeConfigDetails: { placementConfigs: [{ availabilityDomain: "ChangeToYourADName", subnetId: subnet.id, }], size: 2, // specify the number of nodes }, }); // Once the cluster is created, we can use it's kubeconfig to configure the Kubernetes provider const kubeconfig = pulumi.all([okeCluster.id, compartmentId]).apply(([clusterId, compartmentId]) => oci.containerengine.getClusterKubeconfig({ clusterId: clusterId, compartmentId: compartmentId, options: { expiry: "720h" }, }), ); const provider = new k8s.Provider("okeK8s", { kubeconfig: kubeconfig.content, }); // Step 2: Deploy the cluster-redis Helm chart to the OKE cluster const redisChart = new k8s.helm.v3.Chart("redis-cluster", { chart: "cluster-redis", version: "6.2.1", // specify the version of the chart fetchOpts: { repo: "https://charts.bitnami.com/bitnami" }, }, { provider }); // Export the cluster's kubeconfig and the service endpoint of the Redis cluster export const kubeconfigOutput = kubeconfig; export const redisClusterServiceEndpoint = redisChart.getResource("v1/Service", "redis-cluster-redis-cluster").status.loadBalancer.ingress[0].ip;

    Explanation:

    • OCI OKE Cluster: We define the necessary resources to provision an Oracle Kubernetes Engine (OKE) cluster. This includes creating a Virtual Cloud Network (VCN) and a subnet before defining the cluster itself with oci.containerengine.Cluster.

    • Node Pool: A node pool is created with a specific shape and size (number of instances). This is where your Kubernetes workloads will run.

    • Kubernetes Provider: With the cluster up and running, we retrieve the kubeconfig, which is used by Pulumi to communicate with your Kubernetes cluster. This sets up the k8s.Provider with the kubeconfig from our new OKE cluster.

    • Helm Chart Deployment: Once we have a working Kubernetes provider, we proceed with deploying the cluster-redis Helm chart using k8s.helm.v3.Chart.

    • Exports: After the Helm chart has been successfully deployed, we export the kubeconfig for cluster management purposes and the service endpoint to access the Redis cluster.

    Please make sure to replace placeholder text such as "Your Compartment Name", "v1.21.2", "VM.Standard.E2.1", and "ChangeToYourADName" with actual values based on your Oracle Cloud Infrastructure setup and the desired Kubernetes version, node shape, availability domain, etc.

    Run the program using Pulumi CLI:

    pulumi up

    This command will prompt Pulumi to provision the described resources and apply the desired state. If it's the first time you run it in the directory, Pulumi will prompt to create a new stack, which is a logical deployment target that will host your cloud resources. After the command execution, the Redis cluster should be up and running in the OKE cluster, as specified.