‘kubectl get’ command explained with examples

‘kubectl get’ Command Explained with Examples

Kubernetes is an open-source platform that is the most portable for managing containerized workloads and services. It works as an automation tool by providing the services, support and tools that are widely available.

Whereas, Kubectl controls the Kubernetes Cluster as it is one of the key components of Kubernetes having the capability to manage the nodes in the cluster. Kubectl get command is capable of fetching the related data on the cluster about the Kubernetes resources.

In this article, we are going to discuss the use of the ‘Kubectl get’ command with some examples.

Kubectl get commands

Some of the important kubectl get commands to fetch the data on the cluster about the Kubernetes resources are listed below.

Kubectl
get pod

To get the details about the pod of the container of the related kubernetes cluster, there is a command similar to the command as:

To get the list of all the pods available on default namespace, run the command as shown below.

$ kubectl get pod

But to get the details of the specific pod, you can enter the pod name as:

$ kubectl get pod 

Example:

$ kubectl get pod nginx-http-6cf5c9bf86-p5q2x

‘kubectl get’ command explained with examples 29

Here, the pod name is “nginx-http-6cf5c9bf86-p5q2x”. It will display all the details regarding the specific pod.

Kubectl get deployment

To get the details about the deployments of the container of the related kubernetes cluster, there is a command similar to the command as:

To get the list of all the deployments available on default namespace, run the command as shown below.

$ kubectl get deployment

But to get the details of the specific deployment, you can enter the deployment name as:

$ kubectl get deployment 

Example:

$ kubectl get deployment nginx-http

‘kubectl get’ command explained with examples 30

Here, the deployment name is “nginx-http”. It will display all the details regarding the specific deployment.

Kubectl get service

To get the details about the service of the container of the related kubernetes cluster, there is a command similar to the command as:

To get the list of all the services available on default namespace, run the command as shown below.

$ kubectl get service

But to get the details of the specific service, you can enter the service name as:

$ kubectl get service 

Example:

$ kubectl get service nginx-http-svc

‘kubectl get’ command explained with examples 31

Here, the service name is “nginx-http-svc”. It will display all the details regarding the specific service.

Kubectl get ingress

To get the details about the ingress of the container of the related kubernetes cluster, there is a command similar to the command as:

To get the list of all the ingress available on default namespace, run the command as shown below.

$ kubectl get ingress

But to get the details of the specific ingress, you can enter the ingress name as:

$ kubectl get ingress 

Example:

$ kubectl get ingress ingress-nginx

‘kubectl get’ command explained with examples 32

Here, the ingress name is “ingress-nginx”. It will display all the details regarding the specific ingress.

Kubectl get configmap

To get the details about the configmap of the container of the related kubernetes cluster, there is a command similar to the command as:

To get the list of all the configmap available on default namespace, run the command as shown below.

$ kubectl get configmap

But to get the details of the specific configmap, you can enter the config name as:

$ kubectl get configmap 

Example:

$ kubectl get configmap nginx-http-cm

‘kubectl get’ command explained with examples 33

Here, the configmap name is “nginx-http-cm”. It will display all the details regarding the specific configmap.

Kubectl get secrets

To get the details about the secrets of the container of the related kubernetes cluster, there is a command similar to the command as:

To get the list of all the secrets available on default namespace, run the command as shown below.

$ kubectl get secrets

But to get the details of the specific secrets, you can enter the secrets name as:

$ kubectl get secrets 

Example:

$ kubectl get secrets default-token-xct8s

‘kubectl get’ command explained with examples 34

Here, the secret name is “default-token-xct8s”. It will display all the details regarding the specific secrets.

Kubectl get namespace

To get the details about the namespace of the container of the related kubernetes cluster, there is a command similar to the command as:

$ kubectl get namespace 

Example:

$ kubectl get namespace

‘kubectl get’ command explained with examples 35

Here, we are using the default namespace. By running the command as “kubectl get namespace”, we are listing all the available namespace.

Conclusion

In this article, you have learnt how to use the “kubectl get command” with different options like pods, deployment, services, etc. It will fetch the related data on the cluster about the Kubernetes resources.

Karim buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications including CCNA RS, SCP, and ACE. As an IT engineer and technical author, he writes for various websites.


Discover more from Ubuntu-Server.com

Subscribe to get the latest posts sent to your email.

See also  End of year review: Ubuntu Desktop in 2023

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply