1. Deploy the rke2-cilium helm chart on Digital Ocean Kubernetes Service

    TypeScript

    When creating a Kubernetes cluster on Digital Ocean and deploying a Helm chart to it, you will be coordinating across two primary resource types: the KubernetesCluster to create the cluster itself and a Helm chart resource to deploy your application.

    We'll start by creating a new Digital Ocean Kubernetes cluster. This will be a simple setup, suitable for learning purposes—feel free to adjust the configurations such as the region, size, or number of nodes to fit your needs. Do note that some values need to be provided such as region and nodePool configurations. We will then install the rke2-cilium Helm chart onto this cluster.

    Pulumi's Kubernetes provider allows you to write code to deploy Helm charts to a Kubernetes cluster. Here, we will be using the Chart resource from the @pulumi/kubernetes/helm/v3 package to deploy the rke2-cilium Helm chart into our newly created Digital Ocean Kubernetes cluster.

    Here's how you can do that with Pulumi and TypeScript:

    import * as pulumi from "@pulumi/pulumi"; import * as digitalocean from "@pulumi/digitalocean"; import * as k8s from "@pulumi/kubernetes"; // Create a Digital Ocean Kubernetes cluster const cluster = new digitalocean.KubernetesCluster("do-cluster", { region: "nyc1", version: "latest", // Specify the version of Kubernetes or use `latest` nodePool: { name: "default", size: "s-2vcpu-2gb", // This is the size of each node in the node pool. nodeCount: 2, // The number of nodes in the node pool. }, }); // Create a Kubernetes Provider pointing to the created cluster const k8sProvider = new k8s.Provider("do-k8sProvider", { kubeconfig: cluster.kubeConfigs[0].rawConfig, }); // Deploy rke2-cilium Helm chart into the cluster const ciliumChart = new k8s.helm.v3.Chart("rke2-cilium", { chart: "cilium", version: "1.9.6", // Specify the chart version, or use `null` for latest fetchOpts:{ // Set the repository opts where the chart can be pulled from repo: "https://helm.cilium.io/", }, // Values to pass to the Helm chart, you can specify custom values based on chart requirements values: { // For example, if you need to specify cilium agent options you would add it under the 'agent' key: // agent: { // someOption: "someValue", // } }, }, { provider: k8sProvider }); // Export the DigitalOcean Kubernetes cluster kubeconfig export const kubeconfig = cluster.kubeConfigs[0].rawConfig;

    This Pulumi program performs the following actions:

    • Provisions a new Digital Ocean Kubernetes cluster named "do-cluster". We create a node pool with two nodes of s-2vcpu-2gb size in the nyc1 region.
    • Establishes a new Kubernetes provider that will communicate with the cluster using the kubeconfig emitted by the Digital Ocean cluster.
    • Deploys the rke2-cilium Helm chart using the Chart resource from Pulumi's Kubernetes provider. The repo field of fetchOpts points to the location of the Helm chart we wish to install, and the values field allows you to override default configuration options if required.

    With the given configuration, Pulumi will automatically handle the necessary arrangements to deploy the requested version of the Helm chart on the Digital Ocean Kubernetes cluster.

    Remember to adjust the values accordingly if needed to fit your deployment requirements, like specifying custom configuration values within the values object for the ciliumChart.

    To run the Pulumi program:

    • Ensure you have the Pulumi CLI installed and are authenticated against your Digital Ocean account.
    • Save the TypeScript code into a file (e.g., index.ts).
    • Run pulumi up within the directory containing the file to perform the deployment. Pulumi will prompt you to confirm your actions before proceeding with the infrastructure updates.

    After pulumi up completes successfully, your Kubernetes cluster will be up and running with the rke2-cilium Helm chart deployed. You can use the exported kubeconfig to interact with your cluster using kubectl.