1. Deploy the runners helm chart on Kubernetes


    To deploy a Helm chart using Pulumi, you'll be using the Chart resource from the Pulumi Kubernetes provider. Helm is a popular package manager for Kubernetes, which allows you to define, install, and upgrade even the most complex Kubernetes applications.

    The Chart resource in Pulumi is used to represent a Helm chart, providing a way to deploy entire sets of Kubernetes resources from a single package. It is an example of how Pulumi enables you to write infrastructure as code using familiar programming languages.

    Here's a detailed explanation along with a TypeScript program you would use to deploy a Helm chart for runners on a Kubernetes cluster:

    1. Importing dependencies: Start by importing necessary packages.
    2. Creating a Kubernetes provider: In case you are deploying to a cluster that isn't the default configured in your kubeconfig file, you'll need to specify the provider. Otherwise, this step is not necessary.
    3. Creating a Chart resource: Instantiate a chart by specifying the chart name, version, and any configurable values that the Helm chart accepts.
    4. Exporting relevant data: After deployment, you might want to retrieve and export some information about the deployed resources.

    Let's go through the Pulumi code:

    import * as pulumi from '@pulumi/pulumi'; import * as k8s from '@pulumi/kubernetes'; // Step 1: Create a new Kubernetes provider instance if you're using a non-default cluster. // If your desired cluster is already configured in your kubeconfig, you can omit this step. const clusterProvider = new k8s.Provider('my-provider', { kubeconfig: '<YOUR_KUBECONFIG_CONTENT>', }); // Step 2: Deploy the Helm chart for runners. const runnersChart = new k8s.helm.v3.Chart('runners-chart', { // Replace with the chart's repository and name if it's not from the stable repo, // and provide the exact version if needed. chart: 'runners', version: '1.2.3', // specify the chart version // Assumed to be default if not specified, otherwise update `namespace` accordingly. namespace: 'default', // Values to supply to the Helm chart. values: { // Specify any values needed for customizing the deployment. // These will be specific to the Helm chart you're deploying. // For example: // replicaCount: 2, // runnerRegistrationToken: '<YOUR_REGISTRATION_TOKEN>', // ... other values from the Helm chart's 'values.yaml' file. }, // Specify the provider if using a non-default cluster. // provider: clusterProvider, // Uncomment if you've defined `clusterProvider`. }, { provider: clusterProvider }); // Step 3: (Optional) Export some data from the deployed resources. export const runnerStatus = runnersChart.getResourceProperty('v1/Service', 'my-runner-service', 'status');

    In the above code:

    • Replace <YOUR_KUBECONFIG_CONTENT> with the kubeconfig content that provides access to your cluster, if it's not the default one.
    • The runners in chart: 'runners' is a placeholder. You will need to provide the name of the Helm chart you wish to deploy.
    • The version field is where you specify the version of the Helm chart to deploy. Replace '1.2.3' with the actual chart version.
    • Under values field, provide the necessary configurations required by the Helm chart like replica count, tokens, etc.
    • getResourceProperty is used to fetch status information from a deployed service. Replace 'my-runner-service' with the actual service name you want to get the status for.

    Be sure to check the official Helm chart repository for the specific chart name, version, and default values.yaml. Adjust the values field accordingly to match your deployment needs.

    When you run this Pulumi code with pulumi up, it will deploy the Helm chart for the runners on the specified Kubernetes cluster.

    Remember, deploying applications to a Kubernetes cluster requires that you have a working cluster and the necessary permissions to deploy resources to it. Ensure that these prerequisites are satisfied before you attempt to deploy the Helm chart.