Kubernetes - Kubectl Commands

Kubernetes - Kubectl Commands


In my previous article, we already have learned what is Kubernetes, its architecture and what is the difference betweenDocker and Kubernetes.

In this article, we will looking into some of the frequently used Kubeclt commands that are used to manage and interact Kubernetes objects and clusters along with its purpose.





Below is the list of most frequently used Kubeclt commands.

Kubeclt Command

Purpose
kubectl api-versions

This command will print the supported versions of API on the cluster.

kubectl apply –f <filename>

This command will configure a resource by file or stdin

kubectl attach <pod> –c <container>

This command will attach things to the running container.
kubectl cluster-info

This command will display the cluster Information.

kubectl cluster-info dump

This command will dump relevant information regarding cluster for debugging and diagnosis.

kubectl config <SUBCOMMAD>

This command will Modifies the kubeconfig file.

kubectl config current-context

This will display displays the current context.

kubectl config delete-cluster <Cluster Name>

This will delete the specified cluster from kubeconfig
kubectl config delete-context <Context Name>

This command will delete a specified context from kubeconfig.

kubectl config get-cluster

This command will display cluster defined in the kubeconfig.

kubectl config get-context <Context Name>

This command will Describe one or many contexts.
kubectl config set-credentials cluster-admin --username = ankur --
password = SesrweU9l75qciy

This command will Set the user entry in kubeconfig
kubectl config set PROPERTY_NAME PROPERTY_VALUE

This command will set an individual value in kubeconfig file.

kubectl config use-context <Context Name>

This command will set the current context in kubectl file.

kubectl cp <Files from source> <Files to Destinatiion>

This command will copy files and directories to and from containers.

kubectl create –f <File Name>

This command will create the resources by filename.

kubectl replace -f FILENAME

This command will replace a resource by file name or stdin.

Kubectl rollout <Sub Command>

This command is capable of managing the rollout of deployment.

kubectl set image (-f FILENAME | TYPE NAME)

This command will update the image of a pod template.

kubectl top node [node Name]

This command will display CPU/Memory/Storage usage.










SHARE THIS

Author:

My Name is Ankur Jain and I am currently working as Automation Test Architect.I am ISTQB Certified Test Manager,Certified UI Path RPA Developer as well as Certified Scrum Master with total 12 years of working experience with lot of big banking clients around the globe.I love to Design Automation Testing Frameworks with Selenium,Appium,Protractor,Cucumber,Rest-Assured, Katalon Studio and currently exploring lot in Dev-OPS as well. I am currently staying in Mumbai, Maharashtra. Please Connect with me through Contact Us page of this website.

Previous Post
Next Post
December 22, 2020 at 1:45 PM

Hi, I think you have a typo in your list. It should be
> kubectl config get-contexts
and not
> kubectl config get-context
like in your list. When calling the second command I got the error message:

error: unknown command "get-context ..."
See 'kubectl config -h' for help and examples

Reply
avatar