Deploy the reportportal helm chart on Google Kubernetes Engine (GKE)
TypeScriptTo deploy the ReportPortal helm chart on Google Kubernetes Engine (GKE), we first need to set up a GKE cluster and configure Pulumi to deploy Helm charts to Kubernetes. Here's how we can do it:
-
Set up a GKE cluster: We'll define a GKE cluster resource using the
google-native.container/v1beta1.Cluster
resource. A GKE cluster is a managed Kubernetes cluster hosted on Google Cloud. -
Configure Kubeconfig: Once the cluster is created, we'll obtain the Kubeconfig file that allows us to interact with the cluster using
kubectl
or other Kubernetes tooling. -
Install the Helm chart: With the cluster set up and the Kubeconfig configured, we can deploy the ReportPortal Helm chart to the GKE cluster.
I will provide you with a Pulumi program in TypeScript that covers the above steps. The program will create a GKE cluster and deploy the ReportPortal Helm chart into it.
Before using this program, please ensure you have Pulumi installed and configured for use with Google Cloud. You'll also need to have
kubectl
and Helm CLI installed on your machine to interact with the cluster.Here's the program:
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("reportportal-cluster", { initialNodeCount: 2, 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; // Obtain the Kubeconfig for the newly created GKE cluster 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("gkeK8s", { kubeconfig: kubeconfig, }); // Deploying the ReportPortal Helm chart into our cluster. const reportportal = new k8s.helm.v3.Chart("reportportal", { chart: "reportportal", version: "5.0.0", // specify the version you want to deploy fetchOpts:{ repo: "https://reportportal.github.io/helm-chart", //ReportPortal Helm repo }, }, { provider: k8sProvider }); // Export the ReportPortal Helm release status export const reportportalStatus = reportportal.status;
Detailed Explanation:
GKE Cluster Creation: Firstly, we create a GKE cluster using the
@pulumi/gcp
package. The cluster is configured with an initial node count of 2, and using then1-standard-1
machine type which is good for general purposes.Kubeconfig Generation: We then export the necessary Kubeconfig. This configuration file is necessary for
kubectl
and Pulumi to communicate with your GKE cluster.Helm Chart Deployment: We use the
@pulumi/kubernetes
package to declare a Helm chart resource, specifying the ReportPortal chart and its version. This Helm chart is fetched from the official ReportPortal Helm repo.Resource Exports: Finally, we export the cluster name and the status of the Helm release to provide output that can be used for debugging or information retrieval when the Pulumi program is executed.
When you run this Pulumi program with
pulumi up
, it will perform the following actions:- Provision a GKE cluster.
- Configure Kubeconfig.
- Deploy ReportPortal using Helm.
Make sure to select yes when Pulumi prompts you for confirmation to create these resources. After deployment, you will receive output on the console including the cluster name and the status of the Helm release.
-