fix(deploy): 补齐集群备份兼容与切换前门禁

阿里云 OSS 的 S3 兼容层要求 virtual-hosted addressing,且 boto3 需要使用 Signature V2。本提交为 Barman 的归档、备份、保留与恢复统一挂载 AWS 配置,并将实际 WAL 归档和近期全备设为切换硬门禁。

同时补充 CNPG/etcdutl 固定版本安装、显式主库切换、三节点逐台停机、OSS 快照下载校验与远端临时 Secret 清理。已通过 ShellCheck、Kustomize、服务端 dry-run、迁移测试、发布脚本测试、敏感信息扫描及生产 precutover 验收。
This commit is contained in:
2026-07-28 06:46:09 +08:00
parent f5b6ff72f2
commit 7c142f5960
13 changed files with 428 additions and 43 deletions
+18 -3
View File
@@ -135,6 +135,21 @@ set -euo pipefail
source_sha=$1
mode=$2
kubectl='k3s kubectl'
runtime_environment=
cleanup_bootstrap_files() {
if [[ -n ${runtime_environment:-} && -f $runtime_environment &&
! -L $runtime_environment ]]; then
shred -u "$runtime_environment"
fi
if [[ -f /root/bootstrap-secrets.yaml && ! -L /root/bootstrap-secrets.yaml ]]; then
shred -u /root/bootstrap-secrets.yaml
fi
for path in /root/cert-manager.yaml /root/cnpg.yaml /root/barman.yaml \
/root/easyai-production.yaml; do
[[ ! -e $path && ! -L $path ]] || unlink "$path"
done
}
trap cleanup_bootstrap_files EXIT HUP INT TERM
$kubectl apply --server-side --force-conflicts -f /root/cert-manager.yaml >/dev/null
$kubectl rollout status deployment/cert-manager -n cert-manager --timeout=180s
@@ -151,7 +166,6 @@ postgres_password=$($kubectl get secret easyai-postgres-app -n easyai \
-o jsonpath='{.data.password}' | base64 -d)
runtime_environment=$(mktemp)
trap 'rm -f -- "$runtime_environment"' EXIT
chmod 0600 "$runtime_environment"
docker inspect easyai-ai-gateway-api-1 \
--format '{{range .Config.Env}}{{println .}}{{end}}' |
@@ -206,6 +220,9 @@ $kubectl create secret generic easyai-registry -n easyai \
--from-file=.dockerconfigjson="$registry_config" --dry-run=client -o yaml |
$kubectl apply -f - >/dev/null
$kubectl apply --server-side --dry-run=server --force-conflicts \
--field-manager=easyai-production-preflight \
-f /root/easyai-production.yaml >/dev/null
$kubectl apply -f /root/easyai-production.yaml >/dev/null
$kubectl annotate namespace easyai easyai.io/release="$source_sha" --overwrite >/dev/null
if [[ $mode == activate ]]; then
@@ -215,8 +232,6 @@ if [[ $mode == activate ]]; then
$kubectl rollout status deployment/easyai-web-ningbo -n easyai --timeout=300s
fi
rm -f -- /root/cert-manager.yaml /root/cnpg.yaml /root/barman.yaml \
/root/easyai-production.yaml /root/bootstrap-secrets.yaml
REMOTE
if [[ $mode == prepare ]]; then