Quickstart: Kubernetes
Attach a Swytch sidecar to a small application and send Redis commands over localhost.
Use Kubernetes 1.33 or newer, Helm, kubectl, and the swytch CLI to
generate credentials. You need permission to install the operator’s CRD, RBAC, and admission webhook. The cluster must
be able to pull the operator and Swytch images.
Use a released Swytch checkout containing operator/, with the chart and
images from that release. From the checkout root:
helm install swytch ./operator/charts/swytch-operator \
--namespace swytch-system --create-namespace --wait
Install one operator per Kubernetes cluster. The chart installs the webhook certificates; cert-manager is not required. For a custom build, follow the operator build instructions.
kubectl create namespace swytch-demo
kubectl -n swytch-demo create secret generic swytch-secret \
--from-literal=cluster-passphrase="$(swytch gen-passphrase)"
This credential authenticates traffic between Swytch peers. Keep it private.
Save this as app-cache.yaml:
apiVersion: swytch.getswytch.com/v1alpha1
kind: Swytch
metadata:
name: app-cache
namespace: swytch-demo
spec:
deployment: sidecar
memory: 512Mi
sidecar:
transport: tcp
discovery:
dns:
secretKeyRef:
name: swytch-secret
key: cluster-passphrase
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: example-app
namespace: swytch-demo
spec:
replicas: 1
selector:
matchLabels:
app: example-app
template:
metadata:
labels:
app: example-app
annotations:
swytch.getswytch.com/profile: app-cache
spec:
containers:
- name: app
image: redis:7.4-alpine
command: [ sh, -c, 'while true; do redis-cli -h 127.0.0.1 PING; sleep 10; done' ]
The redis image supplies the demonstration client. The operator supplies the Swytch server. Put the profile annotation
on the Pod template, as shown.
kubectl apply -f app-cache.yaml
kubectl -n swytch-demo rollout status deployment/example-app
kubectl -n swytch-demo logs deployment/example-app -c app
The application log should show PONG.
kubectl -n swytch-demo exec deployment/example-app -c app -- \
redis-cli SET greeting hello
kubectl -n swytch-demo exec deployment/example-app -c app -- \
redis-cli GET greeting
Expect OK, then hello. Your own application uses the same 127.0.0.1:6379 endpoint. The operator does not set
application connection variables.
This example stores data in memory. Replacing its only Pod loses that state. Choose tiering before depending on restart recovery.
- Sidecar mode for an existing application and Unix sockets.
- Scaling to add application replicas.
- Operations for upgrades, health, and resource limits.
To remove this demo, delete its namespace. This deletes the demo state and credentials:
kubectl delete namespace swytch-demo
The operator stays installed for other workloads.