All Products
Search
Document Center

:Manage Kubernetes clusters with kubectl on CloudShell

Last Updated:Sep 23, 2024

CloudShell is a web-based CLI tool from Alibaba Cloud. You can manage Alibaba Cloud resources by executing CloudShell commands in any browser. This topic describes how to manage Kubernetes clusters by using kubectl through the CloudShell in the Alibaba Cloud Container Compute Service (ACS) console.

Prerequisites

CloudShell only supports public network access to connect to clusters. Ensure the API Server of the target cluster has public network access enabled. For detailed instructions, see Control public access to the API server of a cluster.

Background information

CloudShell is a web-based CLI tool that assigns a Linux virtual machine to users upon startup at no cost. This virtual machine is equipped with a variety of pre-installed tools and environments, as well as the Web IDE provided by CloudShell, facilitating everyday cloud resource management. For more information, see What is Cloud Shell?.

Note

CloudShell automatically loads the KubeConfig file of clusters when you launch CloudShell through the ACS. You can directly manage your clusters by using kubectl.

Steps

  1. Log on to the ACS console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, choose More > Open Cloud Shell in the Actions column of the target cluster.

  3. (Optional): Click cloudshell.png , then click Mount File Storage.

    Note

    Associating and mounting a NAS file system instance allows for the persistent storage of commonly used scripts and files. Without this, files are lost when the instance is released. You can select to click Create And Attach or Do Not Create For Now based on your needs.

  4. Run the following command to view the namespaces in the current cluster:

    kubectl get namespace

    Expected output:

    NAME              STATUS   AGE
    default           Active   3h14m
    kube-node-lease   Active   3h14m
    kube-public       Active   3h14m
    kube-system       Active   3h14m