@@ -604,6 +604,9 @@ function create-master-auth {
604
604
if [[ -n " ${KUBE_BEARER_TOKEN:- } " ]]; then
605
605
append_or_replace_prefixed_line " ${known_tokens_csv} " " ${KUBE_BEARER_TOKEN} ," " admin,admin,system:masters"
606
606
fi
607
+ if [[ -n " ${KUBE_BOOTSTRAP_TOKEN:- } " ]]; then
608
+ append_or_replace_prefixed_line " ${known_tokens_csv} " " ${KUBE_BOOTSTRAP_TOKEN} ," " system:cluster-bootstrap,uid:system:cluster-bootstrap,system:masters"
609
+ fi
607
610
if [[ -n " ${KUBE_CONTROLLER_MANAGER_TOKEN:- } " ]]; then
608
611
append_or_replace_prefixed_line " ${known_tokens_csv} " " ${KUBE_CONTROLLER_MANAGER_TOKEN} ," " system:kube-controller-manager,uid:system:kube-controller-manager"
609
612
fi
@@ -1562,7 +1565,7 @@ function start-kube-apiserver {
1562
1565
params+=" --etcd-keyfile=${ETCD_APISERVER_CLIENT_KEY_PATH} "
1563
1566
fi
1564
1567
params+=" --secure-port=443"
1565
- if [[ " ${ENABLE_APISERVER_INSECURE_PORT:- true } " != " true" ]]; then
1568
+ if [[ " ${ENABLE_APISERVER_INSECURE_PORT:- false } " != " true" ]]; then
1566
1569
# Default is :8080
1567
1570
params+=" --insecure-port=0"
1568
1571
fi
@@ -2866,6 +2869,14 @@ function wait-till-apiserver-ready() {
2866
2869
done
2867
2870
}
2868
2871
2872
+ function ensure-bootstrap-kubectl-auth {
2873
+ # Creating an authenticated kubeconfig is only necessary if the insecure port is disabled.
2874
+ if [[ -n " ${KUBE_BOOTSTRAP_TOKEN} " ]]; then
2875
+ create-kubeconfig " cluster-bootstrap" ${KUBE_BOOTSTRAP_TOKEN}
2876
+ export KUBECONFIG=/etc/srv/kubernetes/cluster-bootstrap/kubeconfig
2877
+ fi
2878
+ }
2879
+
2869
2880
# ########## Main Function ###########
2870
2881
function main() {
2871
2882
echo " Start to configure instance for kubernetes"
@@ -2913,10 +2924,12 @@ function main() {
2913
2924
fi
2914
2925
fi
2915
2926
2916
- # generate the controller manager, scheduler and cluster autoscaler tokens here since they are only used on the master.
2917
2927
KUBE_CONTROLLER_MANAGER_TOKEN=" $( secure_random 32) "
2918
2928
KUBE_SCHEDULER_TOKEN=" $( secure_random 32) "
2919
2929
KUBE_CLUSTER_AUTOSCALER_TOKEN=" $( secure_random 32) "
2930
+ if [[ " ${ENABLE_APISERVER_INSECURE_PORT:- false} " != " true" ]]; then
2931
+ KUBE_BOOTSTRAP_TOKEN=" $( secure_random 32) "
2932
+ fi
2920
2933
if [[ " ${ENABLE_L7_LOADBALANCING:- } " == " glbc" ]]; then
2921
2934
GCE_GLBC_TOKEN=" $( secure_random 32) "
2922
2935
fi
@@ -2933,6 +2946,7 @@ function main() {
2933
2946
create-node-pki
2934
2947
create-master-pki
2935
2948
create-master-auth
2949
+ ensure-bootstrap-kubectl-auth
2936
2950
create-master-kubelet-auth
2937
2951
create-master-etcd-auth
2938
2952
create-master-etcd-apiserver-auth
0 commit comments