mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 08:17:26 +00:00
Merge pull request #21471 from justinsb/kube_up_auto_upgrade
Auto commit by PR queue bot
This commit is contained in:
commit
2cf3c7809e
@ -999,6 +999,7 @@ function start-master() {
|
|||||||
|
|
||||||
echo "cat > kube_env.yaml << __EOF_MASTER_KUBE_ENV_YAML"
|
echo "cat > kube_env.yaml << __EOF_MASTER_KUBE_ENV_YAML"
|
||||||
cat ${KUBE_TEMP}/master-kube-env.yaml
|
cat ${KUBE_TEMP}/master-kube-env.yaml
|
||||||
|
echo "AUTO_UPGRADE: 'true'"
|
||||||
# TODO: get rid of these exceptions / harmonize with common or GCE
|
# TODO: get rid of these exceptions / harmonize with common or GCE
|
||||||
echo "DOCKER_STORAGE: $(yaml-quote ${DOCKER_STORAGE:-})"
|
echo "DOCKER_STORAGE: $(yaml-quote ${DOCKER_STORAGE:-})"
|
||||||
echo "API_SERVERS: $(yaml-quote ${MASTER_INTERNAL_IP:-})"
|
echo "API_SERVERS: $(yaml-quote ${MASTER_INTERNAL_IP:-})"
|
||||||
@ -1093,6 +1094,7 @@ function start-minions() {
|
|||||||
echo "cd /var/cache/kubernetes-install"
|
echo "cd /var/cache/kubernetes-install"
|
||||||
echo "cat > kube_env.yaml << __EOF_KUBE_ENV_YAML"
|
echo "cat > kube_env.yaml << __EOF_KUBE_ENV_YAML"
|
||||||
cat ${KUBE_TEMP}/node-kube-env.yaml
|
cat ${KUBE_TEMP}/node-kube-env.yaml
|
||||||
|
echo "AUTO_UPGRADE: 'true'"
|
||||||
# TODO: get rid of these exceptions / harmonize with common or GCE
|
# TODO: get rid of these exceptions / harmonize with common or GCE
|
||||||
echo "DOCKER_STORAGE: $(yaml-quote ${DOCKER_STORAGE:-})"
|
echo "DOCKER_STORAGE: $(yaml-quote ${DOCKER_STORAGE:-})"
|
||||||
echo "API_SERVERS: $(yaml-quote ${MASTER_INTERNAL_IP:-})"
|
echo "API_SERVERS: $(yaml-quote ${MASTER_INTERNAL_IP:-})"
|
||||||
|
@ -212,6 +212,57 @@ apt-get-update() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Restart any services that need restarting due to a library upgrade
|
||||||
|
# Uses needrestart
|
||||||
|
restart-updated-services() {
|
||||||
|
# We default to restarting services, because this is only done as part of an update
|
||||||
|
if [[ "${AUTO_RESTART_SERVICES:-true}" != "true" ]]; then
|
||||||
|
echo "Auto restart of services prevented by AUTO_RESTART_SERVICES=${AUTO_RESTART_SERVICES}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
echo "Restarting services with updated libraries (needrestart -r a)"
|
||||||
|
# The pipes make sure that needrestart doesn't think it is running with a TTY
|
||||||
|
# Debian bug #803249; fixed but not necessarily in package repos yet
|
||||||
|
echo "" | needrestart -r a 2>&1 | tee /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
# Reboot the machine if /var/run/reboot-required exists
|
||||||
|
reboot-if-required() {
|
||||||
|
if [[ ! -e "/var/run/reboot-required" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Reboot is required (/var/run/reboot-required detected)"
|
||||||
|
if [[ -e "/var/run/reboot-required.pkgs" ]]; then
|
||||||
|
echo "Packages that triggered reboot:"
|
||||||
|
cat /var/run/reboot-required.pkgs
|
||||||
|
fi
|
||||||
|
|
||||||
|
# We default to rebooting the machine because this is only done as part of an update
|
||||||
|
if [[ "${AUTO_REBOOT:-true}" != "true" ]]; then
|
||||||
|
echo "Reboot prevented by AUTO_REBOOT=${AUTO_REBOOT}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -f /var/run/reboot-required
|
||||||
|
rm -f /var/run/reboot-required.pkgs
|
||||||
|
echo "Triggering reboot"
|
||||||
|
init 6
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install upgrades using unattended-upgrades, then reboot or restart services
|
||||||
|
auto-upgrade() {
|
||||||
|
# We default to not installing upgrades
|
||||||
|
if [[ "${AUTO_UPGRADE:-false}" != "true" ]]; then
|
||||||
|
echo "AUTO_UPGRADE not set to true; won't auto-upgrade"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
apt-get-install unattended-upgrades needrestart
|
||||||
|
unattended-upgrade --debug
|
||||||
|
reboot-if-required # We may reboot the machine right here
|
||||||
|
restart-updated-services
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Install salt from GCS. See README.md for instructions on how to update these
|
# Install salt from GCS. See README.md for instructions on how to update these
|
||||||
# debs.
|
# debs.
|
||||||
@ -834,6 +885,7 @@ if [[ -z "${is_push}" ]]; then
|
|||||||
ensure-install-dir
|
ensure-install-dir
|
||||||
ensure-packages
|
ensure-packages
|
||||||
set-kube-env
|
set-kube-env
|
||||||
|
auto-upgrade
|
||||||
ensure-local-disks
|
ensure-local-disks
|
||||||
[[ "${KUBERNETES_MASTER}" == "true" ]] && mount-master-pd
|
[[ "${KUBERNETES_MASTER}" == "true" ]] && mount-master-pd
|
||||||
create-salt-pillar
|
create-salt-pillar
|
||||||
|
Loading…
Reference in New Issue
Block a user