Beginner
Beginner

Reputation: 2886

Kubernetes REST API

Does kubernetes accessible via a REST API? I was looking over at the Kubernetes API page and it all looks very cryptic / incomplete. They talk about new versions but have not disclosed the API usage or docs anywhere. I just wanted to know if there is a way to access the cluster information in any other way other than using the kubectl command.

Example usage:

What I do now:

kubectl get pod --context='my-prod-cluster'

What I'd like to do:

curl GET /some/parameters/to/get/info

Upvotes: 14

Views: 31809

Answers (5)

rwehner
rwehner

Reputation: 4698

The API is available to you outside of kubectl. In fact, my understanding is that underneath it all kubectl is just making REST calls to the API server. In a cluster using TLS certificates for authentication, a curl call to list your pods might look something like this (you can get your apiserver location/port with kubectl cluster-info | grep 'Kubernetes master'):

curl --cert myuser.pem --key myuser-key.pem --cacert /path/to/ca.pem https://my-prod-cluster-apiserver:6443/api/v1/pods

This doc shows how to use kubectl proxy to allow you to explore the Swagger-generated API docs on your own cluster.

Upvotes: 1

Alex Robinson
Alex Robinson

Reputation: 13397

The REST API is fully documented on the Kubernetes website: https://kubernetes.io/docs/reference/using-api/api-overview/

It includes info on how to reach the API, be authorized to use the API, and a full breakdown of what API objects are available and what operations you can do on them.

Upvotes: 2

mster
mster

Reputation: 898

Kubernetes has an API reference page. It details all the operations accessible via the API. To access your cluster's API locally, make sure to proxy in, using kubectl proxy (after set-up of course).

API Reference: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/

Upvotes: 0

vmcloud
vmcloud

Reputation: 652

I think this is maybe what you find , though it is not always up to date. http://kubernetes.io/kubernetes/third_party/swagger-ui/

Upvotes: 0

Jordan Liggitt
Jordan Liggitt

Reputation: 18161

You can see all the API calls kubectl is making by passing --v=8 to any kubectl command

Upvotes: 47

Related Questions