Skip to content

Commit 457fa6b

Browse files
authored
Merge pull request kubernetes#82413 from zhlhahaha/kube-proxy-error
local-up-cluster kube-proxy terminated error
2 parents 1fcd46c + 6ca5e0e commit 457fa6b

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

hack/lib/util.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,24 @@ kube::util::wait_for_url() {
6464
return 1
6565
}
6666

67+
# Example: kube::util::wait_for_success 120 5 "kubectl get nodes|grep localhost"
68+
# arguments: wait time, sleep time, shell command
69+
# returns 0 if the shell command get output, 1 otherwise.
70+
kube::util::wait_for_success(){
71+
local wait_time="$1"
72+
local sleep_time="$2"
73+
local cmd="$3"
74+
while [ "$wait_time" -gt 0 ]; do
75+
if eval "$cmd"; then
76+
return 0
77+
else
78+
sleep "$sleep_time"
79+
wait_time=$((wait_time-sleep_time))
80+
fi
81+
done
82+
return 1
83+
}
84+
6785
# Example: kube::util::trap_add 'echo "in trap DEBUG"' DEBUG
6886
# See: http://stackoverflow.com/questions/3338030/multiple-bash-traps-for-the-same-signal
6987
kube::util::trap_add() {

hack/local-up-cluster.sh

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,19 @@ function start_cloud_controller_manager {
676676
export CLOUD_CTLRMGR_PID=$!
677677
}
678678

679+
function wait_node_ready(){
680+
# check the nodes information after kubelet daemon start
681+
local nodes_stats="${KUBECTL} --kubeconfig '${CERT_DIR}/admin.kubeconfig' get nodes"
682+
local node_name=$KUBELET_HOST
683+
local system_node_wait_time=30
684+
local interval_time=2
685+
kube::util::wait_for_success "$system_node_wait_time" "$interval_time" "$nodes_stats | grep $node_name"
686+
if [ $? == "1" ]; then
687+
echo "time out on waiting $node_name info"
688+
exit 1
689+
fi
690+
}
691+
679692
function start_kubelet {
680693
KUBELET_LOG=${LOG_DIR}/kubelet.log
681694
mkdir -p "${POD_MANIFEST_PATH}" &>/dev/null || sudo mkdir -p "${POD_MANIFEST_PATH}"
@@ -790,6 +803,10 @@ function start_kubelet {
790803
function start_kubeproxy {
791804
PROXY_LOG=${LOG_DIR}/kube-proxy.log
792805

806+
# wait for kubelet collect node information
807+
echo "wait kubelet ready"
808+
wait_node_ready
809+
793810
cat <<EOF > /tmp/kube-proxy.yaml
794811
apiVersion: kubeproxy.config.k8s.io/v1alpha1
795812
kind: KubeProxyConfiguration
@@ -1003,9 +1020,6 @@ if [[ "${START_MODE}" != "kubeletonly" ]]; then
10031020
if [[ "${EXTERNAL_CLOUD_PROVIDER:-}" == "true" ]]; then
10041021
start_cloud_controller_manager
10051022
fi
1006-
if [[ "${START_MODE}" != "nokubeproxy" ]]; then
1007-
start_kubeproxy
1008-
fi
10091023
start_kubescheduler
10101024
start_kubedns
10111025
if [[ "${ENABLE_NODELOCAL_DNS:-}" == "true" ]]; then
@@ -1031,6 +1045,11 @@ if [[ "${START_MODE}" != "nokubelet" ]]; then
10311045
esac
10321046
fi
10331047

1048+
if [[ "${START_MODE}" != "kubeletonly" ]]; then
1049+
if [[ "${START_MODE}" != "nokubeproxy" ]]; then
1050+
start_kubeproxy
1051+
fi
1052+
fi
10341053
if [[ -n "${PSP_ADMISSION}" && "${AUTHORIZATION_MODE}" = *RBAC* ]]; then
10351054
create_psp_policy
10361055
fi

0 commit comments

Comments
 (0)