1. Deploy the temporal-stack helm chart on Google Kubernetes Engine (GKE)


    Deploying a Helm chart on Google Kubernetes Engine (GKE) using Pulumi can be achieved by first creating a GKE cluster and then deploying the Helm chart to that cluster.

    Below is a detailed explanation of how to use Pulumi to deploy the temporal-stack Helm chart on GKE. The program written in TypeScript will perform the following actions:

    1. Set up a new GKE cluster: We will create a new GKE cluster, which is where our Helm chart will be deployed. This requires defining the cluster's properties like the location, node count, and machine types.

    2. Deploy the Helm chart to the cluster: Once the cluster is ready, we'll use Pulumi's Helm Release resource to deploy the temporal-stack Helm chart.

    Here's the Pulumi program to accomplish this:

    import * as pulumi from "@pulumi/pulumi"; import * as gcp from "@pulumi/gcp"; import * as k8s from "@pulumi/kubernetes"; // Create a GKE cluster const cluster = new gcp.container.Cluster("my-gke-cluster", { initialNodeCount: 2, nodeConfig: { machineType: "n1-standard-1", // This is a default machine type, you might need to select a different one depending on your workload. oauthScopes: [ "https://www.googleapis.com/auth/compute", "https://www.googleapis.com/auth/devstorage.read_only", "https://www.googleapis.com/auth/logging.write", "https://www.googleapis.com/auth/monitoring" ], }, }); // Export the Cluster name export const clusterName = cluster.name; // Export the Kubeconfig to connect to the cluster using kubectl export const kubeconfig = pulumi. all([cluster.name, cluster.endpoint, cluster.masterAuth]). apply(([name, endpoint, masterAuth]) => { const context = `${gcp.config.project}_${gcp.config.zone}_${name}`; return `apiVersion: v1 clusters: - cluster: certificate-authority-data: ${masterAuth.clusterCaCertificate} server: https://${endpoint} name: ${context} contexts: - context: cluster: ${context} user: ${context} name: ${context} current-context: ${context} kind: Config preferences: {} users: - name: ${context} user: auth-provider: config: cmd-args: config config-helper --format=json cmd-path: gcloud expiry-key: '{.credential.token_expiry}' token-key: '{.credential.access_token}' `; }); // Create a Kubernetes provider instance that uses our cluster from above. const k8sProvider = new k8s.Provider("my-k8s-provider", { kubeconfig: kubeconfig, }); // Use the Helm chart `temporal-stack` from the Temporal Helm repository. const temporalStackChart = new k8s.helm.v3.Release("temporal-stack", { chart: "temporal-stack", version: "0.9.0", // Use the desired chart version. repositoryOpts: { repo: "https://temporalio.github.io/helm-charts", }, }, { provider: k8sProvider }); // Export the Helm release status export const temporalStackStatus = temporalStackChart.status;

    This Pulumi program will complete the necessary steps to set up the GKE cluster and deploy the temporal-stack Helm chart. The kubeconfig is also exported, which allows us to interact with the cluster using kubectl commands from our local machine.

    Please replace 0.9.0 with the version of the temporal-stack chart you wish to deploy. The version specified in the program is given as an example, and you should ensure that it is up to date. You can find the latest chart version and additional configuration options in the Temporal Helm chart repository.

    Before running the program, verify that you have the GCP credentials configured on your machine and that you have installed the Pulumi CLI and logged in.

    You can run the program by executing pulumi up in your shell, which will prompt you to confirm the deployment after showing you a preview. Once confirmed, Pulumi will proceed with creating the resources in the order specified.