K3s 1.36 将 Registry 镜像端点生成在 containerd/certs.d 子目录;验收改为递归检查整个 containerd 配置树,并继续以实际拉取 pause 镜像作为最终门禁。 验证:洛杉矶节点 Ready,三个 hosts.toml 端点存在,pause 镜像拉取成功。
46 lines
1.5 KiB
Bash
Executable File
46 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
# shellcheck source=scripts/cluster/common.sh
|
|
source "$script_dir/common.sh"
|
|
load_cluster_env
|
|
|
|
registry_config="$cluster_root/deploy/kubernetes/registries.yaml"
|
|
[[ -f $registry_config && ! -L $registry_config ]] || {
|
|
echo 'K3s registry mirror configuration is unavailable' >&2
|
|
exit 1
|
|
}
|
|
|
|
restart_node() {
|
|
local host=$1
|
|
local node=$2
|
|
local observer=$3
|
|
local ready=false
|
|
cluster_scp "$registry_config" "$host:/etc/rancher/k3s/registries.yaml"
|
|
cluster_ssh "$host" \
|
|
'chmod 0600 /etc/rancher/k3s/registries.yaml && systemctl restart k3s'
|
|
for _ in $(seq 1 60); do
|
|
if cluster_ssh "$observer" \
|
|
"k3s kubectl wait --for=condition=Ready node/$node --timeout=5s >/dev/null 2>&1"; then
|
|
ready=true
|
|
break
|
|
fi
|
|
sleep 2
|
|
done
|
|
[[ $ready == true ]] || {
|
|
echo "K3s node did not return Ready after registry mirror update: $node" >&2
|
|
return 1
|
|
}
|
|
cluster_ssh "$host" \
|
|
"grep -RFq 'https://docker.m.daocloud.io' /var/lib/rancher/k3s/agent/etc/containerd && k3s crictl pull docker.io/rancher/mirrored-pause:3.6 >/dev/null"
|
|
echo "[registry] $node ready"
|
|
}
|
|
|
|
# Restart one etcd member at a time and observe it from a different server.
|
|
restart_node "$CLUSTER_LOS_ANGELES_HOST" easyai-los-angeles "$CLUSTER_NINGBO_HOST"
|
|
restart_node "$CLUSTER_HONGKONG_HOST" easyai-hongkong "$CLUSTER_NINGBO_HOST"
|
|
restart_node "$CLUSTER_NINGBO_HOST" easyai-ningbo "$CLUSTER_HONGKONG_HOST"
|
|
|
|
echo 'k3s_registry_mirrors=PASS nodes=3 quorum_preserved=true'
|