Kubernetes REST API

Are kubernets available through the REST API? I was looking at the Kubernetes API page and it all looks very mysterious / incomplete. They talk about new versions, but do not disclose the use of APIs or documents anywhere. I just wanted to know if there is a way to access cluster information in any other way than using the kubectl .

Usage example:

What am I doing now:

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

What I would like to do:

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

+8
source share
5 answers

You can see all the API calls that kubectl makes by passing --v=8 any kubectl command

+18
source

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

It includes information on how to access the API , obtain permission to use the API , as well as complete information about which API objects are available and what operations on them can be performed.

+2
source

The API is available to you outside of kubectl . In fact, I understand that under it all kubectl just makes REST calls to the API server. In a cluster that uses TLS certificates for authentication, calling curl to list your modules might look something like this (you can get the location / port of your apiserver using 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 document shows how to use kubectl proxy so that you can explore the API documents created using Swagger in your own cluster. These documents are also sometimes generated and placed here .

0
source

I think that this is perhaps what you find, although this is not always true. http://kubernetes.io/kubernetes/third_party/swagger-ui/

0
source

Kubernetes has an API man page. It details all the operations available through the API. To access the API of your cluster locally, make sure that the proxy server is kubectl proxy using kubectl proxy (after configuration, of course).

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

0
source

Source: https://habr.com/ru/post/1233284/


All Articles