Skip to content

Commit

Permalink
feat: 支持install_master/node脚本重入 (TencentBlueKing#2532)
Browse files Browse the repository at this point in the history
fix: localpv 相关变量没有渲染到env文件中
  • Loading branch information
bingoct authored Sep 6, 2023
1 parent dfc849b commit 3145ac0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
21 changes: 13 additions & 8 deletions bcs-ops/install_master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,17 @@ safe_source "${ROOT_DIR}/functions/k8s.sh"

safe_source "${ROOT_DIR}/env/bcs.env"

# ToDo: import image: cni\metric
if [[ -n ${BCS_OFFLINE:-} ]]; then
true
fi
# pull image
kubeadm --config="${ROOT_DIR}/kubeadm-config" config images pull \
|| utils::log "FATAL" "fail to pull k8s image"

if [[ -z ${MASTER_JOIN_CMD:-} ]]; then
kubeadm init --config="${ROOT_DIR}/kubeadm-config" -v 11
if systemctl is-active kubelet.service -q; then
utils::log "WARN" "kubelet service is active now, skip kubeadm init"
else
kubeadm init --config="${ROOT_DIR}/kubeadm-config" -v 11 \
|| utils::log "FATAL" "${LAN_IP} failed to join master: ${K8S_CTRL_IP}"
fi
install -dv "$HOME/.kube"
install -v -m 600 -o "$(id -u)" -g "$(id -g)" \
/etc/kubernetes/admin.conf "$HOME/.kube/config"
Expand All @@ -81,13 +82,17 @@ if [[ -z ${MASTER_JOIN_CMD:-} ]]; then
fi

if [[ ${ENABLE_MULTUS_HA} == "true" ]]; then
if ! "${ROOT_DIR}"/k8s/operate_multus apply;then
if ! "${ROOT_DIR}"/k8s/operate_multus apply; then
utils::log "FATAL" "fail to apply multus"
fi
fi
else
kubeadm join --config="${ROOT_DIR}/kubeadm-config" -v 11 \
|| utils::log "FATAL" "${LAN_IP} failed to join master: ${K8S_CTRL_IP}"
if systemctl is-active kubelet.service -q; then
utils::log "WARN" "kubelet service is active now, skip kubeadm join"
else
kubeadm join --config="${ROOT_DIR}/kubeadm-config" -v 11 \
|| utils::log "FATAL" "${LAN_IP} failed to join master: ${K8S_CTRL_IP}"
fi
install -dv "$HOME/.kube"
install -v -m 600 -o "$(id -u)" -g "$(id -g)" \
/etc/kubernetes/admin.conf "$HOME/.kube/config"
Expand Down
15 changes: 8 additions & 7 deletions bcs-ops/install_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,21 @@ case "${K8S_CSI,,}" in
;;
esac

# pull image
if [[ -n ${BCS_OFFLINE:-} ]]; then
# import local image
true
fi
kubeadm --config="${ROOT_DIR}/kubeadm-config" config images pull \
|| utils::log "FATAL" "fail to pull k8s image"

kubeadm join --config="${ROOT_DIR}/kubeadm-config" -v 11
if systemctl is-active kubelet.service -q; then
utils::log "WARN" "kubelet service is active now, skip kubeadm join"
else
kubeadm join --config="${ROOT_DIR}/kubeadm-config" -v 11 \
|| utils::log "FATAL" "${LAN_IP} failed to join cluster: ${K8S_CTRL_IP}"
fi

if [[ "${ENABLE_APISERVER_HA}" == "true" ]]; then
if [[ "${APISERVER_HA_MODE}" == "bcs-apiserver-proxy" ]]; then
init_bap_rule
else
"${ROOT_DIR}"/system/config_bcs_dns -u "${VIP}" k8s-api.bcs.local
systemctl restart kubelet.service
k8s::restart_kubelet
fi
fi
11 changes: 11 additions & 0 deletions bcs-ops/system/config_envfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,17 @@ BCS_CP_WORKER="${BCS_CP_WORKER}"
# csi
K8S_CSI="${K8S_CSI}"
$(
case "${K8S_CSI,,}" in
"localpv")
cat <<CSI_EOF
LOCALPV_DIR="${LOCALPV_DIR}"
LOCALPV_COUNT="${LOCALPV_COUNT}"
LOCALPV_reclaimPolicy="${LOCALPV_reclaimPolicy}"
CSI_EOF
;;
esac
)
## yum_mirror
MIRROR_URL="${MIRROR_URL}"
Expand Down

0 comments on commit 3145ac0

Please sign in to comment.