Pass KUBELET_TOKEN in kube-env metadata.

ensure-kube-token is not needed anymore because
the token passed in kube-env.

In the up case it is set, in the push case it is an empty string
but not used.

Allow unset KUBELET_TOKEN (for push case).

Fix comment.
This commit is contained in:
Eric Tune 2015-04-23 07:41:56 -07:00
parent 67b5b080b8
commit e8a83b23d1
2 changed files with 5 additions and 22 deletions

View File

@ -73,19 +73,6 @@ for k,v in yaml.load(sys.stdin).iteritems():
fi fi
} }
function ensure-kube-token() {
# We bake the KUBELET_TOKEN in separately to avoid auth information
# having to be re-communicated on kube-push. (Otherwise the client
# has to keep the bearer token around to handle generating a valid
# kube-env.)
if [[ -z "${KUBELET_TOKEN:-}" ]] && [[ ! -e "${KNOWN_TOKENS_FILE}" ]]; then
until KUBELET_TOKEN=$(curl-metadata kube-token); do
echo 'Waiting for metadata KUBELET_TOKEN...'
sleep 3
done
fi
}
function remove-docker-artifacts() { function remove-docker-artifacts() {
echo "== Deleting docker0 ==" echo "== Deleting docker0 =="
# Forcibly install bridge-utils (options borrowed from Salt logs). # Forcibly install bridge-utils (options borrowed from Salt logs).
@ -416,7 +403,6 @@ if [[ -z "${is_push}" ]]; then
ensure-install-dir ensure-install-dir
set-kube-env set-kube-env
[[ "${KUBERNETES_MASTER}" == "true" ]] && mount-master-pd [[ "${KUBERNETES_MASTER}" == "true" ]] && mount-master-pd
ensure-kube-token
create-salt-pillar create-salt-pillar
create-salt-auth create-salt-auth
download-release download-release

View File

@ -358,7 +358,6 @@ function create-route {
# $2: The scopes flag. # $2: The scopes flag.
# $3: The minion start script metadata from file. # $3: The minion start script metadata from file.
# $4: The kube-env metadata. # $4: The kube-env metadata.
# $5: Raw metadata
function create-node-template { function create-node-template {
detect-project detect-project
local attempt=0 local attempt=0
@ -374,8 +373,7 @@ function create-node-template {
--network "${NETWORK}" \ --network "${NETWORK}" \
$2 \ $2 \
--can-ip-forward \ --can-ip-forward \
--metadata-from-file "$3" "$4" \ --metadata-from-file "$3" "$4"; then
--metadata "$5"; then
if (( attempt > 5 )); then if (( attempt > 5 )); then
echo -e "${color_red}Failed to create instance template $1 ${color_norm}" echo -e "${color_red}Failed to create instance template $1 ${color_norm}"
exit 2 exit 2
@ -474,6 +472,7 @@ DNS_REPLICAS: $(yaml-quote ${DNS_REPLICAS:-})
DNS_SERVER_IP: $(yaml-quote ${DNS_SERVER_IP:-}) DNS_SERVER_IP: $(yaml-quote ${DNS_SERVER_IP:-})
DNS_DOMAIN: $(yaml-quote ${DNS_DOMAIN:-}) DNS_DOMAIN: $(yaml-quote ${DNS_DOMAIN:-})
KUBE_BEARER_TOKEN: $(yaml-quote ${KUBE_BEARER_TOKEN}) KUBE_BEARER_TOKEN: $(yaml-quote ${KUBE_BEARER_TOKEN})
KUBELET_TOKEN: $(yaml-quote ${KUBELET_TOKEN:-})
ADMISSION_CONTROL: $(yaml-quote ${ADMISSION_CONTROL:-}) ADMISSION_CONTROL: $(yaml-quote ${ADMISSION_CONTROL:-})
MASTER_IP_RANGE: $(yaml-quote ${MASTER_IP_RANGE}) MASTER_IP_RANGE: $(yaml-quote ${MASTER_IP_RANGE})
EOF EOF
@ -614,7 +613,6 @@ function kube-up {
# Wait for last batch of jobs # Wait for last batch of jobs
wait-for-jobs wait-for-jobs
add-instance-metadata "${MASTER_NAME}" "kube-token=${KUBELET_TOKEN}"
echo "Creating minions." echo "Creating minions."
@ -628,8 +626,7 @@ function kube-up {
write-node-env write-node-env
create-node-template "${NODE_INSTANCE_PREFIX}-template" "${scope_flags[*]}" \ create-node-template "${NODE_INSTANCE_PREFIX}-template" "${scope_flags[*]}" \
"startup-script=${KUBE_ROOT}/cluster/gce/configure-vm.sh" \ "startup-script=${KUBE_ROOT}/cluster/gce/configure-vm.sh" \
"kube-env=${KUBE_TEMP}/node-kube-env.yaml" \ "kube-env=${KUBE_TEMP}/node-kube-env.yaml"
"kube-token=${KUBELET_TOKEN}"
gcloud preview managed-instance-groups --zone "${ZONE}" \ gcloud preview managed-instance-groups --zone "${ZONE}" \
create "${NODE_INSTANCE_PREFIX}-group" \ create "${NODE_INSTANCE_PREFIX}-group" \
@ -867,8 +864,8 @@ function kube-push {
# TODO(zmerlynn): Re-create instance-template with the new # TODO(zmerlynn): Re-create instance-template with the new
# node-kube-env. This isn't important until the node-ip-range issue # node-kube-env. This isn't important until the node-ip-range issue
# is solved (because that's blocking automatic dynamic nodes from # is solved (because that's blocking automatic dynamic nodes from
# working). The node-kube-env has to be composed with the kube-token # working). The node-kube-env has to be composed with the KUBELET_TOKEN
# metadata. Ideally we would have # Ideally we would have
# https://github.com/GoogleCloudPlatform/kubernetes/issues/3168 # https://github.com/GoogleCloudPlatform/kubernetes/issues/3168
# implemented before then, though, so avoiding this mess until then. # implemented before then, though, so avoiding this mess until then.