Most Important Kubernates Commands

Most Important Kubernates Commands

Here I am sharing most import and frequently using kubernates commands in every day while working with kubernates. Cloud providers(Google, AWS, Azure, Oracle etc..) are providing kubernates services.

Here we can use name space either in short name or full name like follows.

Name space short name : -n

Name space full name: –namespace

In the following examples, I am going to using short name -n

How to use namespace or context name?

Syntax
kubectl config use-context <context-name or namespace>

Example
kubectl config use-context narayanatutorial

How to get the nodes?

syntax
kubectl get nodes

Example
kubectl get nodes

How get the pods?

Syntax
kubectl get pods -n <name-space> 

Example
kubectl get pods -n narayanatutorial

How to describe the pod?

Here WebApp1 is a pod name.

Syntax
kubectl describe pod <pod-name> -n <name-space> 

Example
kubectl describe pod WebApp1 -n narayanatutorial

How to see the pod logs?

Syntax
kubectl describe pod <pod-name> -n <name-space> 

Example
kubectl describe pod WebApp1 -n narayanatutorial

How to get the services?

Syntax
kubectl get services -n <name-space> 

Example
kubectl  get services -n narayanatutorial

How to get the restart the pod?

Syntax
kubectl rollout restart deployment <deployment-name> -n <name-space> 

Example
kubectl rollout restart deployment NTDeploymentName -n narayanatutorial

How to get the ingress details?

Syntax
kubectl get ingress -n <name-space> 

Example
kubectl get ingress -n narayanatutorial

How to get the ingress mapped application details?

Syntax
kubectl describe ingress <Mapped-App-Name> -n <name-space> 

Example
kubectl describe ingress NTApp  -n narayanatutorial

How to get the container access?

Syntax
kubectl exec <pod-name> -it bash  -n <name-space> 

Example
kubectl exec NTPod -it bash  -n narayanatutorial

 

 

Leave a Reply