9.2.2 Deploying a multirole StatefulSet
View in the book.
Buy the book.
And here’s the Redis StatefulSet that references the ConfigMap
kubectl create -f Chapter09/9.2.2_StatefulSet_Redis_Multi
This time, we’ll get 3 pods, the primary and 2 replicas:
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
redis-0 1/1 Running 0 57s
redis-1 1/1 Running 0 45s
redis-2 0/1 Pending 0 26s
Instead of creating a local docker container, we can also just exec directly in to test.
Connecting to the primary, we can write data:
$ kubectl exec -it redis-0 -- redis-cli
127.0.0.1:6379> SET capital:australia "Canberra"
OK
127.0.0.1:6379> exit
Connecting to one of the replicas, you can read data
$ kubectl exec -it redis-1 -- redis-cli
Defaulted container "redis-container" out of: redis-container, init-redis (init)
127.0.0.1:6379> GET capital:australia
"Canberra"
But not write
127.0.0.1:6379> SET capital:usa "Washington"
(error) READONLY You can't write against a read only replica.
127.0.0.1:6379> exit