k8s kubelet 生成kube-config文件

接着上面的博客继续写

  pwd -> /etc/kubernetes

  设置集群参数

  kubectl config set-cluster kubernetes --certificate-authority=/etc/kubernetes/ssl/ca.pem --server=https://192.168.1.71:6443 --kubeconfig=kubelet.kubeconfig

  设置客户端认证参数

  kubectl config set-credentials kubelet --client-certificate=/etc/kubernetes/ssl/kubelet-1-71.pem --client-key=/etc/kubernetes/ssl/kubelet-1-71.key --kubeconfig=kubelet.kubeconfig

  生成上下文参数

  kubectl config set-context default --cluster=kubernetes --user=kubelet --kubeconfig=kubelet.kubeconfig

  切换默认上下文

  kubectl config use-context default --kubeconfig=kubelet.kubeconfig

  cat kubelet.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
  name: default
current-context: default
kind: Config
preferences: {}
users:
- name: kubelet
  user:
    as-user-extra: {}
    client-certificate: ssl/kubelet-1-71.pem
    client-key: ssl/kubelet-1-71.key

  如果上面的文件出现 错误 也可以直接修改配置文件  或者直接删除文件重新生成

  

posted @ 2019-05-18 22:24  超我  阅读(5672)  评论(0编辑  收藏  举报