@@ -579,6 +579,9 @@ function create-master-auth {
579
579
if [[ -n " ${KUBE_BEARER_TOKEN:- } " ]]; then
580
580
append_or_replace_prefixed_line " ${known_tokens_csv} " " ${KUBE_BEARER_TOKEN} ," " admin,admin,system:masters"
581
581
fi
582
+ if [[ -n " ${KUBE_BOOTSTRAP_TOKEN:- } " ]]; then
583
+ append_or_replace_prefixed_line " ${known_tokens_csv} " " ${KUBE_BOOTSTRAP_TOKEN} ," " system:cluster-bootstrap,uid:system:cluster-bootstrap,system:masters"
584
+ fi
582
585
if [[ -n " ${KUBE_CONTROLLER_MANAGER_TOKEN:- } " ]]; then
583
586
append_or_replace_prefixed_line " ${known_tokens_csv} " " ${KUBE_CONTROLLER_MANAGER_TOKEN} ," " system:kube-controller-manager,uid:system:kube-controller-manager"
584
587
fi
@@ -2825,6 +2828,14 @@ function wait-till-apiserver-ready() {
2825
2828
done
2826
2829
}
2827
2830
2831
+ function ensure-bootstrap-kubectl-auth {
2832
+ # Creating an authenticated kubeconfig is only necessary if the insecure port is disabled.
2833
+ if [[ -n " ${KUBE_BOOTSTRAP_TOKEN} " ]]; then
2834
+ create-kubeconfig " cluster-bootstrap" ${KUBE_BOOTSTRAP_TOKEN}
2835
+ export KUBECONFIG=/etc/srv/kubernetes/cluster-bootstrap/kubeconfig
2836
+ fi
2837
+ }
2838
+
2828
2839
# ########## Main Function ###########
2829
2840
function main() {
2830
2841
echo " Start to configure instance for kubernetes"
@@ -2872,10 +2883,12 @@ function main() {
2872
2883
fi
2873
2884
fi
2874
2885
2875
- # generate the controller manager, scheduler and cluster autoscaler tokens here since they are only used on the master.
2876
2886
KUBE_CONTROLLER_MANAGER_TOKEN=" $( secure_random 32) "
2877
2887
KUBE_SCHEDULER_TOKEN=" $( secure_random 32) "
2878
2888
KUBE_CLUSTER_AUTOSCALER_TOKEN=" $( secure_random 32) "
2889
+ if [[ " ${ENABLE_APISERVER_INSECURE_PORT:- true} " != " true" ]]; then
2890
+ KUBE_BOOTSTRAP_TOKEN=" $( secure_random 32) "
2891
+ fi
2879
2892
if [[ " ${ENABLE_L7_LOADBALANCING:- } " == " glbc" ]]; then
2880
2893
GCE_GLBC_TOKEN=" $( secure_random 32) "
2881
2894
fi
@@ -2892,6 +2905,7 @@ function main() {
2892
2905
create-node-pki
2893
2906
create-master-pki
2894
2907
create-master-auth
2908
+ ensure-bootstrap-kubectl-auth
2895
2909
create-master-kubelet-auth
2896
2910
create-master-etcd-auth
2897
2911
create-master-etcd-apiserver-auth
0 commit comments