Cluster Information

Prints Cluster Information

TL;DR

  • Print information about the Cluster and Client versions
  • Print information about the Control Plane
  • Print information about Nodes
  • Print information about APIs

Cluster Info

Motivation

It may be necessary to learn about the Kubernetes cluster itself, rather than just the workloads running in it. This can be useful for debugging unexpected behavior.

Versions

The kubectl version prints the client and server versions. Note that the client version may not be present for clients built locally from source.

  1. kubectl version
  1. Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.5", GitCommit:"f01a2bf98249a4db383560443a59bed0c13575df", GitTreeState:"clean", BuildDate:"2018-03-19T19:38:17Z", GoVersion:"go1.9.4", Compiler:"gc", Platform:"darwin/amd64"}
  2. Server Version: version.Info{Major:"1", Minor:"11+", GitVersion:"v1.11.6-gke.2", GitCommit:"04ad69a117f331df6272a343b5d8f9e2aee5ab0c", GitTreeState:"clean", BuildDate:"2019-01-04T16:19:46Z", GoVersion:"go1.10.3b4", Compiler:"gc", Platform:"linux/amd64"}

Version Skew

Kubectl supports +/-1 version skew with the Kubernetes cluster. Kubectl versions that are more than 1 version ahead of or behind the cluster are not guaranteed to be compatible.

Control Plane and Addons

The kubectl cluster-info prints information about the control plane and add-ons.

  1. kubectl cluster-info
  1. Kubernetes master is running at https://1.1.1.1
  2. GLBCDefaultBackend is running at https://1.1.1.1/api/v1/namespaces/kube-system/services/default-http-backend:http/proxy
  3. Heapster is running at https://1.1.1.1/api/v1/namespaces/kube-system/services/heapster/proxy
  4. KubeDNS is running at https://1.1.1.1/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
  5. Metrics-server is running at https://1.1.1.1/api/v1/namespaces/kube-system/services/https:metrics-server:/proxy

Kube Proxy

The URLs printed by cluster-info can be accessed at 127.0.0.1:8001 by running kubectl proxy.

Nodes

The kubectl top node and kubectl top pod print information about the top nodes and pods.

  1. kubectl top node
  1. NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%
  2. gke-dev-default-pool-e1e7bf6a-cc8b 37m 1% 571Mi 10%
  3. gke-dev-default-pool-e1e7bf6a-f0xh 103m 5% 1106Mi 19%
  4. gke-dev-default-pool-e1e7bf6a-jfq5 139m 7% 1252Mi 22%
  5. gke-dev-default-pool-e1e7bf6a-x37l 112m 5% 982Mi 17%

APIs

The kubectl api-versions and kubectl api-resources print information about the available Kubernetes APIs. This information is read from the Discovery Service.

Print the Resource Types available in the cluster.

  1. kubectl api-resources
  1. NAME SHORTNAMES APIGROUP NAMESPACED KIND
  2. bindings true Binding
  3. componentstatuses cs false ComponentStatus
  4. configmaps cm true ConfigMap
  5. endpoints ep true Endpoints
  6. events ev true Event
  7. limitranges limits true LimitRange
  8. namespaces ns false Namespace
  9. ...

Print the API versions available in the cluster.

  1. kubectl api-versions
  1. admissionregistration.k8s.io/v1beta1
  2. apiextensions.k8s.io/v1beta1
  3. apiregistration.k8s.io/v1
  4. apiregistration.k8s.io/v1beta1
  5. apps/v1
  6. apps/v1beta1
  7. apps/v1beta2
  8. ...

Discovery

The discovery information can be viewed at 127.0.0.1:8001/ by running kubectl proxy. The Discovery for specific API can be found under either /api/v1 or /apis/<group>/<version>, depending on the API group - e.g. 127.0.0.1:8001/apis/apps/v1

The kubectl explain command can be used to print metadata about specific Resource types. This is useful for learning about the type.

  1. kubectl explain deployment --api-version apps/v1
  1. KIND: Deployment
  2. VERSION: apps/v1
  3. DESCRIPTION:
  4. Deployment enables declarative updates for Pods and ReplicaSets.
  5. FIELDS:
  6. apiVersion <string>
  7. APIVersion defines the versioned schema of this representation of an
  8. object. Servers should convert recognized schemas to the latest internal
  9. value, and may reject unrecognized values. More info:
  10. https://git.k8s.io/community/contributors/devel/api-conventions.md#resources
  11. kind <string>
  12. Kind is a string value representing the REST resource this object
  13. represents. Servers may infer this from the endpoint the client submits
  14. requests to. Cannot be updated. In CamelCase. More info:
  15. https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds
  16. metadata <Object>
  17. Standard object metadata.
  18. spec <Object>
  19. Specification of the desired behavior of the Deployment.
  20. status <Object>
  21. Most recently observed status of the Deployment.