1. Deploy the mongodb-replicaset helm chart on Oracle Kubernetes Engine (OKE)

    TypeScript

    To deploy the mongodb-replicaset Helm chart on Oracle Kubernetes Engine (OKE), we will use the oci.ContainerEngine.Cluster resource to deploy an OKE cluster and the kubernetes.helm.sh/v3.Chart resource to deploy the Helm chart on that cluster.

    Here's a breakdown of the steps you'll be taking in the program:

    • First, you will need to set up the oci.ContainerEngine.Cluster resource to provision an Oracle Kubernetes Engine (OKE) cluster.
    • Once you have your Kubernetes cluster provisioned and accessible, you will then configure the Pulumi Kubernetes provider to deploy the mongodb-replicaset chart using the kubernetes.helm.sh/v3.Chart resource.

    Below is a Pulumi program written in TypeScript that guides you through these steps:

    import * as pulumi from '@pulumi/pulumi'; import * as oci from '@pulumi/oci'; import * as k8s from '@pulumi/kubernetes'; // Set up your Oracle Cloud Infrastructure (OCI) configuration const config = new pulumi.Config(); const compartmentId = config.requireSecret("compartmentId"); // Your OCI Compartment ID const vcnId = config.requireSecret("vcnId"); // Your Virtual Cloud Network (VCN) ID // Create an Oracle Container Engine for Kubernetes (OKE) cluster const cluster = new oci.ContainerEngine.Cluster("okeCluster", { compartmentId: compartmentId, vcnId: vcnId, kubernetesVersion: "v1.20.8", // Specify the version of Kubernetes to use options: { addOns: { isKubernetesDashboardEnabled: true, isTillerEnabled: false, // Tiller is deprecated in Helm v3 }, admissionControllerOptions: { isPodSecurityPolicyEnabled: false, }, }, // Replace with appropriate values for your setup or use existing key details imagePolicyConfig: { isPolicyEnabled: false, }, // For other configuration like node pools, you can expand this resource definition }); // Set up your Pulumi Kubernetes provider const k8sProvider = new k8s.Provider("k8sProvider", { kubeconfig: cluster.kubeconfigRaw, }); // Helm chart for MongoDB ReplicaSet const mongodbReplicaSetChart = new k8s.helm.v3.Chart("mongodb-replicaset", { chart: "mongodb-replicaset", version: "3.21.3", // specify the exact chart version you want fetchOpts: { repo: "https://charts.bitnami.com/bitnami", // Use the Bitnami Helm repository }, }, { provider: k8sProvider }); // Export the cluster's kubeconfig and the MongoDB service's IP address export const kubeconfig = cluster.kubeconfigRaw; export const mongodbServiceIp = mongodbReplicaSetChart.getResourceProperty("v1/Service", "mongodb-replicaset", "status").apply(status => status.loadBalancer.ingress[0].ip);

    Here is an explanation of the essential parts of the program:

    • OCI Cluster Creation: We use the oci.ContainerEngine.Cluster resource to create a new OKE cluster within your OCI compartment and VCN. Ensure that you have the compartment ID and VCN ID available in your environment.
    • OCI Configuration: The compartmentId and vcnId are set as secrets in the configuration; they should be obtained securely and not hard-coded in your program. Update the kubernetesVersion with the version supported by OKE at the time of deployment.
    • Kubernetes Provider: After deploying the OKE cluster, we need to configure the Kubernetes provider by giving it the kubeconfig of the OKE cluster, allowing Pulumi to perform deployments on the cluster.
    • MongoDB ReplicaSet Chart: We deploy the MongoDB ReplicaSet using the kubernetes.helm.sh/v3.Chart resource. It specifies the Helm chart name, version, and repository.

    After writing this program, you would run pulumi up to provision the resources defined in the code. Remember to set your Pulumi stack configuration for the required variables such as compartmentId and vcnId using the Pulumi CLI beforehand.

    To access the mongodb-replicaset service, you would use the mongodbServiceIp, which is exported at the end of the program. This IP can be used by your applications to connect to your new MongoDB ReplicaSet deployed on Oracle Kubernetes Engine.