This commit is contained in:
Yvan
2026-09-05 08:51:14 +08:00
parent ce4ed32dfc
commit c968c2f1f0
3 changed files with 26 additions and 17 deletions
+17 -12
View File
@@ -203,10 +203,8 @@ spec:
replicas: ${KRA_REPLICAS}
revisionHistoryLimit: 3
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
# 单节点 hostPath 不能让新旧 backend Pod 并存,否则会同时操作同一份配置和上传目录。
type: Recreate
selector:
matchLabels:
app.kubernetes.io/name: ${KRA_APP}-backend
@@ -224,12 +222,21 @@ spec:
- name: wait-for-mysql
image: ${KRA_MYSQL_WAIT_IMAGE}
imagePullPolicy: IfNotPresent
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: ${KRA_APP}-runtime
key: mysql-root-password
optional: true
command: ["sh", "-c"]
# 用字面量块(|)而非折叠标量(>-):嵌套缩进会让折叠标量保留换行,
# 把一条命令拆成多行导致 "command not found"。
args:
- >-
- |
if [ "${KRA_DEPLOY_MYSQL}" = "true" ]; then
until mysqladmin ping -h "${KRA_APP}-mysql" -P 3306
--connect-timeout=2 --silent; do sleep 2; done;
test -n "$MYSQL_ROOT_PASSWORD" || { echo "MYSQL_ROOT_PASSWORD is required when bundled MySQL is enabled" >&2; exit 1; }
until mysqladmin ping -h "${KRA_APP}-mysql" -P 3306 -uroot -p"$MYSQL_ROOT_PASSWORD" --connect-timeout=2 --silent; do sleep 2; done;
fi
# 这里只等待 MySQL 服务可达,不要求应用数据库已经初始化;首次部署
# 仍需进入 bootstrap 模式完成 /init/initdb 向导。
@@ -241,7 +248,7 @@ spec:
runAsGroup: 0
command: ["sh", "-c"]
args:
- >-
- |
mkdir -p /data/conf /app/uploads;
if [ ! -f /data/conf/config.yaml ]; then
cp /bootstrap/config.yaml /data/conf/config.yaml;
@@ -380,10 +387,8 @@ spec:
replicas: ${KRA_REPLICAS}
revisionHistoryLimit: 3
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
# 单节点部署只保留一个前端 Pod,避免更新期间短暂扩出第二个 Pod。
type: Recreate
selector:
matchLabels:
app.kubernetes.io/name: ${KRA_APP}-frontend