kubectl-cluster-info
Display Kubernetes cluster information
TLDR
Show basic cluster information
Dump current cluster state to stdout (for debugging)
Dump cluster state to a directory
Use a specific kubeconfig context
SYNOPSIS
kubectl cluster-info [OPTIONS]
PARAMETERS
--all
If specified, kubectl cluster-info will print addresses for all relevant services, not just the master and default DNS service.
--context=name
Specifies the name of the kubeconfig context to use for the command, overriding the current context.
--kubeconfig=path
Provides an explicit path to the kubeconfig file, useful when not using the default location (~/.kube/config).
-o, --output=format
Defines the output format. Common formats include json, yaml, wide, go-template, etc., allowing for structured data retrieval.
--field-selector=selector
A selector (field query) to filter resources. Supports '=', '==', and '!=' operators (e.g., --field-selector metadata.name=kube-dns).
--label-selector=selector
A selector (label query) to filter resources based on their labels. Supports '=', '==', and '!=' operators (e.g., -l k8s-app=kube-dns).
--field-selector-limit=number
Sets the maximum number of items to retrieve when using field or label selectors. Defaults to 500.
DESCRIPTION
The kubectl cluster-info command is a fundamental utility for quickly retrieving connection details about your Kubernetes cluster. It provides a concise overview of the API server endpoint and often other critical cluster services like CoreDNS or Kube-DNS. This command is invaluable for a rapid health check, verifying connectivity to the cluster, and identifying the entry points for cluster management and service resolution.
When executed, kubectl cluster-info queries the Kubernetes API server and presents the network addresses where the master components and other labeled services are accessible. By default, it typically shows the Kubernetes control plane endpoint and the DNS service endpoint, crucial for any workloads running within the cluster to resolve internal and external services. Its straightforward output makes it an excellent first step in debugging cluster connectivity issues or simply confirming which cluster you are currently interacting with.
CAVEATS
The command requires a properly configured kubeconfig file and network connectivity to the Kubernetes API server. The specific services displayed beyond the API server may vary based on your Kubernetes version and how your cluster is configured (e.g., CoreDNS vs. Kube-DNS). While it confirms endpoint accessibility, it does not perform a deep health check of the underlying services themselves.
DEFAULT OUTPUT
Without any options, kubectl cluster-info typically displays the URL for the Kubernetes API server and the URL for the cluster's DNS service (e.g., CoreDNS or Kube-DNS). This provides a quick overview of the most critical endpoints for cluster operation.
VIEWING ALL SERVICES
To see more services beyond the default API server and DNS, use the --all option:
kubectl cluster-info --all
This can reveal endpoints for other cluster components like monitoring or ingress controllers if they are exposed and discoverable via the API.
USING SELECTORS
The --field-selector and --label-selector options allow for targeted queries. For example, to find a specific DNS service endpoint by label:
kubectl cluster-info --label-selector='k8s-app=kube-dns'
Or by field selector for a specific component's name:
kubectl cluster-info --field-selector='metadata.name=kube-scheduler' --all
HISTORY
The kubectl command-line tool, developed by Google, has been the primary interface for managing Kubernetes clusters since its inception. kubectl cluster-info is one of its foundational commands, designed to provide immediate insight into cluster connectivity. It has been a stable and core component, with minor enhancements over time, such as the introduction of selector options and various output formats, to improve its utility and integration with scripting.
SEE ALSO
kubectl config(1), kubectl get(1), kubectl describe(1)


