本页面上的部分或全部信息可能不适用于 Trusted Cloud by S3NS。
在 Cloud Code for VS Code 中使用 kubeconfig 文件
kubeconfig 文件是 Kubernetes 配置文件,用于整理集群访问权限、用户和上下文。本页介绍了如何在 Cloud Code 中添加、删除和切换不同的 kubeconfig。
如需详细了解 kubeconfig 文件,请参阅 Kubernetes 文档中的使用 kubeconfig 文件整理集群访问。
管理 kubeconfig
默认情况下,Cloud Code 插件使用默认的 kubeconfig 文件(位于 $HOME/.kube
目录下)检索 Kubernetes 资源并运行命令。但是,您可以配置其他 kubeconfig 文件。
添加其他 kubeconfig 文件
如需添加其他 kubeconfig 文件,请执行以下操作:
- 打开命令面板(按
Ctrl
/Cmd
+Shift
+P
或点击 View > Command Palette),然后运行 Cloud Code: Switch kubeconfig。
- 点击 + Load kubeconfig,然后前往要添加的 kubeconfig 文件的位置。
- 选择要添加的 kubeconfig 文件,然后点击 Add KubeConfig Path(添加 KubeConfig 路径)。
- 按照系统提示为新的 kubeconfig 文件提供名称。
- 按
Enter
进行确认。
移除 kubeconfig 文件
如需移除 kubeconfig 文件,请执行以下操作:
- 打开命令面板(按
Ctrl
/Cmd
+Shift
+P
或点击 View > Command Palette),然后运行 Cloud Code: Remove KubeConfig from Kubernetes Explorer。
- 选中要移除的 kubeconfig 旁边的复选框,然后点击 Ok。
切换 kubeconfig
您可以使用命令面板切换 kubeconfig。如需切换 kubeconfig,请执行以下操作:
- 打开 Command Palette,然后运行 Cloud Code: Switch KubeConfig。
- 点击要使用的 kubeconfig。
后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-11。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-11。"],[[["Kubeconfig files are Kubernetes configuration files that manage cluster access, users, and contexts, and Cloud Code utilizes them for various operations."],["Cloud Code defaults to the kubeconfig file in the `$HOME/.kube` directory but allows the addition of other kubeconfig files for managing different contexts."],["You can add kubeconfig files in Cloud Code by using the \"Cloud Code: Switch kubeconfig\" command in the command palette and navigating to the desired file, and you can name them as well."],["Removing kubeconfig files in Cloud Code is possible by using the command \"Cloud Code: Remove KubeConfig from Kubernetes Explorer\", and selecting the files to remove."],["Switching between different kubeconfigs is easily done through the command palette by using the \"Cloud Code: Switch KubeConfig\" command and selecting the desired kubeconfig."]]],[]]