fix: wait for redpanda before bootstrapping topics
This commit is contained in:
parent
3483579a81
commit
7c0dc83e47
1 changed files with 20 additions and 4 deletions
|
|
@ -4,6 +4,7 @@ metadata:
|
||||||
name: redpanda-topic-bootstrap
|
name: redpanda-topic-bootstrap
|
||||||
namespace: unrip
|
namespace: unrip
|
||||||
spec:
|
spec:
|
||||||
|
backoffLimit: 6
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
restartPolicy: OnFailure
|
restartPolicy: OnFailure
|
||||||
|
|
@ -12,7 +13,22 @@ spec:
|
||||||
image: docker.redpanda.com/redpandadata/redpanda:v24.3.9
|
image: docker.redpanda.com/redpandadata/redpanda:v24.3.9
|
||||||
command: ["/bin/sh", "-lc"]
|
command: ["/bin/sh", "-lc"]
|
||||||
args:
|
args:
|
||||||
- >-
|
- |
|
||||||
rpk topic create raw.near_intents.quote norm.swap_demand cmd.execute_trade exec.trade_result
|
set -eu
|
||||||
--brokers redpanda.unrip.svc.cluster.local:9092
|
BROKERS="redpanda.unrip.svc.cluster.local:9092"
|
||||||
--partitions 1 --replicas 1 || true
|
TOPICS="raw.near_intents.quote norm.swap_demand cmd.execute_trade exec.trade_result"
|
||||||
|
|
||||||
|
echo "waiting for Redpanda at ${BROKERS}"
|
||||||
|
until rpk cluster info --brokers "$BROKERS" >/dev/null 2>&1; do
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
|
||||||
|
for topic in $TOPICS; do
|
||||||
|
if rpk topic describe "$topic" --brokers "$BROKERS" >/dev/null 2>&1; then
|
||||||
|
echo "topic already exists: $topic"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "creating topic: $topic"
|
||||||
|
rpk topic create --brokers "$BROKERS" --partitions 1 --replicas 1 "$topic"
|
||||||
|
done
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue