Deploy the seldon-core-analytics helm chart on Google Kubernetes Engine (GKE)
TypeScriptTo deploy the
seldon-core-analytics
Helm chart on Google Kubernetes Engine (GKE), you'll need to perform a few high-level steps:- Create a GKE Cluster: You need a running Kubernetes cluster on GKE to which you can deploy the Helm chart. You will use Pulumi's GCP provider to create this cluster.
- Install Helm: Helm is a package manager for Kubernetes, which you'll use to deploy
seldon-core-analytics
. Helm can be installed on your local machine, or you can use Pulumi to install it on the cluster as part of the deployment process. - Deploy the Helm chart: After setting up Helm, you will deploy the
seldon-core-analytics
chart to your GKE cluster.
Below is a complete Pulumi program written in TypeScript that will create a new GKE cluster and deploy the
seldon-core-analytics
Helm chart to it. Before running this program, make sure you've installed Pulumi and configured it to connect to your GCP account.import * as gcp from "@pulumi/gcp"; import * as k8s from "@pulumi/kubernetes"; // Create a GKE cluster const cluster = new gcp.container.Cluster("my-gke-cluster", { initialNodeCount: 2, nodeConfig: { preemptible: true, machineType: "n1-standard-1", }, }); // Export the Cluster name export const clusterName = cluster.name; // Export the Kubeconfig to access your cluster using kubectl export const kubeconfig = cluster.name.apply(name => { const context = `${gcp.config.project}_${gcp.config.zone}_${name}`; return `apiVersion: v1 clusters: - cluster: certificate-authority-data: ${cluster.masterAuth.clusterCaCertificate} server: https://${cluster.endpoint} name: ${context} contexts: - context: cluster: ${context} user: ${context} name: ${context} current-context: ${context} kind: Config preferences: {} users: - name: ${context} user: auth-provider: config: access-token: ${cluster.masterAuth.token} cmd-args: config config-helper --format=json cmd-path: gcloud expiry-key: '{.credential.token_expiry}' token-key: '{.credential.access_token}' name: gcp `; }); // Initialize a new provider using the cluster's kubeconfig const k8sProvider = new k8s.Provider("gkeK8s", { kubeconfig: kubeconfig, }); // Deploy the seldon-core-analytics Helm chart using the k8s provider const seldonCoreAnalyticsChart = new k8s.helm.v3.Chart("seldon-core-analytics", { chart: "seldon-core-analytics", version: "1.1.0", // specify the version of the chart to deploy fetchOpts: { repo: "https://storage.googleapis.com/seldon-charts", // Helm chart repository }, }, { provider: k8sProvider }); // Export the name of the Helm chart deployed export const helmChartName = seldonCoreAnalyticsChart.name;
Explanation:
-
GKE Cluster: The
gcp.container.Cluster
class is used to create a new GKE cluster. This class accepts various arguments likeinitialNodeCount
andnodeConfig
, which define the size and type of cluster you want to create. -
Kubeconfig: We're exporting the kubeconfig file that allows us to interact with our cluster using tools like
kubectl
. It's built using the cluster's output properties. -
Kubernetes Provider: The
k8s.Provider
class initializes a new Kubernetes provider instance with the kubeconfig obtained from the GKE cluster. This provider will be used to manage resources in the Kubernetes cluster. -
Helm Chart: The
seldon-core-analytics
Helm chart is deployed using thek8s.helm.v3.Chart
class, which wraps around Helm operations to interact with charts in a declarative fashion. We need to specify the chart name, version, and repository.
Once you've written this code in a file
index.ts
, you can run it using the following Pulumi CLI commands:pulumi up
This command will provision the resources you've defined in your code. It will prompt you with an overview of changes before applying them.
After successfully deploying your Helm chart, you may want to interact with your GKE cluster, which you can do by setting up
kubectl
with the kubeconfig:pulumi stack output kubeconfig > kubeconfig.yaml export KUBECONFIG=$PWD/kubeconfig.yaml kubectl get pods
Remember to replace
seldon-core-analytics
and its version with the specific ones you intend to use as necessary. The repository URL should also be updated if the chart is located in a different Helm repository.