cloud-foundation-fabric/blueprints/gke/patterns/redis-cluster/tutorial.md

3.0 KiB
Raw Blame History

Deploy a Redis cluster on GKE

Objectives

This tutorial covers the following steps:

  • Create a GKE cluster.
  • Create a Redis Cluster on GKE.
  • Confirm the redis is up and running.
  • Confirm creation of the volumes for the stateful set.
  • Confirm the Pod Disruption Budget (PDB).

Estimated time:

To get started, click Start.

select/create a project

Create the Autopilot GKE cluster

  1. Change to the autopilot-cluster directory.

    cd autopilot-cluster 
    
  2. Create a new file terraform.tfvars in that directory.

    touch terraform.tfvars
    
  3. Open the file for editing.

  4. Paste the following content in the file and update any value as needed.

project_id     = "<walkthrough-project-name/>"
cluster_name   = "cluster"
cluster_create = {
  deletion_protection = false
}
region         = "europe-west1"
vpc_create = { }
  1. Initialize the terraform configuration.

    terraform init
    
  2. Apply the terraform configuration.

    terraform apply
    
  3. Fetch the cluster credentials.

    gcloud container fleet memberships get-credentials cluster --project "<walkthrough-project-name/>"
    
  4. Check the nodes are ready.

    kubectl get pods -n kube-system
    

Install Redis and create associated resources

  1. Change to the patterns/batch directory.

    cd ../redis-cluster
    
  2. Create a new file terraform.tfvars in that directory.

    touch terraform.tfvars
    
  3. Open the file for editing.

  4. Paste the following content in the file.

    credentials_config = {
      kubeconfig = {
        path = "~/.kube/config"
      }
    }
    statefulset_config = {
      replicas = 8
      resource_requests = {
        cpu = "1"
        memory = "1.5Gi"
      }
    }
    
  5. Initialize the terraform configuration.

    terraform init
    
  6. Apply the terraform configuration.

    terraform apply
    
  7. Check that the Redis pods are ready

    kubectl get pods -n redis
    
  8. Check that the Redis volumes match the number of replicas

    kubectl get pv
    
  9. Confirm the Pod Disruption Budget for redis guarantees at least 3 pods are up during a voluntary disruption

    kubectl describe pdb redis-pdb -n redis
    

Destroy resources (optional)

  1. Change to the patterns/autopilot-cluster directory.

    cd ../autopilot-cluster
    
  2. Destroy the cluster with the following command.

    terraform destroy
    

Congratulations

Youre all set!