1. Deploy the cluster-redis helm chart on Google Kubernetes Engine (GKE)


    To deploy a Redis cluster using the Helm chart on Google Kubernetes Engine (GKE), you will first need to set up a GKE cluster. Once the cluster is running, you can use the Pulumi Kubernetes provider to deploy a Redis cluster using the Helm chart.

    Below, we outline the steps you need to follow using Pulumi with TypeScript. Firstly, you will create a GKE cluster, and then you will deploy the Redis Helm chart onto that cluster.

    Set up the GKE Cluster

    1. Import required packages: We'll use @pulumi/gcp to manage GCP resources like GKE and @pulumi/kubernetes to interact with the Kubernetes API.

    2. Create a GKE cluster: Instantiate a GKE cluster by creating an instance of gcp.container.Cluster.

    3. Configure Kubernetes provider: Once we have a cluster, we will configure a Pulumi Kubernetes provider to deploy resources to that cluster.

    Deploy Redis Using Helm Chart

    1. Use Helm Chart resource: Deploy Redis using the kubernetes.helm.v3.Chart resource, which allows us to specify a Helm chart to deploy, the version, and any custom values we want to pass to our Helm chart.

    2. Configure Redis chart: We provide necessary configurations (such as the name of the chart and any custom values) to the Chart resource.

    Here is the complete TypeScript program to set up the GKE cluster and deploy a Redis Helm chart onto it:

    import * as pulumi from '@pulumi/pulumi'; import * as gcp from '@pulumi/gcp'; import * as k8s from '@pulumi/kubernetes'; // Initialize GKE cluster const gkeCluster = new gcp.container.Cluster('gke-cluster', { // Specify the desired settings for the cluster initialNodeCount: 2, nodeVersion: 'latest', minMasterVersion: 'latest', nodeConfig: { // Select the machine type that suits your needs 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 = gkeCluster.name; // Once we have our cluster, we need to configure the Kubernetes provider with the appropriate kubeconfig. const k8sProvider = new k8s.Provider('k8s-provider', { kubeconfig: gkeCluster.name.apply(name => gcp.container.getCluster({ name: name, location: gkeCluster.location, project: gkeCluster.project, }).then(cluster => cluster.kubeConfig) ), }); // Deploy Redis using the stable/redis Helm chart const redisChart = new k8s.helm.v3.Chart( 'redis-chart', { chart: 'redis', version: '10.5.7', // Specify the version of the chart you wish to deploy fetchOpts:{ repo: 'https://charts.bitnami.com/bitnami', }, values: { // Place any custom values for the Redis Helm chart here usePassword: false, cluster: { enabled: true, slaveCount: 3, }, }, }, { providers: { kubernetes: k8sProvider }, } ); // Export the Redis master service endpoint export const redisMasterServiceEndpoint = redisChart.getResourceProperty( 'v1/Service', 'redis-master', 'status' ).apply(status => status.loadBalancer?.ingress[0]?.ip);


    • We create a new GKE cluster, specifying the initial node count, node version, and other necessary parameters including the machine type using gcp.container.Cluster.
    • We instantiate a Kubernetes provider configured to use the kubeconfig of our new GKE cluster.
    • We deploy the Redis helm chart from the Bitnami repository, configuring it with our desired values like password usage and cluster settings using kubernetes.helm.v3.Chart.
    • Finally, we export the cluster name and the Redis master service endpoint as stack outputs.

    Next Steps

    After saving this program in a file (e.g., index.ts), you need to run it using the Pulumi CLI. You'll need to perform the following steps:

    1. Initialize a new Pulumi project.
    2. Set up the appropriate cloud credentials for GCP.
    3. Run pulumi up to preview and deploy the changes.

    The CLI will prompt you for confirmation before proceeding to create the resources. After the deployment is successful, Pulumi will print the exported values, which include the name of your GKE cluster and the Redis master service endpoint address.