Deploy the benthos helm chart on Google Kubernetes Engine (GKE)
TypeScriptDeploying a Helm chart on Google Kubernetes Engine using Pulumi involves several steps. First, you need to create a GKE cluster using
google-native.container.v1beta1.Cluster
. Once the cluster is created, you can deploy your Helm chart to that cluster using thekubernetes.helm.sh/v3.Release
resource.Below is a step-by-step TypeScript program that accomplishes the deployment of the Benthos Helm chart on GKE:
-
Setting up a GKE cluster:
- Import the necessary
google-native
andkubernetes
packages from Pulumi. - Define a GKE cluster resource.
- Make sure you have a Kubernetes context set up in your
.kube/config
so that Pulumi can interact with your cluster.
- Import the necessary
-
Deploying the Benthos Helm chart using Helm Release:
- Import the
@pulumi/kubernetes
package for Helm chart deployment. - Create a new Helm Release, referencing the Benthos chart from a known Helm chart repository.
- Import the
Here's the TypeScript program that performs these tasks:
import * as gcp from "@pulumi/gcp"; import * as k8s from "@pulumi/kubernetes"; import * as pulumi from "@pulumi/pulumi"; // Initialize a new Pulumi project, which allows us to define our infrastructure const projectName = pulumi.getProject(); // Create the GKE cluster const cluster = new gcp.container.Cluster(`${projectName}-cluster`, { initialNodeCount: 2, minMasterVersion: "latest", location: "us-central1-a", 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 configure a Kubernetes provider that uses the cluster's kubeconfig const k8sProvider = new k8s.Provider("k8s-provider", { kubeconfig: cluster.kubeConfigRaw, }); // Deploy the Benthos Helm chart const benthosRelease = new k8s.helm.v3.Release("benthos-release", { chart: "benthos", repositoryOpts: { repo: "https://helm.benthos.dev", }, namespace: "default", values: { // Custom Benthos values can be specified here }, }, { provider: k8sProvider }); // Export the Benthos Release name export const benthosReleaseName = benthosRelease.name;
This program does the following:
- Defines a GKE cluster resource using the
@pulumi/gcp
package with a specified number of nodes, GCP zone, and node machine type. - Exports the created cluster name for future reference.
- Sets up a Pulumi Kubernetes provider that uses the cluster's kubeconfig to allow us to deploy Kubernetes resources.
- Deploys the Benthos Helm chart using
@pulumi/kubernetes
'shelm.v3.Release
resource and specifies the Helm chart repository. - Optionally, you can pass in custom values to the
values
property to configure Benthos according to your needs. - Exports the name of the Benthos Helm release.
To use this program effectively, make sure that:
- You have
gcloud
andkubectl
installed and configured to interact with your GCP account where you have enough permissions to create GKE clusters and deploy resources. - You have the
@pulumi/gcp
and@pulumi/kubernetes
packages installed. - Your Pulumi stack is configured correctly with GCP as the target cloud provider.
To run this Pulumi program:
- Save the code in a file with a
.ts
extension (e.g.,main.ts
). - Run
pulumi up
to preview and deploy the changes.
Remember, deploying a GKE cluster and activating the Kubernetes provider will create resources on GCP that may incur costs. Keep track of these resources and manage them according to your budget and needs.
-