Skip to content

Commit

Permalink
Merge branch 'release-1.2' into automated-cherry-pick-of-kubernetes#2…
Browse files Browse the repository at this point in the history
…5405-upstream-release-1.2
  • Loading branch information
roberthbailey committed Jun 6, 2016
2 parents fa15d93 + e58faac commit f83a12d
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 38 deletions.
12 changes: 8 additions & 4 deletions cluster/gce/trusty/configure-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,14 @@ assemble_kubelet_flags() {
fi
# Add the unconditional flags
KUBELET_CMD_FLAGS="${KUBELET_CMD_FLAGS} --cloud-provider=gce --allow-privileged=true --cgroup-root=/ --system-cgroups=/system --kubelet-cgroups=/kubelet --babysit-daemons=true --config=/etc/kubernetes/manifests --cluster-dns=${DNS_SERVER_IP} --cluster-domain=${DNS_DOMAIN}"
echo "KUBELET_OPTS=\"${KUBELET_CMD_FLAGS}\"" > /etc/default/kubelet
}

restart_docker_daemon() {
readonly DOCKER_OPTS="-p /var/run/docker.pid --bridge=cbr0 --iptables=false --ip-masq=false"
DOCKER_OPTS="-p /var/run/docker.pid --bridge=cbr0 --iptables=false --ip-masq=false"
if [ "${TEST_CLUSTER:-}" = "true" ]; then
DOCKER_OPTS="${DOCKER_OPTS} --debug"
fi
echo "DOCKER_OPTS=\"${DOCKER_OPTS} ${EXTRA_DOCKER_OPTS:-}\"" > /etc/default/docker
# Make sure the network interface cbr0 is created before restarting docker daemon
while ! [ -L /sys/class/net/cbr0 ]; do
Expand Down Expand Up @@ -587,15 +591,15 @@ setup_addon_manifests() {
if [ ! -d "${dst_dir}" ]; then
mkdir -p "${dst_dir}"
fi
files=$(find "${src_dir}" -name "*.yaml")
files=$(find "${src_dir}" -maxdepth 1 -name "*.yaml")
if [ -n "${files}" ]; then
cp "${src_dir}/"*.yaml "${dst_dir}"
fi
files=$(find "${src_dir}" -name "*.json")
files=$(find "${src_dir}" -maxdepth 1 -name "*.json")
if [ -n "${files}" ]; then
cp "${src_dir}/"*.json "${dst_dir}"
fi
files=$(find "${src_dir}" -name "*.yaml.in")
files=$(find "${src_dir}" -maxdepth 1 -name "*.yaml.in")
if [ -n "${files}" ]; then
cp "${src_dir}/"*.yaml.in "${dst_dir}"
fi
Expand Down
33 changes: 25 additions & 8 deletions cluster/gce/trusty/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,34 @@ install_kube_binary_config() {
# a test cluster.
readonly BIN_PATH="/usr/bin"
if ! which kubelet > /dev/null || ! which kubectl > /dev/null; then
# This should be the case of trusty.
cp "${src_dir}/kubelet" "${BIN_PATH}"
cp "${src_dir}/kubectl" "${BIN_PATH}"
elif [ "${TEST_CLUSTER:-}" = "true" ]; then
kube_bin="${kube_home}/bin"
else
# This should be the case of GCI.
readonly kube_bin="${kube_home}/bin"
mkdir -p "${kube_bin}"
mount --bind "${kube_bin}" "${kube_bin}"
mount -o remount,rw,exec "${kube_bin}"
cp "${src_dir}/kubelet" "${kube_bin}"
cp "${src_dir}/kubectl" "${kube_bin}"
mount --bind "${kube_bin}/kubelet" "${BIN_PATH}/kubelet"
mount --bind -o remount,ro,^noexec "${BIN_PATH}/kubelet" "${BIN_PATH}/kubelet"
mount --bind "${kube_bin}/kubectl" "${BIN_PATH}/kubectl"
mount --bind -o remount,ro,^noexec "${BIN_PATH}/kubectl" "${BIN_PATH}/kubectl"
chmod 544 "${kube_bin}/kubelet"
chmod 544 "${kube_bin}/kubectl"
# If the built-in binary version is different from the expected version, we use
# the downloaded binary. The simplest implementation is to always use the downloaded
# binary without checking the version. But we have another version guardian in GKE.
# So, we compare the versions to ensure this run-time binary replacement is only
# applied for OSS kubernetes.
readonly builtin_version="$(/usr/bin/kubelet --version=true | cut -f2 -d " ")"
readonly required_version="$(/home/kubernetes/bin/kubelet --version=true | cut -f2 -d " ")"
if [ "${TEST_CLUSTER:-}" = "true" ] || [ "${builtin_version}" != "${required_version}" ]; then
mount --bind "${kube_bin}/kubelet" "${BIN_PATH}/kubelet"
mount --bind "${kube_bin}/kubectl" "${BIN_PATH}/kubectl"
else
# Remove downloaded binary just to prevent misuse.
rm -f "${kube_bin}/kubelet"
rm -f "${kube_bin}/kubectl"
fi
fi

# Put kube-system pods manifests in /home/kubernetes/kube-manifests/.
Expand All @@ -152,9 +169,9 @@ install_kube_binary_config() {
tar xzf "${kube_home}/${manifests_tar}" -C "${dst_dir}" --overwrite
readonly kube_addon_registry="${KUBE_ADDON_REGISTRY:-gcr.io/google_containers}"
if [ "${kube_addon_registry}" != "gcr.io/google_containers" ]; then
find "${dst_dir}" -name \*.yaml -or -name \*.yaml.in | \
find "${dst_dir}" -maxdepth 1 -name \*.yaml -or -maxdepth 1 -name \*.yaml.in | \
xargs sed -ri "s@(image:\s.*)gcr.io/google_containers@\1${kube_addon_registry}@"
find "${dst_dir}" -name \*.manifest -or -name \*.json | \
find "${dst_dir}" -maxdepth 1 -name \*.manifest -or -maxdepth 1 -name \*.json | \
xargs sed -ri "s@(image\":\s+\")gcr.io/google_containers@\1${kube_addon_registry}@"
fi
cp "${dst_dir}/kubernetes/gci-trusty/configure-helper.sh" /etc/kube-configure-helper.sh
Expand Down
33 changes: 25 additions & 8 deletions cluster/gce/trusty/master.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From nobody Thu Mar 10 10:33:00 2016
From nobody Thu May 13 20:33:00 2016
Content-Type: multipart/mixed; boundary="===================================="
MIME-Version: 1.0

Expand All @@ -15,6 +15,7 @@ description "Download and install k8s binaries and configurations"
start on cloud-config

script
{
set -o errexit
set -o nounset

Expand All @@ -29,6 +30,7 @@ script
. /etc/kube-env
echo "Install kube master binary and configuration files"
install_kube_binary_config
} 2>&1 | logger --priority daemon.info -t ${UPSTART_JOB}
end script

--====================================
Expand All @@ -44,6 +46,7 @@ description "Prepare kube master environment"
start on stopped kube-install-master

script
{
set -o errexit
set -o nounset

Expand All @@ -60,7 +63,11 @@ script
echo "Creating kuberntes master auth file"
create_master_auth
echo "Creating master instance kubelet auth file"
create_master_kubelet_auth
create_master_kubelet_auth
echo "Assemble kubelet command line"
# Kubelet command flags will be written in /etc/default/kubelet
assemble_kubelet_flags
} 2>&1 | logger --priority daemon.info -t ${UPSTART_JOB}
end script

--====================================
Expand All @@ -76,11 +83,13 @@ description "Install packages needed to run kubernetes"
start on stopped kube-install-master

script
{
set -o errexit
set -o nounset

. /etc/kube-configure-helper.sh
install_critical_packages
} 2>&1 | logger --priority daemon.info -t ${UPSTART_JOB}
end script

--====================================
Expand All @@ -96,11 +105,13 @@ description "Install additional packages used by kubernetes"
start on stopped kube-install-packages

script
{
set -o errexit
set -o nounset

. /etc/kube-configure-helper.sh
install_additional_packages
} 2>&1 | logger --priority daemon.info -t ${UPSTART_JOB}
end script

--====================================
Expand All @@ -118,16 +129,14 @@ start on stopped kube-install-packages and stopped kube-env
respawn

script
{
set -o errexit
set -o nounset

echo "Start kubelet upstart job"
. /etc/kube-configure-helper.sh
. /etc/kube-env
# Assemble command line flags based on env variables, which will put the string
# of flags in variable KUBELET_CMD_FLAGS
assemble_kubelet_flags
/usr/bin/kubelet ${KUBELET_CMD_FLAGS} 1>>/var/log/kubelet.log 2>&1
. /etc/default/kubelet
/usr/bin/kubelet ${KUBELET_OPTS} 1>>/var/log/kubelet.log 2>&1
} 2>&1 | logger --priority daemon.info -t ${UPSTART_JOB}
end script

# Wait for 10s to start kubelet again.
Expand All @@ -146,12 +155,14 @@ description "Restart docker daemon"
start on started kubelet

script
{
set -o errexit
set -o nounset

. /etc/kube-configure-helper.sh
. /etc/kube-env
restart_docker_daemon
} 2>&1 | logger --priority daemon.info -t ${UPSTART_JOB}
end script

--====================================
Expand All @@ -167,6 +178,7 @@ description "Start kube-master components and addons pods"
start on stopped kube-docker

script
{
set -o errexit
set -o nounset

Expand All @@ -179,6 +191,7 @@ script
start_kube_controller_manager
start_kube_scheduler
prepare_kube_addons
} 2>&1 | logger --priority daemon.info -t ${UPSTART_JOB}
end script

--====================================
Expand All @@ -196,6 +209,7 @@ start on stopped kube-master-components
respawn

script
{
set -o errexit
set -o nounset

Expand All @@ -210,6 +224,7 @@ script
fi
# Run the script to start and monitoring addon manifest changes.
exec /var/lib/cloud/scripts/kubernetes/kube-addons.sh 1>>/var/log/kube-addons.log 2>&1
} 2>&1 | logger --priority daemon.info -t ${UPSTART_JOB}
end script

# Wait for 10s to start it again.
Expand All @@ -230,6 +245,7 @@ start on stopped kube-docker
respawn

script
{
set -o errexit
set -o nounset

Expand All @@ -239,6 +255,7 @@ script
. /etc/kube-configure-helper.sh
. /etc/kube-env
health_monitoring
} 2>&1 | logger --priority daemon.info -t ${UPSTART_JOB}
end script

# Wait for 10s to start it again.
Expand Down
34 changes: 25 additions & 9 deletions cluster/gce/trusty/node.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From nobody Thu Mar 10 10:33:00 2016
From nobody Thu May 13 20:33:00 2016
Content-Type: multipart/mixed; boundary="===================================="
MIME-Version: 1.0

Expand All @@ -15,6 +15,7 @@ description "Download and install k8s binaries and configurations"
start on cloud-config

script
{
set -o errexit
set -o nounset

Expand All @@ -29,6 +30,7 @@ script
. /etc/kube-env
echo "Install kube nodes binary and configuration files"
install_kube_binary_config
} 2>&1 | logger --priority daemon.info -t ${UPSTART_JOB}
end script

--====================================
Expand All @@ -44,6 +46,7 @@ description "Prepare kube node environment"
start on stopped kube-install-node

script
{
set -o errexit
set -o nounset

Expand All @@ -59,6 +62,10 @@ script
create_kubelet_kubeconfig
echo "Creating kube-proxy kubeconfig file"
create_kubeproxy_kubeconfig
echo "Assemble kubelet command line"
# Kubelet command flags will be in /etc/default/kubelet
assemble_kubelet_flags
} 2>&1 | logger --priority daemon.info -t ${UPSTART_JOB}
end script

--====================================
Expand All @@ -74,11 +81,13 @@ description "Install packages needed to run kubernetes"
start on stopped kube-install-node

script
{
set -o errexit
set -o nounset

. /etc/kube-configure-helper.sh
install_critical_packages
} 2>&1 | logger --priority daemon.info -t ${UPSTART_JOB}
end script

--====================================
Expand All @@ -94,11 +103,13 @@ description "Install additional packages used by kubernetes"
start on stopped kube-install-packages

script
{
set -o errexit
set -o nounset

. /etc/kube-configure-helper.sh
install_additional_packages
} 2>&1 | logger --priority daemon.info -t ${UPSTART_JOB}
end script

--====================================
Expand All @@ -116,16 +127,14 @@ start on stopped kube-install-packages and stopped kube-env
respawn

script
{
set -o errexit
set -o nounset

echo "Start kubelet upstart job"
. /etc/kube-configure-helper.sh
. /etc/kube-env
# Assemble command line flags based on env variables, which will put the string
# of flags in variable KUBELET_CMD_FLAGS.
assemble_kubelet_flags
/usr/bin/kubelet ${KUBELET_CMD_FLAGS} 1>>/var/log/kubelet.log 2>&1
. /etc/default/kubelet
/usr/bin/kubelet ${KUBELET_OPTS} 1>>/var/log/kubelet.log 2>&1
} 2>&1 | logger --priority daemon.info -t ${UPSTART_JOB}
end script

# Wait for 10s to start kubelet again.
Expand All @@ -144,12 +153,14 @@ description "Restart docker daemon"
start on started kubelet

script
{
set -o errexit
set -o nounset

. /etc/kube-configure-helper.sh
. /etc/kube-env
restart_docker_daemon
} 2>&1 | logger --priority daemon.info -t ${UPSTART_JOB}
end script

--====================================
Expand All @@ -165,6 +176,7 @@ description "Start kube-proxy static pod"
start on stopped kube-docker

script
{
set -o errexit
set -o nounset

Expand Down Expand Up @@ -208,6 +220,7 @@ script
fi

mv -f ${tmp_file} /etc/kubernetes/manifests/
} 2>&1 | logger --priority daemon.info -t ${UPSTART_JOB}
end script

--====================================
Expand All @@ -223,6 +236,7 @@ description "Install kubelet add-on manifest files"
start on stopped kube-docker

script
{
set -o errexit
set -o nounset

Expand All @@ -232,9 +246,9 @@ script
start_fluentd
# Kube-registry-proxy
if [ "${ENABLE_CLUSTER_REGISTRY:-}" = "true" ]; then
cp /home/kubernetes/kube-manifests/kubernetes/kube-registry-proxy.yaml \
/etc/kubernetes/manifests/
cp /home/kubernetes/kube-manifests/kubernetes/kube-registry-proxy.yaml /etc/kubernetes/manifests/
fi
} 2>&1 | logger --priority daemon.info -t ${UPSTART_JOB}
end script

--====================================
Expand All @@ -250,6 +264,7 @@ start on stopped kube-docker
respawn

script
{
set -o nounset
set -o errexit

Expand All @@ -259,6 +274,7 @@ script
. /etc/kube-configure-helper.sh
. /etc/kube-env
health_monitoring
} 2>&1 | logger --priority daemon.info -t ${UPSTART_JOB}
end script

# Wait for 10s to start it again.
Expand Down
Loading

0 comments on commit f83a12d

Please sign in to comment.