如何生成kubeconfig文件

修改cluster

1
2
3
4
5
kubectl config set-cluster CLUSTER_NAME \
--certificate-authority=/path/to/ca \
--embed-certs=true \
--server=KUBE_APISERVER \
--kubeconfig=/path/to/kubeconfig

修改user

1
2
3
4
5
kubectl config set-credentials USERNAME \
--client-certificate=/path/to/cert \
--client-key=/path/to/key \
--embed-certs=true \
--kubeconfig=/path/to/kubeconfig

修改context

1
2
3
4
kubectl config set-context CONTEXT \
--cluster=CLUSTER_NAME \
--user=USERNAME \
--kubeconfig=/path/to/kubeconfig

设置默认context

1
kubectl config use-context CONTEXT --kubeconfig=/path/to/kubeconfig