1. Deploy the mssql-linux helm chart on Digital Ocean Kubernetes Service


    In this guide, you will learn how to deploy a Helm chart that provisions an MSSQL instance running on Linux to a Digital Ocean Kubernetes cluster using Pulumi. We will be using the following Pulumi resources:

    1. digitalocean.KubernetesCluster: To create a Kubernetes cluster on Digital Ocean. This provides you the necessary Kubernetes infrastructure to deploy applications such as the mssql-linux service.

    2. kubernetes.helm.v3.Chart: This resource allows you to deploy Helm charts to a Kubernetes cluster. In this case, you will use it to deploy the mssql-linux chart, which sets up an MSSQL server running in a Linux container.

    Below is a Pulumi program written in TypeScript that accomplishes this deployment. Please ensure you have Pulumi installed, are logged into the Pulumi service, and have the Digital Ocean API access configured. This program assumes you have the necessary Digital Ocean token set up in your Pulumi configuration, or through environment variables.

    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: "nyc3", version: "latest", nodePool: { name: "default", size: "s-2vcpu-2gb", nodeCount: 2, }, }); // Create a provider for the Kubernetes cluster created above const k8sProvider = new k8s.Provider("do-k8s", { kubeconfig: cluster.kubeConfigs[0].rawConfig, }); // Deploy mssql-linux helm chart const mssqlChart = new k8s.helm.v3.Chart("mssql-linux", { chart: "mssql-linux", version: "latest", // specify the version of the chart if necessary fetchOpts: { repo: "https://YOUR_HELM_REPO_URL", // replace with the actual Helm chart repository URL }, }, { provider: k8sProvider }); // Export the Kubeconfig and service endpoint export const kubeconfig = cluster.kubeConfigs[0].rawConfig; export const mssqlServiceEndpoint = pulumi.all([mssqlChart.getResource("v1/Service", "mssql-linux")]).apply(([service]) => { return service.status.loadBalancer.ingress[0].ip; });

    In this program:

    • We start by importing necessary libraries from Pulumi for DigitalOcean and Kubernetes.

    • We define a DigitalOcean Kubernetes cluster do-cluster in the nyc3 region with the latest Kubernetes version and a default node pool configuration.

    • Next, a Kubernetes provider instance do-k8s is created. This provider uses the kubeconfig from the DigitalOcean Kubernetes cluster that we set up, which allows Pulumi to communicate with our DO K8s cluster.

    • We then declare a Helm chart resource mssql-linux using the provided repository URL. You must replace https://YOUR_HELM_REPO_URL with the actual repository URL that hosts the mssql-linux chart. The Helm chart will be installed on the Digital Ocean Kubernetes cluster specified by the provider property.

    • Finally, the program exports the raw kubeconfig necessary to access the cluster using kubectl or any Kubernetes-compatible client and the IP address where the MSSQL service deployed by the Helm chart can be accessed.

    Make sure to replace https://YOUR_HELM_REPO_URL with the appropriate Helm chart repository URL where the mssql-linux chart is hosted. If you are not sure about the version or the repository URL, check the official documentation or Helm repository for the mssql-linux chart for accurate information.

    Once this program is run, Pulumi will provision the resources in the specified order and output the values of the kubeconfig and the mssqlServiceEndpoint. You can use these to interact with your Kubernetes cluster and your newly deployed SQL Server instance.