Run Valkey (Redis)
This assumes you can already reach your cluster with kubectl (see the
kubectl quickstart).
Valkey is an in-memory key/value store for caching,
sessions, and queues. It’s the BSD-licensed, Linux Foundation fork of Redis and
a drop-in replacement: the same wire protocol and the same clients
(redis-py, ioredis, Jedis, go-redis, …) work unchanged. You’ll deploy a
single instance in its own namespace, with persistence so its data survives pod
restarts.
Deploy
Section titled “Deploy”Create a dedicated namespace:
kubectl create namespace valkeyDeploy Valkey, its storage, and a Service into the namespace:
cat <<'EOF' | kubectl apply -f -apiVersion: v1kind: Secretmetadata: name: valkey namespace: valkeystringData: VALKEY_PASSWORD: change-me---apiVersion: v1kind: PersistentVolumeClaimmetadata: name: valkey namespace: valkeyspec: accessModes: - ReadWriteOnce resources: requests: storage: 5Gi---apiVersion: apps/v1kind: Deploymentmetadata: name: valkey namespace: valkeyspec: replicas: 1 strategy: type: Recreate selector: matchLabels: app: valkey template: metadata: labels: app: valkey spec: containers: - name: valkey image: valkey/valkey:8 command: - sh - -c - exec valkey-server --requirepass "$VALKEY_PASSWORD" --appendonly yes env: - name: VALKEY_PASSWORD valueFrom: secretKeyRef: name: valkey key: VALKEY_PASSWORD ports: - containerPort: 6379 volumeMounts: - name: data mountPath: /data volumes: - name: data persistentVolumeClaim: claimName: valkey---apiVersion: v1kind: Servicemetadata: name: valkey namespace: valkeyspec: selector: app: valkey ports: - port: 6379 targetPort: 6379EOFSecurity
Section titled “Security”This Service is ClusterIP, so the store is only reachable from inside the
cluster. On a single-tenant skube cluster that’s the safe default: keep your app
and Valkey in the cluster and connect over the Service.
If you need to reach it from outside the cluster:
- For occasional access, prefer
kubectl port-forward -n valkey service/valkey 6379:6379over a public endpoint. It tunnels through the API server and exposes nothing. - Valkey speaks its own TCP protocol, not HTTP, so the Ingress and Gateway guides don’t apply. To expose it for real, enable Valkey’s own TLS.
- Use a strong password, not
change-me, and rotate the secret if it leaks.
Connect
Section titled “Connect”Check it’s responding (use the password you set above):
kubectl exec -n valkey deploy/valkey -- valkey-cli -a change-me pingA PONG response means it’s up. Open an interactive shell:
kubectl exec -n valkey -it deploy/valkey -- valkey-cli -a change-meFrom there, the basics, store a value, read it back, and set one that expires:
SET greeting "hello from skube"GET greetingSET session:42 active EX 30 # expires in 30 secondsTTL session:42 # seconds leftDBSIZE # number of keysDEL greetingOther workloads in the cluster connect with this URL (<password> is the value
from the secret above):
redis://:<password>@valkey.valkey.svc.cluster.local:6379Clean up
Section titled “Clean up”Delete the namespace to remove everything at once:
kubectl delete namespace valkeyThis destroys the stored data along with it.