Skip to content

Commit 80b31b4

Browse files
fix: K8s init container and env var substitution
- Seed node (hypercache-0) skips DNS wait for itself (bootstrap fix) - Use shell entrypoint to sed-substitute POD_IP and POD_NAME into config - Tested: 3-node cluster on Minikube, cluster_size=3, healthy=true
1 parent 9dcaf11 commit 80b31b4

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

k8s/hypercache-cluster.yaml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,18 @@ spec:
141141
- name: wait-for-seed
142142
image: busybox:1.36
143143
command: ['sh', '-c']
144+
env:
145+
- name: POD_NAME
146+
valueFrom:
147+
fieldRef:
148+
fieldPath: metadata.name
144149
args:
145150
- |
151+
# hypercache-0 IS the seed — skip waiting for itself
152+
if [ "$POD_NAME" = "hypercache-0" ]; then
153+
echo "I am the seed node, starting immediately"
154+
exit 0
155+
fi
146156
echo "Waiting for seed node DNS..."
147157
until nslookup hypercache-0.hypercache-headless.hypercache.svc.cluster.local; do
148158
sleep 2
@@ -151,8 +161,14 @@ spec:
151161
containers:
152162
- name: hypercache
153163
image: rishabhverma17/hypercache:latest
154-
command: ["/hypercache"]
155-
args: ["--config", "/config/hypercache.yaml", "--protocol", "resp"]
164+
command: ['sh', '-c']
165+
args:
166+
- |
167+
# Substitute env vars in config template
168+
sed -e "s/\${NODE_ID}/$POD_NAME/g" \
169+
-e "s/\${POD_IP}/$POD_IP/g" \
170+
/config/hypercache.yaml > /tmp/hypercache.yaml
171+
exec /hypercache --config /tmp/hypercache.yaml --protocol resp --node-id "$POD_NAME"
156172
env:
157173
- name: POD_IP
158174
valueFrom:
@@ -162,10 +178,6 @@ spec:
162178
valueFrom:
163179
fieldRef:
164180
fieldPath: metadata.name
165-
- name: NODE_ID
166-
valueFrom:
167-
fieldRef:
168-
fieldPath: metadata.name
169181
ports:
170182
- containerPort: 8080
171183
name: resp

0 commit comments

Comments
 (0)