fix(k01): apply infra cr documents one by one to avoid scheduler storm
build-and-push-harbor / docker-build-push (push) Waiting to run

This commit is contained in:
zetaloop
2026-05-06 03:44:54 +08:00
parent da43d9b8f7
commit 8dac0b8d76
+26 -4
View File
@@ -4,6 +4,30 @@ set -euo pipefail
INFRA_DIR="$(cd "$(dirname "$0")/infra" && pwd)"
export KUBECONFIG="${KUBECONFIG:-/etc/rancher/k3s/k3s.yaml}"
apply_docs() {
local file="$1" kind="$2" wait_expr="$3" buf i
i=0
buf=""
while IFS= read -r line; do
if [[ "$line" == "---" ]]; then
printf '%s\n' "$buf" | kubectl apply -f -
((i++))
echo " ($i) applied"
buf=""
else
[[ -n "$buf" ]] && buf+=$'\n'
buf+="$line"
fi
done < "$file"
printf '%s\n' "$buf" | kubectl apply -f -
((i++))
echo " ($i) applied"
if [ -n "$kind" ]; then
kubectl -n juwan wait --for="$wait_expr" --timeout=900s "$kind" --all || true
fi
}
echo envoy + ratelimit
kubectl apply -f "${INFRA_DIR}/envoy.yaml"
kubectl apply -f "${INFRA_DIR}/ratelimit.yaml"
@@ -11,12 +35,10 @@ kubectl -n juwan wait --for=condition=Ready pod -l app=envoy-gateway --timeout=1
kubectl -n juwan wait --for=condition=Ready pod -l "app in (ratelimit,rl-redis)" --timeout=120s || true
echo redis
kubectl apply -f "${INFRA_DIR}/redis.yaml"
kubectl -n juwan wait --for=jsonpath='{.status.readyReplicas}'=1 redisreplication --all --timeout=600s || true
apply_docs "${INFRA_DIR}/redis.yaml" redisreplication "jsonpath={.status.readyReplicas}=1"
echo postgres
kubectl apply -f "${INFRA_DIR}/postgres.yaml"
kubectl -n juwan wait --for=condition=Ready cluster --all --timeout=900s || true
apply_docs "${INFRA_DIR}/postgres.yaml" cluster.postgresql.cnpg.io "condition=Ready"
echo mongo
kubectl apply -f "${INFRA_DIR}/mongo.yaml"