本页面上的部分或全部信息可能不适用于 Trusted Cloud by S3NS。
在 Cloud Code for IntelliJ 中处理 kubeconfig 文件
kubeconfig 文件是 Kubernetes 配置文件,用于整理集群访问权限、用户和上下文。本页介绍了如何在 Cloud Code 中添加、删除和切换不同的 kubeconfig。
如需详细了解 kubeconfig 文件,请参阅 Kubernetes 文档中关于使用 kubeconfig 文件组织集群访问的内容。
管理 kubeconfig
默认情况下,Cloud Code 插件使用默认的 kubeconfig 文件(位于 $HOME/.kube
目录下)检索 Kubernetes 资源并运行命令。但是,您可以配置其他 kubeconfig 文件。
添加其他 kubeconfig 文件
如需添加其他 kubeconfig 文件,请执行以下操作:
- 导航到 IDE 中的 Cloud Code 设置(File > Settings > Tools > Cloud Code > Kubernetes;对于 Mac OS X,则为 IntelliJ IDEA > Preferences > Tools > Cloud Code > Kubernetes)。
- 在 kubeconfig 部分中,点击 + Add kubeconfig 图标或按
Alt
+insert
以显示选择对话框。
- 在选择 kubeconfig 文件对话框中,前往要添加的 kubeconfig 文件所在的位置。
- 选择要使用的 kubeconfig 文件,然后点击确定。
- 在设置对话框中,点击确定以保存所做的更改。
移除 kubeconfig 文件
如需移除 kubeconfig 文件,请执行以下操作:
- 导航到 IDE 中的 Cloud Code 设置(File > Settings > Tools > Cloud Code > Kubernetes;对于 Mac OS X,则为 IntelliJ IDEA > Preferences > Tools > Cloud Code > Kubernetes)。
- 在 kubeconfig 部分中,点击要移除的 kubeconfig,然后点击 - 移除图标或按
Alt
+Delete
。
- 点击确定以保存更改。
切换 kubeconfig
您可以通过点击 kubeconfig 下拉菜单并选择要使用的 kubeconfig,切换资源浏览器的当前 kubeconfig。选择 kubeconfig 后,工具窗口会更新为使用所选的 kubeconfig。
提示:可以使用 kubeconfig 下拉菜单直接添加新的 kubeconfig。

使用 Cloud Code 运行配置
Cloud Code 运行配置可以修改为使用备用 kubeconfig 文件。如需更改 kubeconfig,请打开“Run Configuration”以进行修改,然后在 Run > Advanced settings 下,从 kubeconfig 下拉菜单中选择要使用的 kubeconfig。在选择 kubeconfig 后,可用上下文会更新以反映在所选 kubeconfig 中找到的上下文。
提示:点击下拉列表右侧的 + 添加,可以直接从运行配置添加新的 kubeconfig。

后续步骤
获取支持
如需在 IntelliJ IDE 中提交反馈或报告问题,请依次前往
工具 >
Cloud Code >
帮助 / 简介 >
提交反馈或报告问题,以便在
GitHub 上报告问题。
如未另行说明,那么本页面中的内容已根据知识共享署名 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 managing Kubernetes resources."],["Cloud Code allows you to add, remove, and switch between different kubeconfig files through its settings panel, located under **File** \\\u003e **Settings** \\\u003e **Tools** \\\u003e **Cloud Code** \\\u003e **Kubernetes**."],["You can easily switch the active kubeconfig for the resource browser through a dropdown menu, enabling you to view and manage resources in different clusters."],["Cloud Code Run Configurations can be modified to use specific kubeconfig files, allowing for targeted deployments and operations on different clusters."],["New kubeconfigs can be added directly via both the Kubeconfigs dropdown menu and in the run configuration view."]]],[]]