Deploy the banzaicloud-logging-operator-monitoring helm chart on Google Kubernetes Engine (GKE)
TypeScriptTo deploy the
banzaicloud-logging-operator-monitoring
Helm chart on Google Kubernetes Engine (GKE), we will proceed with the following steps:- Set up a GKE cluster by defining a GKE cluster resource.
- Install the
logging-operator
Helm chart on the GKE cluster using the Pulumi Kubernetes Provider.
Setting up Google Kubernetes Engine (GKE) Cluster
First, we need to create a GKE cluster where our Helm chart will be deployed. We use the
Cluster
resource from thegcp.container
module to create the cluster. TheCluster
resource requires properties like the name of the cluster, the location (zone or region), the node settings for the GKE cluster, and any additional features we want to enable on the cluster.Installing the Helm chart
Once the GKE cluster is up and running, we can proceed to deploy Helm charts. We'll use the
Chart
resource from the Pulumi Kubernetes provider. TheChart
resource is a representation of a Helm chart within Pulumi and lets us specify the chart name, version, and any configurations that the chart exposes.Here is a TypeScript program that performs the above operations using Pulumi:
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-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; // Export the Kubeconfig to access the cluster with 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}' name: gcp `; }); // Create a Kubernetes provider instance that uses our cluster from above. const k8sProvider = new k8s.Provider("my-k8s-provider", { kubeconfig: kubeconfig, }); // Deploy the banzaicloud-logging-operator-monitoring Helm chart const loggingOperatorChart = new k8s.helm.v3.Chart("banzaicloud-logging-operator-monitoring", { chart: "banzaicloud-logging-operator-monitoring", version: "3.9.4", // specify the version of the Helm chart fetchOpts:{ repo: "https://kubernetes-charts.banzaicloud.com/", // specify the Helm chart repository }, }, { provider: k8sProvider }); // Export the Helm chart resources export const chartResources = loggingOperatorChart.resources;
This program performs the following operations:
- Creates a GKE cluster named
my-cluster
with 2 nodes of machine typen1-standard-1
. - Exports a kubeconfig file that will allow us to interact with our GKE cluster using tools like
kubectl
. - Initializes a Kubernetes provider for Pulumi to interact with the newly created GKE cluster.
- Deploys the
banzaicloud-logging-operator-monitoring
Helm chart from the specified Helm repository to the GKE cluster with the Kubernetes provider.
To run this Pulumi program, you'll need Node.js and Pulumi installed on your machine, as well as configured access to Google Cloud Platform. Once everything's set up, you can run the program by saving it to a file (e.g.
index.ts
) and executingpulumi up
in your terminal within the same directory.Note that when you instantiate the
k8s.helm.v3.Chart
resource, you must specify the version of the Helm chart that you want to deploy. We use3.9.4
in this example; however, you should check for the latest or desired version of thebanzaicloud-logging-operator-monitoring
Helm chart.More information about the resources used in this program can be found in the following documentation: