Run Commands with kubectl
Kubectl is the Kubernetes command-line tool. You can use it to run commands on Kubernetes clusters to view and manage cluster resources, and more.
The KubeSphere console provides a Web kubectl. By default, only users granted the platform-admin role (such as the default admin account) have permission to use the Web kubectl for cluster resource operations and management.
This section demonstrates how to use the Web kubectl for cluster resource operations and management.
Prerequisites
You should have the platform-admin role on the KubeSphere platform. For more information, please refer to Users and Platform Roles.
Using Web Kubectl
Log in to the KubeSphere web console with a user having the platform-admin role.
Hover the cursor over the icon in the bottom right corner of the page and click kubectl from the menu.
In the popup window, you will see the kubectl interface as shown below. If you have multiple clusters, you need to first select the target cluster from the dropdown list in the top right corner. If there is only one cluster, the dropdown list will not be visible.
Enter kubectl commands in the command line tool to query and manage Kubernetes cluster resources. For example, execute the following command to check the status of all pods in the cluster.
kubectl get pods -A
Run kubectl commands in the terminal window using the following syntax:
kubectl [command] [TYPE] [NAME] [flags]
Note Here, command, TYPE, NAME, and flags are:
command: Specifies the operation to perform on one or more resources, such as create, get, describe, and delete.
TYPE: Specifies resource type. Resource types are case-insensitive, and you can specify singular, plural, or abbreviated forms.
NAME: Specifies the name of the resource. Names are case-sensitive. If the name is omitted, detailed information for all resources will be displayed, for example,
kubectl get pods
.flags: Specifies optional parameters. For example, you can use the
-s
or--server
flag to specify the address and port of the Kubernetes API server.
If you need help, run
kubectl help
in the terminal window or refer to Kubernetes Kubectl Documentation.
Feedback
Was this page Helpful?
Receive the latest news, articles and updates from KubeSphere
Thanks for the feedback. If you have a specific question about how to use KubeSphere, ask it on Slack. Open an issue in the GitHub repo if you want to report a problem or suggest an improvement.