1. Deploy the tekton-pipeline helm chart on Google Kubernetes Engine (GKE)

    TypeScript

    To deploy the Tekton Pipelines Helm chart on Google Kubernetes Engine (GKE) using Pulumi, you'll need to complete a few steps:

    1. Set up a GKE cluster.
    2. Install Helm and configure it to work with your cluster.
    3. Deploy the Tekton Pipelines Helm chart to your cluster.

    In the following Pulumi TypeScript program, we will perform these steps. Here's a step-by-step explanation of what each part of the program does:

    • Google Kubernetes Engine (GKE) Cluster: This Pulumi program describes the creation of a GKE cluster using google-native.container.v1beta1.Cluster. This defines the version, machine type, and other configuration for the cluster nodes.
    • Kubernetes Provider: After the GKE cluster is up and running, a Kubernetes provider is set up, which configures Pulumi to use the generated kubeconfig from the GKE cluster.
    • Helm Release: Finally, the Tekton Pipelines Helm chart is deployed using kubernetes.helm.v3.Release. This will install Tekton Pipelines into the GKE cluster.

    Make sure you have Pulumi installed and have authenticated access to your Google Cloud account. The GCP project ID and region should be set either through the gcloud CLI or via Pulumi configuration.

    Here is the complete program that accomplishes the deployment:

    import * as gcp from "@pulumi/gcp"; import * as k8s from "@pulumi/kubernetes"; import * as pulumi from "@pulumi/pulumi"; // A new GKE cluster is created with the specified configurations. const cluster = new gcp.container.Cluster("tekton-pipelines-cluster", { initialNodeCount: 2, nodeVersion: "latest", minMasterVersion: "latest", nodeConfig: { machineType: "n1-standard-1", 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; // Once the cluster is created, we can obtain its kubeconfig. 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}' name: gcp `; }); // Export the kubeconfig to standard output export const kubeConfigOutput = kubeconfig; // Create a Kubernetes Provider to interact with the GKE cluster using the generated kubeconfig. const k8sProvider = new k8s.Provider("k8s-provider", { kubeconfig: kubeconfig, }); // Installing Tekton Pipelines using Helm Chart. const tektonPipelinesRelease = new k8s.helm.v3.Release("tekton-pipelines-release", { chart: "tekton-pipelines", version: "0.30.0", // Specify the version of the chart to install. namespace: "default", // You can change the namespace according to where you want to install it. repositoryOpts: { repo: "https://tekton-releases.storage.googleapis.com", // Tekton Pipelines Helm repository URL. }, }, { provider: k8sProvider }); // Export the status of the Helm release export const tektonPipelinesStatus = tektonPipelinesRelease.status;

    This program will do the following when you run pulumi up in your terminal:

    • Create a GKE cluster with the configuration you've specified.
    • Obtain the necessary kubeconfig to communicate with your new cluster.
    • Set up a Pulumi Kubernetes provider configured to use the kubeconfig.
    • Use the Kubernetes provider and the Helm Chart resource to deploy Tekton Pipelines to your cluster.

    Before running this program, ensure all dependencies are installed by running npm install @pulumi/gcp @pulumi/kubernetes @pulumi/pulumi.

    After deploying, you can use the kubectl command-line tool with the printed kubeconfig to interact with your GKE cluster. The export const lines in the program will output the created resources' properties you can use to connect or manage the resources.

    You can learn more about the used resources in their respective Pulumi documentation: