一、下載kubectl
wget https://dl.k8s.io/v1.6.0/kubernetes-client-linux-amd64.tar.
gz
tar -xzvf kubernetes-client-linux-amd64.tar.gz
cp kubernetes/client/bin/kube /usr/bin/
chmod a+x /usr/bin/kubelinux
kubectl拷貝到每一個節點bootstrap
二、建立kubectl kubeconfig 文件
root@ubuntu132:~/scripts# cat kubectl-kubeconfig.sh
#!/bin/bash
#
export KUBE_APISERVER="https://192.168.15.132:6443"ubuntu
kubectl config set-cluster kubernetes \
--certificate-authority=/etc/kubernetes/ssl/ca.pem \
--embed-certs=true \
--server=${KUBE_APISERVER}api
kubectl config set-credentials admin \
--client-certificate=/etc/kubernetes/ssl/admin.pem \
--embed-certs=true \
--client-key=/etc/kubernetes/ssl/admin-key.pembash
kubectl config set-context kubernetes \
--cluster=kubernetes \
--user=adminide
kubectl config use-context kubernetesserver
生成的 kubeconfig 被保存到 ~/.kube/config 文件,該文件能夠直接拷貝成/etc/kubernetes/bootstrap.kubeconfig 這樣api同kubelet等認證直接經過。ip