3.0 KiB
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
-
Change to the
autopilot-cluster
directory.cd autopilot-cluster
-
Create a new file
terraform.tfvars
in that directory.touch terraform.tfvars
-
Open the file for editing.
-
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 = { }
-
Initialize the terraform configuration.
terraform init
-
Apply the terraform configuration.
terraform apply
-
Fetch the cluster credentials.
gcloud container fleet memberships get-credentials cluster --project "<walkthrough-project-name/>"
-
Check the nodes are ready.
kubectl get pods -n kube-system
Install Redis and create associated resources
-
Change to the
patterns/batch
directory.cd ../redis-cluster
-
Create a new file
terraform.tfvars
in that directory.touch terraform.tfvars
-
Open the file for editing.
-
Paste the following content in the file.
credentials_config = { kubeconfig = { path = "~/.kube/config" } } statefulset_config = { replicas = 8 resource_requests = { cpu = "1" memory = "1.5Gi" } }
-
Initialize the terraform configuration.
terraform init
-
Apply the terraform configuration.
terraform apply
-
Check that the Redis pods are ready
kubectl get pods -n redis
-
Check that the Redis volumes match the number of replicas
kubectl get pv
-
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)
-
Change to the
patterns/autopilot-cluster
directory.cd ../autopilot-cluster
-
Destroy the cluster with the following command.
terraform destroy
Congratulations
You’re all set!