Skip to content

Commit 0203192

Browse files
authored
Merge pull request kubernetes#78044 from dekkagaijin/patch-6
Consolidate logic to ensure kubectl auth
2 parents 3db6715 + 9bc3c2a commit 0203192

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

cluster/gce/gci/configure-helper.sh

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ function create-master-auth {
588588
append_or_replace_prefixed_line "${known_tokens_csv}" "${KUBE_BEARER_TOKEN}," "admin,admin,system:masters"
589589
fi
590590
if [[ -n "${KUBE_BOOTSTRAP_TOKEN:-}" ]]; then
591-
append_or_replace_prefixed_line "${known_tokens_csv}" "${KUBE_BOOTSTRAP_TOKEN}," "system:cluster-bootstrap,uid:system:cluster-bootstrap,system:masters"
591+
append_or_replace_prefixed_line "${known_tokens_csv}" "${KUBE_BOOTSTRAP_TOKEN}," "gcp:kube-bootstrap,uid:gcp:kube-bootstrap,system:masters"
592592
fi
593593
if [[ -n "${KUBE_CONTROLLER_MANAGER_TOKEN:-}" ]]; then
594594
append_or_replace_prefixed_line "${known_tokens_csv}" "${KUBE_CONTROLLER_MANAGER_TOKEN}," "system:kube-controller-manager,uid:system:kube-controller-manager"
@@ -1506,7 +1506,7 @@ function compute-master-manifest-variables {
15061506
INSECURE_PORT_MAPPING=""
15071507
if [[ "${ENABLE_APISERVER_INSECURE_PORT:-false}" == "true" ]]; then
15081508
INSECURE_PORT_MAPPING="{ \"name\": \"local\", \"containerPort\": 8080, \"hostPort\": 8080},"
1509-
fi
1509+
fi
15101510
}
15111511

15121512
# A helper function that bind mounts kubelet dirs for running mount in a chroot
@@ -2846,11 +2846,12 @@ function wait-till-apiserver-ready() {
28462846
done
28472847
}
28482848

2849-
function ensure-bootstrap-kubectl-auth {
2850-
# Creating an authenticated kubeconfig is only necessary if the insecure port is disabled.
2849+
function ensure-master-bootstrap-kubectl-auth {
2850+
# By default, `kubectl` uses http://localhost:8080
2851+
# If the insecure port is disabled, kubectl will need to use an admin-authenticated kubeconfig.
28512852
if [[ -n "${KUBE_BOOTSTRAP_TOKEN:-}" ]]; then
2852-
create-kubeconfig "cluster-bootstrap" ${KUBE_BOOTSTRAP_TOKEN}
2853-
export KUBECONFIG=/etc/srv/kubernetes/cluster-bootstrap/kubeconfig
2853+
create-kubeconfig "kube-bootstrap" "${KUBE_BOOTSTRAP_TOKEN}"
2854+
export KUBECONFIG=/etc/srv/kubernetes/kube-bootstrap/kubeconfig
28542855
fi
28552856
}
28562857

@@ -2971,13 +2972,13 @@ function main() {
29712972
KUBE_CONTROLLER_MANAGER_TOKEN="$(secure_random 32)"
29722973
KUBE_SCHEDULER_TOKEN="$(secure_random 32)"
29732974
KUBE_CLUSTER_AUTOSCALER_TOKEN="$(secure_random 32)"
2974-
if [[ "${ENABLE_APISERVER_INSECURE_PORT:-false}" != "true" ]]; then
2975-
KUBE_BOOTSTRAP_TOKEN="$(secure_random 32)"
2976-
fi
29772975
if [[ "${ENABLE_L7_LOADBALANCING:-}" == "glbc" ]]; then
29782976
GCE_GLBC_TOKEN="$(secure_random 32)"
29792977
fi
29802978
ADDON_MANAGER_TOKEN="$(secure_random 32)"
2979+
if [[ "${ENABLE_APISERVER_INSECURE_PORT:-false}" != "true" ]]; then
2980+
KUBE_BOOTSTRAP_TOKEN="$(secure_random 32)"
2981+
fi
29812982

29822983
setup-os-params
29832984
config-ip-firewall
@@ -2990,7 +2991,7 @@ function main() {
29902991
create-node-pki
29912992
create-master-pki
29922993
create-master-auth
2993-
ensure-bootstrap-kubectl-auth
2994+
ensure-master-bootstrap-kubectl-auth
29942995
create-master-kubelet-auth
29952996
create-master-etcd-auth
29962997
create-master-etcd-apiserver-auth

0 commit comments

Comments
 (0)