华为云UCS-本地集群KubeConfig文件:使用本地集群KubeConfig文件
时间:2025-05-19 16:15:54
使用本地集群KubeConfig文件
拿到ucs-ctl生成的KubeConfig之后,还需要使KubeConfig在节点上生效,步骤如下:
- 复制KubeConfig到节点上。
scp /local/path/to/kubeconfig user@remote:/remote/path/to/kubeconfig
- 如果当前节点添加过EnableSecretEncrypt环境变量,需要先取消。
unset EnableSecretEncrypt
- 使KubeConfig生效,可选方法:
- 方法一:复制到默认位置。
mv /remote/path/to/kubeconfig $HOME/.kube/config
- 方法二:环境变量指定。
export KUBECONFIG=/remote/path/to/kubeconfig
- 方法三:命令行参数指定。
kubectl --kubeconfig=/remote/path/to/kubeconfig
- 方法一:复制到默认位置。
上述操作之后,就可以访问本地集群的API server了。关于KubeConfig更详细的用法可参考:使用kubeconfig文件组织集群访问Kubernetes。
support.huaweicloud.com/usermanual-ucs/ucs_01_0288.html