Deploy the kommander-thanos helm chart on Google Kubernetes Engine (GKE)
TypeScriptTo deploy the Kommander Thanos Helm chart on a Google Kubernetes Engine (GKE) cluster, you'll need to follow these steps:
-
Set up a GKE cluster: Define and create a GKE cluster where you will deploy the Helm chart.
-
Install the Helm chart: Once the cluster is available, use Pulumi's Helm support to deploy the Kommander Thanos Helm chart.
Here's a detailed breakdown of the program:
-
GKE Cluster: We'll start by creating a GKE cluster using
google-native.container/v1beta1.Cluster
. A cluster is a set of worker machines, called nodes, where you can run containerized applications. -
Helm Release: After the cluster is up, we'll deploy Kommander Thanos using
kubernetes.helm.sh/v3.Release
, which is the Pulumi resource for deploying Helm charts. With this, you can specify the chart, version, and any values you want to override.
Now, let's go through the code step-by-step:
import * as gcp from "@pulumi/gcp"; import * as k8s from "@pulumi/kubernetes"; import * as pulumi from "@pulumi/pulumi"; // Create a GKE cluster const cluster = new gcp.container.Cluster("gke-cluster", { initialNodeCount: 2, nodeVersion: "latest", // This is illustrative, you may want to pin to a specific version. minMasterVersion: "latest", nodeConfig: { machineType: "n1-standard-1", // Choose an appropriate machine type here. 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 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}' name: gcp `; }); // Create a Kubernetes provider instance that uses our cluster from above. const clusterProvider = new k8s.Provider("gkeK8s", { kubeconfig: kubeconfig, }); // Now we have a K8s cluster, install the Kommander Thanos Helm chart into the cluster. // We will create the Helm Release using Pulumi's kubernetes.helm.v3.Chart. const kommanderThanosChart = new k8s.helm.v3.Chart("kommander-thanos", { chart: "kommander-thanos", version: "0.1.0", // Specify the version of the Helm chart fetchOpts: { repo: "https://mesosphere.github.io/charts", // The Helm repository for Kommander Thanos }, }, { provider: clusterProvider }); // Export the Helm chart name export const helmChartName = kommanderThanosChart.metadata.apply(m => m.name);
This code does the following:
- Defines a GKE cluster with 2 nodes.
- Exports the
kubeconfig
to allowkubectl
and Pulumi's Kubernetes provider to communicate with the GKE cluster. - Sets up a Kubernetes provider to manage resources in the GKE cluster.
- Declares a Helm chart resource to install the Kommander Thanos chart from the specified Helm repository.
Remember to replace the
chart
andversion
fields with the actual chart name and version you intend to deploy. Therepo
URL should point to the Helm repository where the Kommander Thanos chart is hosted.After defining the program, you can deploy your infrastructure with Pulumi commands:
pulumi up
This command will prompt you to review and confirm the changes before applying them to create the resources.
Please, replace the placeholder values with the actual values relevant to your deployment, such as the GKE cluster configuration and the Helm chart version. Ensure you have Pulumi CLI installed, you're logged in, and the GCP credentials are set up correctly.
-