1. Deploy the mariadb-persistent helm chart on Google Kubernetes Engine (GKE)


    Deploying a mariadb-persistent helm chart on Google Kubernetes Engine (GKE) involves several steps, which include setting up a GKE cluster and then deploying the Helm chart onto the cluster.

    Below is a detailed explanation and corresponding Pulumi program written in TypeScript that guides you through this process:

    Step 1: Create a GKE Cluster

    First, we need to create a Google Kubernetes Engine (GKE) cluster that the mariadb-persistent Helm chart will be deployed to. We will use the google-native.container/v1beta1.Cluster resource from the google-native provider to create the cluster. It allows us to define properties like the number of nodes, machine types, and the networking to be used by the cluster.

    Step 2: Deploy the Helm Chart

    After the cluster is up and running, we'll deploy the mariadb-persistent Helm Chart. For this, we'll use the helm provider and the helm.sh/v3.Chart resource. This allows us to specify the name of the Helm chart and any configuration that needs to be applied, in addition to specifying the repository where the chart can be found.

    Pulumi Program (index.ts)

    import * as pulumi from "@pulumi/pulumi"; import * as gcp from "@pulumi/gcp"; import * as k8s from "@pulumi/kubernetes"; import * as gcpNative from "@pulumi/google-native"; // Create a GKE cluster const cluster = new gcpNative.container.v1beta1.Cluster("mariadb-cluster", { // Specify the location of the cluster location: "us-central1", // Define properties for the cluster initialNodeCount: 3, // Define the machine type and other properties of nodes in the cluster nodeConfig: { machineType: "n1-standard-1", }, }); // Export the generated kubeconfig for the 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 using the GKE cluster's kubeconfig const k8sProvider = new k8s.Provider("k8s-provider", { kubeconfig: kubeconfig, }); // Deploy the mariadb-persistent helm chart const mariadbChart = new k8s.helm.v3.Chart("mariadb-chart", { // Specify the Helm repository where the chart is hosted and the chart name chart: "mariadb", version: "8.1.2", fetchOpts: { repo: "https://charts.bitnami.com/bitnami", }, // Specify the custom values for the chart values: { // Replace these values with the appropriate configurations // For example, setting persistence storage options and database credentials persistence: { enabled: true, storageClass: "standard", // Use appropriate storage class size: "8Gi", // Define the size of the persistent storage }, // More values like rootUser, passwords, and replication can be configured here }, }, { provider: k8sProvider }); // Export the URL for the mariadb service export const mariadbServiceUrl = pulumi.interpolate`mariadb.${cluster.name}.svc.cluster.local`;


    • We define a new GKE cluster with 3 nodes using the n1-standard-1 machine type.
    • Once the cluster is created, we generate a kubeconfig that is needed to interact with the cluster using the Kubernetes provider.
    • We then create an instance of the Kubernetes provider with the kubeconfig from our GKE cluster.
    • After preparing the provider, we deploy the mariadb-persistent Helm chart from the Bitnami repository, ensuring that persistent storage is enabled with a size of 8Gi. Custom values can be adjusted to modify things like storage size and database credentials.
    • We export the kubeconfig and the internal service URL for MariaDB to connect to our database within the cluster.

    Remember, before running the Pulumi program, make sure to set up and authenticate your Pulumi CLI with Google Cloud by following the Pulumi documentation on Google Cloud Setup. Additionally, you must have the gcloud CLI installed and authenticated on your local machine where you plan to run the Pulumi code.

    You can deploy this program using Pulumi CLI:

    pulumi up

    This will start the deployment process in interactive mode, showing you the resources that will be created before any changes are made. Confirm the changes to start the deployment. After the deployment is complete, it will output the kubeconfig and the mariadbServiceUrl which you can use to interact with your GKE cluster and MariaDB installation respectively.