Menu Close

K8 – How to display Kubernetes cluster info

Here, we will learn How to display Kubernetes cluster info. The kubectl cluster-info command is used to display cluster info.

Kubernetes is a popular open-source container orchestration system used for managing and deploying containerized applications. Kubectl is a command-line interface (CLI) tool used for managing Kubernetes clusters. One of the most commonly used kubectl commands is kubectl cluster-info. In this article, we will explore the various aspects of kubectl cluster-info and how it can be used to manage Kubernetes clusters.

What is kubectl cluster-info?

The kubectl cluster-info command is used to display the cluster endpoint and Kubernetes API server version information. This command provides essential information about the Kubernetes cluster and its components, which can be useful in troubleshooting cluster-related issues.

Syntax of kubectl cluster-info

The syntax of kubectl cluster-info is straightforward.

kubectl cluster-info

Output of kubectl cluster-info

The output of kubectl cluster-info includes the following information:

  • Kubernetes master endpoint
  • Kubernetes API server version
  • Kubernetes DNS service endpoint
  • Kubernetes dashboard URL

Here is an example output of the kubectl cluster-info command:

Kubernetes master is running at https://kubernetes-master:6443
KubeDNS is running at https://kubernetes-master:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Kubernetes dashboard is running at https://kubernetes-master:6443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/

Options for kubectl cluster-info

The kubectl cluster-info command provides several options that you can use to customize its behavior. Here are some of the most commonly used options:

  • --context: Specify the context to use for the command. A context is a group of access parameters for a Kubernetes cluster, including the cluster name, server URL, and authentication information.
  • --kubeconfig: Specify the location of the kubeconfig file to use for the command. The kubeconfig file contains information about one or more Kubernetes clusters, including authentication information and context settings.
  • --request-timeout: Specify the timeout for the request in seconds. By default, the command will timeout after 60 seconds.
  • --v: Increase the verbosity of the output. You can use this option multiple times to increase the verbosity further.

How to use kubectl cluster-info?

The kubectl cluster-info command is mainly used for obtaining information about the Kubernetes cluster. However, it can also be used for troubleshooting and debugging cluster issues. The output of kubectl cluster-info can help identify if the Kubernetes API server or any other components of the Kubernetes cluster are down.

Here are some common use cases of kubectl cluster-info:

  • Verifying the Kubernetes API server endpoint:
    • The output of kubectl cluster-info includes the Kubernetes master endpoint, which is the endpoint for the Kubernetes API server. This information can be used to verify the connectivity to the Kubernetes API server. If the Kubernetes API server is down, it will not be possible to retrieve any information about the cluster.
  • Verifying the Kubernetes DNS service endpoint:
    • The output of kubectl cluster-info also includes the Kubernetes DNS service endpoint. This information can be used to verify the connectivity to the Kubernetes DNS service. If the Kubernetes DNS service is down, it will not be possible to resolve any DNS names within the Kubernetes cluster.

Conclusion

The kubectl cluster-info command is a powerful tool for retrieving information about your Kubernetes cluster. It provides you with the basic information you need to manage your cluster effectively, including details about the Kubernetes API server, control plane components, and DNS service. By understanding how to use this command and its options effectively, you can gain better visibility into your Kubernetes cluster and make informed decisions about how to manage it.

To learn more about golang, Please refer given below link:

https://techieindoor.com/go-lang-tutorial/

References:

https://golang.org/pkg/

Posted in kubernetes

Leave a Reply

Your email address will not be published. Required fields are marked *