Deploy the pangeo helm chart on Google Kubernetes Engine (GKE)
TypeScriptTo deploy the Pangeo Helm chart on Google Kubernetes Engine (GKE), we will be following these steps:
-
Set up a GKE cluster: We will need a Kubernetes cluster running on Google Cloud to deploy our Helm chart. We will use Pulumi's
google-native.container/v1beta1.Cluster
resource to provision a GKE cluster. -
Install the Pulumi Kubernetes provider: This provider will allow us to interact with the Kubernetes API to deploy and manage resources like our Helm chart.
-
Deploy Pangeo Helm chart: Once we have our Kubernetes cluster, we will deploy the Pangeo Helm chart using the
harness.service.Helm
resource, which will allow us to define the Helm release and its configuration.
Detailed Steps and Pulumi Program
First, we will write a Pulumi program in TypeScript. This program will create a GKE cluster and deploy the Pangeo Helm chart on it.
Make sure you have the following prerequisites in place before running the Pulumi program:
- Pulumi CLI installed
- Google Cloud SDK installed and configured with necessary permissions
- A Pulumi account set up and the Pulumi project initialized (run
pulumi new
to create a new project if needed)
Now, let's write our Pulumi program:
import * as pulumi from '@pulumi/pulumi'; import * as gcp from '@pulumi/gcp'; import * as k8s from '@pulumi/kubernetes'; // Step 1: Provision a Google Kubernetes Engine (GKE) cluster const cluster = new gcp.container.Cluster('pangeo-gke-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 and Kubeconfig export const clusterName = cluster.name; 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 `; }); // Step 2: Configure Kubernetes provider to use the generated kubeconfig const k8sProvider = new k8s.Provider('k8s-provider', { kubeconfig: kubeconfig, }); // Step 3: Deploy Pangeo Helm chart const pangeoRelease = new k8s.helm.v3.Chart('pangeo', { chart: 'pangeo', version: '0.1.0', // Please replace with the actual chart version fetchOpts:{ repo: 'https://pangeo-data.github.io/helm-chart/', // Helm chart repository }, }, { provider: k8sProvider }); // Export the Pangeo Helm release status export const pangeoStatus = pangeoRelease.status;
In the code above, we start by creating a GKE cluster with a default node pool consisting of 2 nodes of type
n1-standard-1
. Feel free to adjust the machine type and the number of nodes as per your requirements. Next, we create a kubeconfig for accessing the GKE cluster. This configuration is constructed by pulling information from the created cluster, such as its endpoint and master authentication credentials.We also configure the Kubernetes provider with the generated kubeconfig to interact
-