Merge pull request #26741 from andyzheng0831/fix-trusty

Automatic merge from submit-queue

Trusty: fix 'find' commands and add k8s license and motd info

This PR fixes several things which should be also cherry picked in release-1.2 branch:

- Fix the 'find' command failure. See issue #26350 for the background;
- Add k8s license file into /home/kubernetes and set /etc/motd info. We fixed this in cluster/gce/gci for 1.3 branch, but have not done it for 1.2 branch. This PR simply copies the code from the GCI support.

Please note that the trusty code in master branch is under best-effort maintenance and we don't guarantee prompt fixes. But for 1.2 branch, we need to guarantee its correctness. I will test this in 1.2 branch.

@roberthbailey and @zmerlynn please review it.

cc/ @dchen1107 @fabioy @kubernetes/goog-image FYI.
This commit is contained in:
k8s-merge-robot 2016-06-02 18:43:47 -07:00
commit 73d9816671
4 changed files with 59 additions and 5 deletions

View File

@ -301,13 +301,23 @@ create_master_auth() {
echo "${KUBE_PROXY_TOKEN},kube_proxy,kube_proxy" >> "${known_tokens_csv}" echo "${KUBE_PROXY_TOKEN},kube_proxy,kube_proxy" >> "${known_tokens_csv}"
fi fi
if [ -n "${PROJECT_ID:-}" ] && [ -n "${TOKEN_URL:-}" ] && [ -n "${TOKEN_BODY:-}" ] && [ -n "${NODE_NETWORK:-}" ]; then use_cloud_config="false"
cat <<EOF >/etc/gce.conf cat <<EOF >/etc/gce.conf
[global] [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-url = ${TOKEN_URL}
token-body = ${TOKEN_BODY} token-body = ${TOKEN_BODY}
project-id = ${PROJECT_ID} project-id = ${PROJECT_ID}
network-name = ${NODE_NETWORK} 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 EOF
fi fi
if [ -n "${MULTIZONE:-}" ]; then if [ -n "${MULTIZONE:-}" ]; then
@ -315,7 +325,9 @@ EOF
multizone = ${MULTIZONE} multizone = ${MULTIZONE}
EOF EOF
fi fi
if [ "${use_cloud_config}" != "true" ]; then
rm -f /etc/gce.conf
fi
if [ -n "${GCP_AUTHN_URL:-}" ]; then if [ -n "${GCP_AUTHN_URL:-}" ]; then
cat <<EOF >/etc/gcp_authn.config cat <<EOF >/etc/gcp_authn.config
clusters: clusters:
@ -754,3 +766,32 @@ start_kube_addons() {
# Place addon manager pod manifest # Place addon manager pod manifest
cp "${addon_src_dir}/kube-addon-manager.yaml" /etc/kubernetes/manifests cp "${addon_src_dir}/kube-addon-manager.yaml" /etc/kubernetes/manifests
} }
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
}

View File

@ -20,6 +20,14 @@
# of needed functions. The script itself is not supposed to be executed in # of needed functions. The script itself is not supposed to be executed in
# other manners. # 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() { download_kube_env() {
# Fetch kube-env from GCE metadata server. # Fetch kube-env from GCE metadata server.
readonly tmp_kube_env="/tmp/kube-env.yaml" readonly tmp_kube_env="/tmp/kube-env.yaml"
@ -151,6 +159,7 @@ install_kube_binary_config() {
rm -f "${kube_bin}/kubectl" rm -f "${kube_bin}/kubectl"
fi fi
fi fi
cp "${kube_home}/kubernetes/LICENSES" "${kube_home}"
# Put kube-system pods manifests in /home/kubernetes/kube-manifests/. # Put kube-system pods manifests in /home/kubernetes/kube-manifests/.
dst_dir="${kube_home}/kube-manifests" dst_dir="${kube_home}/kube-manifests"
@ -169,9 +178,9 @@ install_kube_binary_config() {
tar xzf "${kube_home}/${manifests_tar}" -C "${dst_dir}" --overwrite tar xzf "${kube_home}/${manifests_tar}" -C "${dst_dir}" --overwrite
readonly kube_addon_registry="${KUBE_ADDON_REGISTRY:-gcr.io/google_containers}" readonly kube_addon_registry="${KUBE_ADDON_REGISTRY:-gcr.io/google_containers}"
if [ "${kube_addon_registry}" != "gcr.io/google_containers" ]; then 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}@" 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}@" xargs sed -ri "s@(image\":\s+\")gcr.io/google_containers@\1${kube_addon_registry}@"
fi fi
cp "${dst_dir}/kubernetes/gci-trusty/trusty-configure-helper.sh" /etc/kube-configure-helper.sh cp "${dst_dir}/kubernetes/gci-trusty/trusty-configure-helper.sh" /etc/kube-configure-helper.sh

View File

@ -25,6 +25,7 @@ script
-o /etc/kube-configure.sh \ -o /etc/kube-configure.sh \
http://metadata.google.internal/computeMetadata/v1/instance/attributes/configure-sh http://metadata.google.internal/computeMetadata/v1/instance/attributes/configure-sh
. /etc/kube-configure.sh . /etc/kube-configure.sh
set_broken_motd
echo "Downloading kube-env file" echo "Downloading kube-env file"
download_kube_env download_kube_env
. /etc/kube-env . /etc/kube-env
@ -192,6 +193,7 @@ script
start_kube_scheduler start_kube_scheduler
start_kube_addons start_kube_addons
start_cluster_autoscaler start_cluster_autoscaler
reset_motd
} 2>&1 | logger --priority daemon.info -t ${UPSTART_JOB} } 2>&1 | logger --priority daemon.info -t ${UPSTART_JOB}
end script end script

View File

@ -25,6 +25,7 @@ script
-o /etc/kube-configure.sh \ -o /etc/kube-configure.sh \
http://metadata.google.internal/computeMetadata/v1/instance/attributes/configure-sh http://metadata.google.internal/computeMetadata/v1/instance/attributes/configure-sh
. /etc/kube-configure.sh . /etc/kube-configure.sh
set_broken_motd
echo "Downloading kube-env file" echo "Downloading kube-env file"
download_kube_env download_kube_env
. /etc/kube-env . /etc/kube-env
@ -248,6 +249,7 @@ script
if [ "${ENABLE_CLUSTER_REGISTRY:-}" = "true" ]; then 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 fi
reset_motd
} 2>&1 | logger --priority daemon.info -t ${UPSTART_JOB} } 2>&1 | logger --priority daemon.info -t ${UPSTART_JOB}
end script end script