Deploy Redis on Kubernetes: StatefulSet with Client Service Access

Deploying Redis on Kubernetes requires a StatefulSet for stable pod identity across restarts and a dedicated client service for load-balanced access from in-cluster applications. This template deploys a 3-replica Redis StatefulSet in a dedicated namespace with password authentication and a ClusterIP service for client connections, and includes step-by-step verification to confirm read/write operations are working correctly.
| Component | Type | Port | Role |
|---|---|---|---|
| Namespace | Namespace | - | Isolates Redis resources in project-redis-dev |
| Redis | StatefulSet | 6379 | 3-replica cluster with stable pod identity and password authentication |
| redis-client-service | ClusterIP Service | 6379 | Load-balanced client access across all Redis pods |
Redis runs as a 3-replica StatefulSet (redis-0, redis-1, redis-2) inside the project-redis-dev namespace, providing stable pod naming and ordered startup. A ClusterIP Service (redis-client-service) on port 6379 distributes client connections across the running Redis pods. Password authentication is enforced at the Redis level, requiring clients to authenticate before issuing commands.
kubectl get pods -n project-redis-dev — you should see redis-0, redis-1, and redis-2 in Running status.kubectl run redis-client --rm -it --image=redis:alpine --restart=Never -n project-redis-dev -- sh.redis-cli -h redis-client-service -p 6379 -a mypassword.PING and confirm the response is PONG, verifying the connection is established.SET testkey "hello" and confirm the response is OK.GET testkey and confirm it returns "hello", verifying read/write operations.QUIT, then type exit to leave and auto-delete the test pod.This template configures a 3-replica Redis StatefulSet on Kubernetes in a dedicated namespace with password authentication and a ClusterIP service for load-balanced client access.