diff --git a/cluster/gce/configure-vm.sh b/cluster/gce/configure-vm.sh index fe5bd92cb5ab0..df095c8b45027 100644 --- a/cluster/gce/configure-vm.sh +++ b/cluster/gce/configure-vm.sh @@ -254,6 +254,13 @@ function create-salt-auth() { kubelet_auth_file="/srv/salt-overlay/salt/kubelet/kubernetes_auth" (umask 077; echo "{\"BearerToken\": \"${KUBELET_TOKEN}\", \"Insecure\": true }" > "${kubelet_auth_file}") + + # Generate tokens for other "service accounts". Append to known_tokens. + local -r service_accounts=("system:scheduler" "system:controller_manager" "system:logging" "system:monitoring" "system:dns") + for account in "${service_accounts[@]}"; do + token=$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64 | tr -d "=+/" | dd bs=32 count=1 2>/dev/null) + echo "${token},${account},${account}" >> "${known_tokens_file}" + done } function download-release() { diff --git a/cluster/saltbase/salt/kube-addons/kube-addons.sh b/cluster/saltbase/salt/kube-addons/kube-addons.sh index e68fc15baf22d..016f8af44b65c 100644 --- a/cluster/saltbase/salt/kube-addons/kube-addons.sh +++ b/cluster/saltbase/salt/kube-addons/kube-addons.sh @@ -19,19 +19,52 @@ # managed result is of that. Start everything below that directory. KUBECTL=/usr/local/bin/kubectl -# $1 addon to start. +function create-kubernetesauth-secret() { + local -r token=$1 + local -r username=$2 + local -r safe_username=$(tr -s ':_' '--' <<< "${username}") + + # Make secret with a kubernetes_auth file with a token. + # TODO(etune): put apiserver certs into secret too, and reference from authfile, + # so that "Insecure" is not needed. + kafile=$(echo "{\"BearerToken\": \"${token}\", \"Insecure\": true }" | base64 -w0) + read -r -d '' secretjson <