Fix two issues of master on Trusty

This change moves the code of running and monitoring addon pods in a daemon type upstart job, so that addon manifest monitoring can be restarted automatically upon failure. Second, it updates the usage of "kube-ui" to "dashboard" to match the change in PR #20330.
This commit is contained in:
Andy Zheng 2016-02-05 19:43:09 -08:00
parent 242000d790
commit 20444558a3
2 changed files with 48 additions and 29 deletions

View File

@ -15,10 +15,10 @@
# limitations under the License. # limitations under the License.
# This script contains functions for configuring instances to run kubernetes # This script contains functions for configuring instances to run kubernetes
# nodes. It is uploaded to GCE metadata server when a VM instance is created, # master and nodes. It is uploaded as GCE instance metadata. The upstart jobs
# and then downloaded by the instance. The upstart jobs in # in cluster/gce/trusty/<node.yaml, master.yaml> download it and make use
# cluster/gce/trusty/node.yaml source this script to make use of needed # of needed functions. The script itself is not supposed to be executed in
# functions. The script itself is not supposed to be executed in other manners. # other manners.
config_hostname() { config_hostname() {
# Set the hostname to the short version. # Set the hostname to the short version.
@ -441,10 +441,6 @@ compute_master_manifest_variables() {
if [ -n "${KUBE_DOCKER_REGISTRY:-}" ]; then if [ -n "${KUBE_DOCKER_REGISTRY:-}" ]; then
DOCKER_REGISTRY=${KUBE_DOCKER_REGISTRY} DOCKER_REGISTRY=${KUBE_DOCKER_REGISTRY}
fi fi
KUBECTL_BIN="/usr/bin/kubectl"
if [ "${TEST_CLUSTER:-}" = "true" ]; then
KUBECTL_BIN="/usr/local/bin/kubectl"
fi
} }
# Starts k8s apiserver. # Starts k8s apiserver.
@ -621,13 +617,7 @@ setup_addon_manifests() {
} }
# Start k8s addons static pods. # Start k8s addons static pods.
# prepare_kube_addons() {
# Assumed vars (which are calculated in function compute_master_manifest_variables)
# KUBECTL_BIN
start_kube_addons() {
# Fluentd
start_fluentd
addon_src_dir="/run/kube-manifests/kubernetes/trusty" addon_src_dir="/run/kube-manifests/kubernetes/trusty"
addon_dst_dir="/etc/kubernetes/addons" addon_dst_dir="/etc/kubernetes/addons"
# Set up manifests of other addons. # Set up manifests of other addons.
@ -684,27 +674,19 @@ start_kube_addons() {
setup_addon_manifests "addons" "fluentd-elasticsearch" setup_addon_manifests "addons" "fluentd-elasticsearch"
fi fi
if [ "${ENABLE_CLUSTER_UI:-}" = "true" ]; then if [ "${ENABLE_CLUSTER_UI:-}" = "true" ]; then
setup_addon_manifests "addons" "kube-ui" setup_addon_manifests "addons" "dashboard"
fi fi
if echo "${ADMISSION_CONTROL:-}" | grep -q "LimitRanger"; then if echo "${ADMISSION_CONTROL:-}" | grep -q "LimitRanger"; then
setup_addon_manifests "admission-controls" "limit-range" setup_addon_manifests "admission-controls" "limit-range"
fi fi
# Run scripts to start addons placed in /etc/kubernetes/addons # Prepare the scripts for running addons.
addon_script_dir="/var/lib/cloud/scripts/kubernetes" addon_script_dir="/var/lib/cloud/scripts/kubernetes"
mkdir -p "${addon_script_dir}" mkdir -p "${addon_script_dir}"
cp "${addon_src_dir}/kube-addons.sh" "${addon_script_dir}" cp "${addon_src_dir}/kube-addons.sh" "${addon_script_dir}"
cp "${addon_src_dir}/kube-addon-update.sh" "${addon_script_dir}" cp "${addon_src_dir}/kube-addon-update.sh" "${addon_script_dir}"
chmod 544 "${addon_script_dir}/"*.sh chmod 544 "${addon_script_dir}/"*.sh
# In case that upstart does not set the HOME variable or sometimes # In case that some GCE customized trusty may have a read-only /root.
# GCE customized trusty has a read-only /root. mount -t tmpfs tmpfs /root
export HOME="/root" mount --bind -o remount,rw,noexec /root
mount -t tmpfs tmpfs "${HOME}"
mount --bind -o remount,rw,noexec "${HOME}"
export KUBECTL_BIN
export TOKEN_DIR="/etc/srv/kubernetes"
export kubelet_kubeconfig_file="/var/lib/kubelet/kubeconfig"
export TRUSTY_MASTER="true"
# Run the script to start and monitoring addon manifest changes.
/bin/bash "${addon_script_dir}/kube-addons.sh"
} }

View File

@ -204,13 +204,50 @@ script
. /etc/kube-configure.sh . /etc/kube-configure.sh
. /etc/kube-env . /etc/kube-env
start_etcd_servers start_etcd_servers
start_fluentd
compute_master_manifest_variables compute_master_manifest_variables
start_kube_apiserver start_kube_apiserver
start_kube_controller_manager start_kube_controller_manager
start_kube_scheduler start_kube_scheduler
start_kube_addons prepare_kube_addons
end script end script
--====================================
MIME-Version: 1.0
Content-Type: text/upstart-job; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="kube-addons.conf"
#upstart-job
description "Run kubernetes addon pods"
start on stopped kube-master-components
respawn
script
set -o errexit
set -o nounset
. /etc/kube-env
export HOME="/root"
if [ "${TEST_CLUSTER:-}" = "true" ]; then
export KUBECTL_BIN="/usr/local/bin/kubectl"
else
export KUBECTL_BIN="/usr/bin/kubectl"
fi
export TOKEN_DIR="/etc/srv/kubernetes"
export kubelet_kubeconfig_file="/var/lib/kubelet/kubeconfig"
export TRUSTY_MASTER="true"
# Run the script to start and monitoring addon manifest changes.
exec /var/lib/cloud/scripts/kubernetes/kube-addons.sh
end script
# Wait for 10s to start it again.
post-stop exec sleep 10
--==================================== --====================================
MIME-Version: 1.0 MIME-Version: 1.0
Content-Type: text/upstart-job; charset="us-ascii" Content-Type: text/upstart-job; charset="us-ascii"