更新时间:2025-11-18 GMT+08:00
分享

通过CloudShell连接集群

CloudShell是一款用于管理与运维云资源的网页版Shell工具,它能够为用户提供一个即时的、预配置的环境。通过CloudShell连接集群,您无需在本地安装、配置或维护kubectl等工具,即可直接管理和操作集群,能够有效降低环境配置的复杂性。

前提条件

集群中已安装CoreDNS插件。

约束与限制

  • 在CloudShell中使用kubectl时,kubectl的权限由登录用户的权限决定。
  • CloudShell暂不支持委托账号和子项目。
  • CloudShell中kubectl证书有效期为1天,从云容器引擎重新跳转可以重置有效期。

使用CloudShell连接集群

CloudShell中已预装并配置了kubectl工具,且默认连接到对应集群,您可以在CloudShell界面中直接执行kubectl命令,管理集群资源。使用CloudShell连接集群的具体步骤如下:

  1. 登录CCE控制台,在左侧导航栏中单击“集群管理”。
  2. 在右侧集群列表中,找到对应集群,在右侧单击“命令行工具”即可使用CloudShell。

    图1 CloudShell

  3. 进入CloudShell后,执行以下命令,验证CloudShell中的kubectl是否已连接对应集群。

    kubectl cluster-info    # 查看集群信息

    若回显结果如下,则说明CloudShell中的kubectl已连接集群,您可以直接使用kubectl命令管理集群资源。

    Kubernetes control plane is running at https://xx.xx.xx.xx:5443
    CoreDNS is running at https://xx.xx.xx.xx:5443/api/v1/namespaces/kube-system/services/coredns:dns/proxy
    To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

相关文档