Kubernetes: redis-master using Minikube

This will create a redis-master using Minikube (no slaves or sentinels).

Clone git repository

https://github.com/itsmetommy/kubernetes-redis-master

Create

kubectl -n itsmetommy apply -f .

Example

kubectl -n itsmetommy apply -f .
service "redis-primary" created
statefulset.apps "redis-primary" created

Describe service

kubectl -n itsmetommy describe svc redis-primary

Example

Note the NodePort 31740.

kubectl -n itsmetommy describe svc redis-primary
Name:                     redis-primary
Namespace:                itsmetommy
Labels:                   app=redis-primary
Annotations:              kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app":"redis-primary"},"name":"redis-primary","namespace":"itsmetommy"},"spe...
Selector:                 app=redis-primary
Type:                     NodePort
IP:                       10.103.102.72
Port:                     redis-primary  6379/TCP
TargetPort:               6379/TCP
NodePort:                 redis-primary  31740/TCP
Endpoints:                172.17.0.7:6379
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

Connect to redis-master

redis-cli -h $(minikube ip) -p 31740

Example

redis-cli -h $(minikube ip) -p 31740
192.168.99.101:31740>
➜ stateful-redis-master redis-cli -h $(minikube ip) -p 31740
192.168.99.101:31740> exit

Clean up

kubectl -n itsmetommy delete -f .

Example

kubectl -n itsmetommy delete -f .
service "redis-primary" deleted
statefulset.apps "redis-primary" deleted

Delete pvc

kubectl -n itsmetommy delete pvc -l app=redis-primary

Example

kubectl -n itsmetommy delete pvc -l app=redis-primary
persistentvolumeclaim "redis-primary-redis-primary-0" deleted