标签:文件 trap context 通过 kubectl token auth contex 错误
接着上面的博客继续写
pwd
/etc/kubernetes
kubectl config set-cluster kubernetes --certificate-authority=/etc/kubernetes/ssl/ca.pem --server=https://192.168.1.71:6443 --kubeconfig=bootstrap.kubeconfig
设置k8s bootstrap.kubeconfig token
kubectl config set-credentials kubelet-bootstrap --token=`awk -F ‘,‘ ‘{print $1}‘ token.csv` --kubeconfig=bootstrap.kubeconfig
如果上面的执行有错误 最好文件都删除再执行
生成默认的上下文参数
kubectl config set-context default --cluster=kubernetes --user=kubelet-bootstrap --kubeconfig=bootstrap.kubeconfig
切换上下文
kubectl config use-context default --kubeconfig=bootstrap.kubeconfig
cat bootstrap.kubeconfig
apiVersion: v1 clusters: - cluster: certificate-authority: ssl/ca.pem server: https://192.168.1.71:6443 name: kubernetes contexts: - context: cluster: kubernetes user: kubelet-bootstrap name: default current-context: default kind: Config preferences: {} users: - name: kubelet-bootstrap user: as-user-extra: {} token: 46f06e612eea4e76c47d5471d608c379
通过命令行设置的配置文件 证书是相对路径 也可以直接修改成绝对路径
标签:文件 trap context 通过 kubectl token auth contex 错误
原文地址:https://www.cnblogs.com/S--S/p/10887368.html