How To Install Kubectl?

How To Install Kubectl?

kubectl

Command line interface for running commands against Kubernetes clusters.

Install kubectl

  • Debian apt-get install kubernetes-client Click to copy
  • CentOS yum install kubernetes-client Click to copy
  • Fedora dnf install kubernetes-client Click to copy
  • macOS brew install kubernetes-cli Click to copy

Command line interface for running commands against Kubernetes clusters.

How to use kubectl?

Below are few example commands for kubectl that you can use in the terminal.

List all pods in all namespaces:
kubectl get pods --all-namespacesClick to copy
List all pods with more information (such as node name):
kubectl get pods -o wideClick to copy
Update specified pod with the label 'unhealthy' and the value 'true':
kubectl label pods name unhealthy=trueClick to copy
List all resources with different types:
kubectl get allClick to copy
Show metrics for all nodes:
kubectl top nodeClick to copy
Show metrics for all pods in the default namespace:
kubectl top podClick to copy
Print the address of the master and cluster services:
kubectl cluster-infoClick to copy
Install the latest version of kubectl in Debian, CentOS, Fedora and macOS from terminal. To install the kubectl just copy the above command for your OS and run into terminal. After you run the command it will grab the latest version of kubectl from the respository and install it in your computer/server.