Deploy the cloudbees-core helm chart on Google Kubernetes Engine (GKE)
TypeScriptTo deploy the CloudBees Core on a Google Kubernetes Engine (GKE) cluster using Pulumi, we need to complete a couple of steps:
-
Create a GKE cluster: This is the Kubernetes cluster where your applications will be deployed. Google Kubernetes Engine is a managed environment for deploying, managing, and scaling your containerized applications using Google infrastructure.
-
Deploy the CloudBees Core helm chart: Helm charts are packages that contain all of the necessary resources to deploy an application or service to a Kubernetes cluster. CloudBees Core is a CI/CD solution for modern software delivery teams, and it's packaged as a Helm chart for Kubernetes deployments.
Here's a program in TypeScript that performs these two steps using Pulumi's Google Cloud (
gcp
) and Kubernetes (kubernetes
) libraries.Detailed Steps for Deploying CloudBees Core on GKE with Pulumi
Step 1: Import the required libraries
At the beginning of our Pulumi program, we will import the Pulumi packages required for creating a GKE cluster and deploying a Helm chart.
Step 2: Create a GKE cluster
We'll define a GKE cluster. In this example, we're creating a small cluster with just the default node pool options. For production use, you'll likely want to configure more options on the cluster and the node pool.
Step 3: Deploy the Helm chart
With the cluster set up, we can deploy CloudBees Core using its Helm chart. The exact details of the Helm chart, such as version and any custom values, will depend on your specific requirements.
Step 4: Export the Kubeconfig
After the cluster is created, we'll want to export the Kubeconfig file so that we can interact with our cluster using
kubectl
, the command line tool for Kubernetes.Full Pulumi Program
Here's the TypeScript program that accomplishes the tasks above:
import * as gcp from "@pulumi/gcp"; import * as k8s from "@pulumi/kubernetes"; import * as pulumi from "@pulumi/pulumi"; // Step 1: Create a GKE cluster const cluster = new gcp.container.Cluster("cloudbees-core-gke-cluster", { initialNodeCount: 2, nodeVersion: "latest", minMasterVersion: "latest", nodeConfig: { machineType: "e2-medium", 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; // Step 2: Obtain the Kubeconfig for the created cluster 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 export const kubeconfigOutput = kubeconfig; // Step 3: Initialize the Kubernetes Provider using the kubeconfig const k8sProvider = new k8s.Provider("k8s-provider", { kubeconfig: kubeconfig, }); // Step 4: Deploy the CloudBees Core Helm chart using the Kubernetes Provider const cloudbeesHelmChart = new k8s.helm.v3.Chart("cloudbees-core", { chart: "cloudbees-core", version: "3.19.0", // specify the version of the Helm chart fetchOpts: { repo: "https://helm.example.com/", // specify the Helm chart repository URL }, // Set the namespace and any required custom values values: { // Specify any custom values needed for your CloudBees Core deployment. // Refer to the official CloudBees Core Helm chart documentation for details // about the required values. }, }, { provider: k8sProvider }); // Export the endpoint to access the CloudBees Core export const cloudbeesCoreEndpoint = cloudbeesHelmChart.getResourceProperty( "v1/Service", "example-svc", "status", "loadBalancer", "ingress", 0, "ip", );
You’ll need to replace the placeholder values such as
chart
,version
, andfetchOpts.repo
with the actual values corresponding to the CloudBees Core Helm chart you wish to use. You should consult the official CloudBees documentation or the Helm chart repository for these details.Before running this program, ensure you have configured Pulumi with your Google Cloud credentials and have selected the appropriate project and zone where the GKE cluster should be deployed.
Once configured, you can deploy this stack using the Pulumi CLI:
- Run
pulumi up
to preview and deploy the changes. - If the preview looks good, select
yes
to proceed with the deployment.
After deployment, Pulumi will output the
kubeconfigOutput
andcloudbeesCoreEndpoint
, which you can use to configurekubectl
and access your CloudBees Core installation.-