towerops/k8s/valkey-statefulset.yaml
Graham McIntire 7f7cbac965
Add init container to Valkey to wait for Flannel CNI readiness
Prevents FailedCreatePodSandBox errors when talos-worker1 reboots and pods
try to start before Flannel writes /run/flannel/subnet.env.

Init container polls DNS resolution until network is ready before starting Valkey.
2026-01-20 11:41:21 -06:00

90 lines
2.4 KiB
YAML

---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: valkey
namespace: towerops
spec:
serviceName: valkey
replicas: 1
selector:
matchLabels:
app: valkey
template:
metadata:
labels:
app: valkey
spec:
# Use system-cluster-critical priority to ensure Valkey starts after CNI is ready
priorityClassName: system-cluster-critical
securityContext:
runAsNonRoot: true
runAsUser: 999
fsGroup: 999
seccompProfile:
type: RuntimeDefault
# Init container to wait for network to be ready (Flannel CNI)
initContainers:
- name: wait-for-network
image: busybox:1.36
command:
- sh
- -c
- |
echo "Waiting for network to be ready..."
until nslookup kubernetes.default.svc.cluster.local > /dev/null 2>&1; do
echo "Network not ready, retrying in 2s..."
sleep 2
done
echo "Network is ready!"
securityContext:
allowPrivilegeEscalation: false
runAsNonRoot: true
runAsUser: 999
capabilities:
drop:
- ALL
seccompProfile:
type: RuntimeDefault
containers:
- name: valkey
image: valkey/valkey:8.0-alpine
imagePullPolicy: IfNotPresent
securityContext:
allowPrivilegeEscalation: false
runAsNonRoot: true
runAsUser: 999
capabilities:
drop:
- ALL
seccompProfile:
type: RuntimeDefault
ports:
- containerPort: 6379
name: valkey
resources:
requests:
memory: "128Mi"
cpu: "50m"
limits:
memory: "512Mi"
cpu: "200m"
livenessProbe:
exec:
command:
- valkey-cli
- ping
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 2
failureThreshold: 3
readinessProbe:
exec:
command:
- valkey-cli
- ping
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 2
successThreshold: 1
failureThreshold: 2