Skip to content

Commit

Permalink
Merge pull request kubernetes#27288 from andyzheng0831/automated-cher…
Browse files Browse the repository at this point in the history
…ry-pick-of-#26741-upstream-release-1.2

Automated cherry pick of kubernetes#26741
  • Loading branch information
roberthbailey authored Jun 14, 2016
2 parents cabc9bd + 1e54242 commit e730a3c
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 4 deletions.
46 changes: 44 additions & 2 deletions cluster/gce/trusty/configure-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -332,20 +332,33 @@ create_master_auth() {
add_token_entry "system:dns" "${known_tokens_csv}"
fi

if [ -n "${PROJECT_ID:-}" ] && [ -n "${TOKEN_URL:-}" ] && [ -n "${TOKEN_BODY:-}" ] && [ -n "${NODE_NETWORK:-}" ]; then
cat <<EOF >/etc/gce.conf
use_cloud_config="false"
cat <<EOF >/etc/gce.conf
[global]
EOF
if [ -n "${PROJECT_ID:-}" ] && [ -n "${TOKEN_URL:-}" ] && [ -n "${TOKEN_BODY:-}" ] && [ -n "${NODE_NETWORK:-}" ]; then
use_cloud_config="true"
cat <<EOF >>/etc/gce.conf
token-url = ${TOKEN_URL}
token-body = ${TOKEN_BODY}
project-id = ${PROJECT_ID}
network-name = ${NODE_NETWORK}
EOF
fi
if [ -n "${NODE_INSTANCE_PREFIX:-}" ]; then
use_cloud_config="true"
cat <<EOF >>/etc/gce.conf
node-tags = ${NODE_INSTANCE_PREFIX}
EOF
fi
if [ -n "${MULTIZONE:-}" ]; then
cat <<EOF >>/etc/gce.conf
multizone = ${MULTIZONE}
EOF
fi
if [ "${use_cloud_config}" != "true" ]; then
rm -f /etc/gce.conf
fi
}

# Uses KUBELET_CA_CERT (falling back to CA_CERT), KUBELET_CERT, and KUBELET_KEY
Expand Down Expand Up @@ -699,3 +712,32 @@ prepare_kube_addons() {
mount -t tmpfs tmpfs /root
mount --bind -o remount,rw,noexec /root
}

reset_motd() {
# kubelet is installed both on the master and nodes, and the version is easy to parse (unlike kubectl)
readonly version="$(/usr/bin/kubelet --version=true | cut -f2 -d " ")"
# This logic grabs either a release tag (v1.2.1 or v1.2.1-alpha.1),
# or the git hash that's in the build info.
gitref="$(echo "${version}" | sed -r "s/(v[0-9]+\.[0-9]+\.[0-9]+)(-[a-z]+\.[0-9]+)?.*/\1\2/g")"
devel=""
if [ "${gitref}" != "${version}" ]; then
devel="
Note: This looks like a development version, which might not be present on GitHub.
If it isn't, the closest tag is at:
https://github.com/kubernetes/kubernetes/tree/${gitref}
"
gitref="${version//*+/}"
fi
cat > /etc/motd <<EOF
Welcome to Kubernetes ${version}!
You can find documentation for Kubernetes at:
http://docs.kubernetes.io/
You can download the build image for this release at:
https://storage.googleapis.com/kubernetes-release/release/${version}/kubernetes-src.tar.gz
It is based on the Kubernetes source at:
https://github.com/kubernetes/kubernetes/tree/${gitref}
${devel}
For Kubernetes copyright and licensing information, see:
/home/kubernetes/LICENSES
EOF
}
13 changes: 11 additions & 2 deletions cluster/gce/trusty/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
# of needed functions. The script itself is not supposed to be executed in
# other manners.

set_broken_motd() {
cat > /etc/motd <<EOF
Broken (or in progress) Kubernetes node setup! If you are using Ubuntu Trusty,
check log file /var/log/syslog. If you are using GCI image, use
"journalctl | grep kube" to find more information.
EOF
}

download_kube_env() {
# Fetch kube-env from GCE metadata server.
readonly tmp_install_dir="/var/cache/kubernetes-install"
Expand Down Expand Up @@ -151,6 +159,7 @@ install_kube_binary_config() {
rm -f "${kube_bin}/kubectl"
fi
fi
cp "${kube_home}/kubernetes/LICENSES" "${kube_home}"

# Put kube-system pods manifests in /home/kubernetes/kube-manifests/.
dst_dir="${kube_home}/kube-manifests"
Expand All @@ -169,9 +178,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}" -maxdepth 1 -name \*.yaml -or -maxdepth 1 -name \*.yaml.in | \
find "${dst_dir}" -name \*.yaml -or -name \*.yaml.in | \
xargs sed -ri "s@(image:\s.*)gcr.io/google_containers@\1${kube_addon_registry}@"
find "${dst_dir}" -maxdepth 1 -name \*.manifest -or -maxdepth 1 -name \*.json | \
find "${dst_dir}" -name \*.manifest -or -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
2 changes: 2 additions & 0 deletions cluster/gce/trusty/master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ script
-o /etc/kube-configure.sh \
http://metadata.google.internal/computeMetadata/v1/instance/attributes/configure-sh
. /etc/kube-configure.sh
set_broken_motd
echo "Downloading kube-env file"
download_kube_env
. /etc/kube-env
Expand Down Expand Up @@ -221,6 +222,7 @@ script
if [ -n "${TEST_ADDON_CHECK_INTERVAL_SEC:-}" ]; then
export TEST_ADDON_CHECK_INTERVAL_SEC=${TEST_ADDON_CHECK_INTERVAL_SEC}
fi
reset_motd
# 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}
Expand Down
2 changes: 2 additions & 0 deletions cluster/gce/trusty/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ script
-o /etc/kube-configure.sh \
http://metadata.google.internal/computeMetadata/v1/instance/attributes/configure-sh
. /etc/kube-configure.sh
set_broken_motd
echo "Downloading kube-env file"
download_kube_env
. /etc/kube-env
Expand Down Expand Up @@ -247,6 +248,7 @@ script
if [ "${ENABLE_CLUSTER_REGISTRY:-}" = "true" ]; then
cp /home/kubernetes/kube-manifests/kubernetes/kube-registry-proxy.yaml /etc/kubernetes/manifests/
fi
reset_motd
} 2>&1 | logger --priority daemon.info -t ${UPSTART_JOB}
end script

Expand Down

0 comments on commit e730a3c

Please sign in to comment.