Member-only story

DevOps Notebook: Most useful kubectl Commands !

Arun Kumar Singh
3 min readSep 12, 2020

--

Kubernetes Family !

Kubectl is a command line utility which allows you to interact with kubernetes cluster and run commands against it. Behind the curtain, It actually interacts with Kubernetes API to perform all operations.

Kubectl connect to K8s cluster with help of a config file. Default location of this config file kube directory which stays at $HOME/.kube
You can pass custom location by using --kubeconfig flag.

Syntex for Kubectl commands -

kubectl [command] [TYPE] [NAME] [flags]command - Type of operation eg: get, create, delete, apply etctype - Resource TypeName - name of the resourceflags - optional flags

Now lets go back a little bit and try to understand how this works. Kubernetes API is an HTTP REST API and main door to connect or interact with K8s cluster. All operations happen in K8s cluster are actually happen through it. I am not going to cover how HTTP REST API works but spending sometime will be very helpful for you.

Kubectl also connects with this API endpoint using HTTP requests. So when you run a command using Kubectl, is actually a communication with API. So if you run a command like creating a POD !

--

--

Arun Kumar Singh
Arun Kumar Singh

Written by Arun Kumar Singh

In quest of understanding How Systems Work !

No responses yet