12

I know that the Kubelet process on each Kubernetes node exposes a simple API server, but I cannot find any documentation for it.

Does someone know of a resource that has it?

Jonas
  • 121,568
  • 97
  • 310
  • 388
adrian
  • 2,326
  • 2
  • 32
  • 48

5 Answers5

8

It isn't documented anywhere (that I know of). I always end up reading the code to find out what endpoints exist.

Also note that unlike the API in the apiserver, there are no guarantees that the kubelet API will be stable between versions. Over time I expect that it will become properly versioned (and probably swaggerfied) and at that point we will provide documentation and a commitment to backward compatibility.

Robert Bailey
  • 17,866
  • 3
  • 50
  • 58
6

Some kubelet useful API to curl:

http://localhost:10255/pods
http://localhost:10255/stats/summary
http://localhost:10255/metrics
Haoyuan Ge
  • 3,379
  • 3
  • 24
  • 40
6

There is a new open-source project called kubeletctl.
It documents all the kubelet APIs (document and undocument).
You can use like that:

kubeletctl -s <node_ip> pods  
kubeletctl -s <node_ip> metrics cadvisor

When you run kubeletctl -h you will see all the commands you can use, it also has sub-commands but you need to type the parent command and then add -h, e.g kubeletctl metrics -h.

Here are some of the APIs kubelet implements:

testPaths := map[string]string{
    "/attach/{podNamespace}/{podID}/{containerName}":       "proxy",
    "/attach/{podNamespace}/{podID}/{uid}/{containerName}": "proxy",
    "/configz": "proxy",
    "/containerLogs/{podNamespace}/{podID}/{containerName}": "proxy",
    "/cri/":                    "proxy",
    "/cri/foo":                 "proxy",
    "/debug/flags/v":           "proxy",
    "/debug/pprof/{subpath:*}": "proxy",
    "/exec/{podNamespace}/{podID}/{containerName}":       "proxy",
    "/exec/{podNamespace}/{podID}/{uid}/{containerName}": "proxy",
    "/healthz":                            "proxy",
    "/healthz/log":                        "proxy",
    "/healthz/ping":                       "proxy",
    "/healthz/syncloop":                   "proxy",
    "/logs/":                              "log",
    "/logs/{logpath:*}":                   "log",
    "/metrics":                            "metrics",
    "/metrics/cadvisor":                   "metrics",
    "/metrics/probes":                     "metrics",
    "/metrics/resource/v1alpha1":          "metrics",
    "/pods/":                              "proxy",
    "/portForward/{podNamespace}/{podID}": "proxy",
    "/portForward/{podNamespace}/{podID}/{uid}":         "proxy",
    "/run/{podNamespace}/{podID}/{containerName}":       "proxy",
    "/run/{podNamespace}/{podID}/{uid}/{containerName}": "proxy",
    "/runningpods/":    "proxy",
    "/spec/":           "spec",
    "/stats/":          "stats",
    "/stats/container": "stats",
    "/stats/summary":   "stats",
    "/stats/{namespace}/{podName}/{uid}/{containerName}": "stats",
    "/stats/{podName}/{containerName}":                   "stats",
}
E235
  • 11,560
  • 24
  • 91
  • 141
0

Not documenting it is a way of saying: don't depend on this yet, it's a wip. Some parts, like cadvisor which is currently running as part of the kubelet binary, are actually more standardized. If there's some feature you'd really like to use but can't find docs on, I'd suggest asking on the kubernetes sig-node slack channel, or the sig-node mailing list

Prashanth B
  • 4,833
  • 1
  • 19
  • 13
0

You can run this quick command to list out all api endpoints. You will need to have jq installed

kubectl get --raw "/" | jq

jrow
  • 83
  • 7