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

    TypeScript

    Deploying a Helm chart to an Oracle Kubernetes Engine (OKE) cluster involves a few steps:

    1. Setting up the OKE Cluster: Before deploying any applications, you need to have an OKE cluster up and running. You can create this using the oci.ContainerEngine.Cluster resource.

    2. Installing the Helm Chart: Once you have a working Kubernetes cluster, you can deploy your Helm chart using the kubernetes.helm.sh/v3.Chart resource from the Kubernetes provider.

    Below is a Pulumi program written in TypeScript that provides a foundation for these steps. The code assumes you've already set up your Pulumi for OCI configuration with the appropriate credentials.

    Please replace the placeholder values with your actual OKE cluster details and Helm chart configuration.

    import * as pulumi from "@pulumi/pulumi"; import * as oci from "@pulumi/oci"; import * as k8s from "@pulumi/kubernetes"; // Create an OCI Kubernetes cluster const cluster = new oci.ContainerEngine.Cluster("myOkeCluster", { // You'll need to provide details such as the compartment Id, VCN, and subnet IDs // as required by your OCI setup, or retrieve them if they've already been created. compartmentId: "your-compartment-id", vcnId: "your-vcn-id", kubernetesVersion: "v1.20.8", options: { serviceLbSubnetIds: ["your-lb-subnet-id-1", "your-lb-subnet-id-2"], }, }); // Assuming kubeconfig is already set up to point to the OCI cluster. // If you're running this in automation, you'll need to use OCI APIs to retrieve the kubeconfig. const provider = new k8s.Provider("okeK8s", { kubeconfig: cluster.kubeconfig, // This should be the content of the kubeconfig file, may require fetching dynamically }); // Deploy the simples-mongodb Helm chart const mongoChart = new k8s.helm.v3.Chart("simpleMongoDb", { chart: "mongodb", version: "10.26.5", // Specify the version of the chart you want to deploy fetchOpts: { repo: "https://charts.bitnami.com/bitnami", }, // You can customize the values for the chart, such as setting persistence, resources, etc. values: { // Any customizable values that people typically set in a values.yaml file }, }, { provider: provider }); // Export the cluster's kubeconfig and MongoDB service endpoint. export const kubeconfig = cluster.kubeconfig; export const mongoEndpoint = mongoChart.getResourceProperty("v1/Service", "simple-mongodb-mongodb", "status").apply(status => status.loadBalancer.ingress[0].ip);

    In this program:

    • We defined a cluster using the oci.ContainerEngine.Cluster resource, specifying important parameters such as the compartment ID, VCN ID, and Kubernetes version.
    • We've created a k8s.Provider which is responsible for the interaction with the Kubernetes cluster. The provider requires a kubeconfig to communicate with the cluster.
    • The k8s.helm.v3.Chart resource is used to deploy the MongoDB Helm chart from the Bitnami repository. This resource takes a fetchOpts property to specify where the chart should be fetched from and a values property to customize the Helm chart's deployment. You would need to specify the chart's version and may need to customize other parameters to suit your use case.
    • Finally, we export the kubeconfig to interact with the cluster and the MongoDB service endpoint.

    Please note that the above code might need adjustments to fit your specific environment and requirements, especially the kubeconfig, which should be securely retrieved and managed. The placeholders like your-compartment-id, your-vcn-id, and your-lb-subnet-id-x need to be replaced with actual values from your Oracle Cloud Infrastructure.

    Keep in mind the management of sensitive information such as credentials. Ensure that they are stored securely and not exposed in plaintext in your Pulumi program.

    For more details on using OCI with Pulumi;

    For more information about Helm charts with Pulumi and Kubernetes:

    Make sure you have the Pulumi CLI installed and the OCI CLI configured with appropriate permissions to create and manage resources. Once the Pulumi program is ready, deploy your stack with the following Pulumi CLI commands:

    pulumi up

    After you've reviewed the proposed changes, you can confirm the deployment, and Pulumi will begin provisioning the resources.

    Remember to destroy your resources once you're done to avoid unnecessary charges:

    pulumi destroy