mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Trusty: fix several bugs
This commit is contained in:
parent
0af90c1920
commit
10d9f72341
@ -22,7 +22,8 @@
|
|||||||
|
|
||||||
config_hostname() {
|
config_hostname() {
|
||||||
# Set the hostname to the short version.
|
# Set the hostname to the short version.
|
||||||
short_hostname=$(hostname -s)
|
host_name=$(curl --silent "http://metadata.google.internal/computeMetadata/v1/instance/hostname" -H "Metadata-Flavor: Google")
|
||||||
|
short_hostname=$(echo "${host_name}" | cut -d. -f1)
|
||||||
hostname "${short_hostname}"
|
hostname "${short_hostname}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,8 +122,7 @@ install_critical_packages() {
|
|||||||
# Install docker and brctl if they are not in the image.
|
# Install docker and brctl if they are not in the image.
|
||||||
if ! which docker > /dev/null; then
|
if ! which docker > /dev/null; then
|
||||||
echo "Do not find docker. Install it."
|
echo "Do not find docker. Install it."
|
||||||
# We should install the latest qualified docker, which is version 1.8.3 at present.
|
curl -fsSL https://get.docker.com/ | sh
|
||||||
curl -sSL https://get.docker.com/ | DOCKER_VERSION=1.8.3 sh
|
|
||||||
fi
|
fi
|
||||||
if ! which brctl > /dev/null; then
|
if ! which brctl > /dev/null; then
|
||||||
echo "Do not find brctl. Install it."
|
echo "Do not find brctl. Install it."
|
||||||
@ -132,18 +132,22 @@ install_critical_packages() {
|
|||||||
|
|
||||||
# Install the packages that are useful but not required by spinning up a cluster.
|
# Install the packages that are useful but not required by spinning up a cluster.
|
||||||
install_additional_packages() {
|
install_additional_packages() {
|
||||||
# Socat and nsenter are not required for spinning up a cluster. We move the
|
|
||||||
# installation here to be in parallel with the cluster creation.
|
|
||||||
if ! which socat > /dev/null; then
|
if ! which socat > /dev/null; then
|
||||||
echo "Do not find socat. Install it."
|
echo "Do not find socat. Install it."
|
||||||
apt-get install --yes socat
|
apt-get install --yes socat
|
||||||
fi
|
fi
|
||||||
if ! which nsenter > /dev/null; then
|
if ! which nsenter > /dev/null; then
|
||||||
echo "Do not find nsenter. Install it."
|
echo "Do not find nsenter. Install it."
|
||||||
# Note: this is an easy way to install nsenter, but may not be the fastest
|
mkdir -p /tmp/nsenter-install
|
||||||
# way. In addition, this may not be a trusted source. So, replace it if
|
cd /tmp/nsenter-install
|
||||||
# we have a better solution.
|
curl https://www.kernel.org/pub/linux/utils/util-linux/v2.24/util-linux-2.24.tar.gz | tar -zxf-
|
||||||
docker run --rm -v /usr/local/bin:/target jpetazzo/nsenter
|
apt-get --yes install make
|
||||||
|
apt-get --yes install gcc
|
||||||
|
cd util-linux-2.24
|
||||||
|
./configure --without-ncurses
|
||||||
|
make nsenter
|
||||||
|
cp nsenter /usr/local/bin
|
||||||
|
rm -rf /tmp/nsenter-install
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,10 +291,15 @@ restart_docker_daemon() {
|
|||||||
echo "Sleep 1 second to wait for cbr0"
|
echo "Sleep 1 second to wait for cbr0"
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
initctl restart docker
|
|
||||||
# Remove docker0
|
# Remove docker0
|
||||||
ifconfig docker0 down
|
ifconfig docker0 down
|
||||||
brctl delbr docker0
|
brctl delbr docker0
|
||||||
|
# Ensure docker daemon is really functional before exiting. Operations afterwards may
|
||||||
|
# assume it is running.
|
||||||
|
while ! docker version > /dev/null; do
|
||||||
|
echo "Sleep 1 second to wait for docker daemon"
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create the log file and set its properties.
|
# Create the log file and set its properties.
|
||||||
@ -312,10 +321,14 @@ health_monitoring() {
|
|||||||
if ! timeout 10 docker version > /dev/null; then
|
if ! timeout 10 docker version > /dev/null; then
|
||||||
echo "Docker daemon failed!"
|
echo "Docker daemon failed!"
|
||||||
pkill docker
|
pkill docker
|
||||||
|
# Wait for a while, as we don't want to kill it again before it is really up.
|
||||||
|
sleep 30
|
||||||
fi
|
fi
|
||||||
if ! curl --insecure -m "${max_seconds}" -f -s https://127.0.0.1:${KUBELET_PORT:-10250}/healthz > /dev/null; then
|
if ! curl --insecure -m "${max_seconds}" -f -s https://127.0.0.1:${KUBELET_PORT:-10250}/healthz > /dev/null; then
|
||||||
echo "Kubelet is unhealthy!"
|
echo "Kubelet is unhealthy!"
|
||||||
pkill kubelet
|
pkill kubelet
|
||||||
|
# Wait for a while, as we don't want to kill it again before it is really up.
|
||||||
|
sleep 60
|
||||||
fi
|
fi
|
||||||
sleep "${sleep_seconds}"
|
sleep "${sleep_seconds}"
|
||||||
done
|
done
|
||||||
|
@ -144,7 +144,6 @@ script
|
|||||||
--system-cgroups=/system \
|
--system-cgroups=/system \
|
||||||
--runtime-cgroups=/docker-daemon \
|
--runtime-cgroups=/docker-daemon \
|
||||||
--kubelet-cgroups=/kubelet \
|
--kubelet-cgroups=/kubelet \
|
||||||
--babysit-daemons=true \
|
|
||||||
${KUBELET_CMD_FLAGS} 1>>/var/log/kubelet.log 2>&1
|
${KUBELET_CMD_FLAGS} 1>>/var/log/kubelet.log 2>&1
|
||||||
end script
|
end script
|
||||||
|
|
||||||
@ -161,10 +160,7 @@ Content-Disposition: attachment; filename="kube-docker.conf"
|
|||||||
|
|
||||||
description "Restart docker daemon"
|
description "Restart docker daemon"
|
||||||
|
|
||||||
# The condition "stopped kube-install-additional-packages" is to avoid
|
start on started kubelet
|
||||||
# breaking nsenter installation, which is through a docker container.
|
|
||||||
# It can be removed if we find a better way to install nsenter.
|
|
||||||
start on started kubelet and stopped kube-install-additional-packages
|
|
||||||
|
|
||||||
script
|
script
|
||||||
set -o errexit
|
set -o errexit
|
||||||
@ -255,6 +251,9 @@ script
|
|||||||
set -o errexit
|
set -o errexit
|
||||||
set -o nounset
|
set -o nounset
|
||||||
|
|
||||||
|
# Wait for a minute to let docker and kubelet processes finish initialization.
|
||||||
|
# TODO(andyzheng0831): replace it with a more reliable method if possible.
|
||||||
|
sleep 60
|
||||||
. /etc/kube-configure.sh
|
. /etc/kube-configure.sh
|
||||||
. /etc/kube-env
|
. /etc/kube-env
|
||||||
health_monitoring
|
health_monitoring
|
||||||
|
@ -143,7 +143,6 @@ script
|
|||||||
--system-cgroups=/system \
|
--system-cgroups=/system \
|
||||||
--runtime-cgroups=/docker-daemon \
|
--runtime-cgroups=/docker-daemon \
|
||||||
--kubelet-cgroups=/kubelet \
|
--kubelet-cgroups=/kubelet \
|
||||||
--babysit-daemons=true \
|
|
||||||
${KUBELET_CMD_FLAGS} 1>>/var/log/kubelet.log 2>&1
|
${KUBELET_CMD_FLAGS} 1>>/var/log/kubelet.log 2>&1
|
||||||
end script
|
end script
|
||||||
|
|
||||||
@ -160,10 +159,7 @@ Content-Disposition: attachment; filename="kube-docker.conf"
|
|||||||
|
|
||||||
description "Restart docker daemon"
|
description "Restart docker daemon"
|
||||||
|
|
||||||
# The condition "stopped kube-install-additional-packages" is to avoid
|
start on started kubelet
|
||||||
# breaking nsenter installation, which is through a docker container.
|
|
||||||
# It can be removed if we find a better way to install nsenter.
|
|
||||||
start on started kubelet and stopped kube-install-additional-packages
|
|
||||||
|
|
||||||
script
|
script
|
||||||
set -o errexit
|
set -o errexit
|
||||||
|
Loading…
Reference in New Issue
Block a user