Deploy the oracledb-exporter helm chart on Google Kubernetes Engine (GKE)
TypeScriptTo deploy the
oracledb-exporter
Helm chart on Google Kubernetes Engine (GKE), you will create a GKE cluster and then deploy the Helm chart onto it. In Pulumi, this involves two major steps:- Provisioning a GKE Cluster
- Deploying a Helm chart to the GKE Cluster
We will use Pulumi with TypeScript for this task. Here's a step-by-step guide on how you can achieve this:
Step 1: Provision a GKE Cluster
First, you'll need to provision a GKE cluster. You can accomplish this by defining a
Cluster
resource from the@pulumi/google-native
package.Step 2: Deploy the Helm Chart
Once you have your GKE cluster up and running, the next step is to deploy the
oracledb-exporter
Helm chart onto that cluster. This step is possible with theRelease
resource from the@pulumi/kubernetes
package, which allows you to manage Helm chart releases.Remember to configure your Pulumi GCP provider to use the intended project and region.
Here's the TypeScript program to achieve the deployment:
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("my-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 export const clusterName = cluster.name; // Export the Cluster endpoint 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("my-gke-cluster-provider", { kubeconfig: kubeconfig, }); // Deploy the oracledb-exporter Helm chart using the new instance of the provider. const oracledbExporterChart = new k8s.helm.v3.Chart("oracledb-exporter", { chart: "oracledb-exporter", // You should specify the version and repository of the Helm chart here along with any custom values. // A full list of the chart's configurable values can typically be found in its "values.yaml" file or in its documentation. // For example, the version and repository could be specified as follows: // version: "x.y.z", // fetchOpts:{ // repo: "http://helm-repo-url/charts" // }, // values: { // // Custom values for the chart. // }, }, { provider: clusterProvider }); // Export the Deployment name export const deploymentName = oracledbExporterChart.getResourceProperty("v1/Deployment", "oracledb-exporter", "metadata.name");
In this program:
- We create a GKE cluster using the
Cluster
class from the@pulumi/gcp
package. The number of nodes, their type, and OAuth scopes for API access are all specified in thenodeConfig
. - We use the
kubeconfig
to construct the cluster's configuration for the Kubernetes provider to interact with our GKE cluster. - We instantiate a Pulumi Kubernetes provider that targets our newly-created GKE cluster.
- We then deploy the
oracledb-exporter
Helm chart using theChart
class from the@pulumi/kubernetes/helm/v3
package. - Be sure to specify the Helm chart version, repository, and any custom
values
needed for your deployment.
Remember to install the necessary Pulumi packages and configure your GCP credentials in your environment. You can run the Pulumi program using the
pulumi up
command, which will perform the deployment described in the code.