Skip to content
Related Articles
Open in App
Not now

Related Articles

Kubernetes – API

Improve Article
Save Article
  • Difficulty Level : Expert
  • Last Updated : 26 Nov, 2022
Improve Article
Save Article

Pre-requisite:- Kubernetes

Kubernetes API is the application that serves Kubernetes functionality through a RESTful interface and stores the state of the cluster via HTTP. Users can directly interact with the Kubernetes API or via tools like kubectl. It supports retrieving, creating, updating, and deleting primary resources via POST, PUT, PATCH, DELETE, and GET. Kubernetes resources are stored as API objects. The API allows configuration to be managed analytically. The core Kubernetes API is flexible and can also be extended to support custom resources.

 

It uses common RESTful terminology to describe the API concepts:

  • Resource type is a name used in the URL ( pods, namespaces, services).
  • All resource types have a  representation of their object schema which is called a kind.
  • A list of instances of a resource is known as a collection.
  • A single instance of a resource type is called a resource and usually represents an object.

Accessing REST API:

 If you want to access the REST API with an HTTP client like curl or wget, or a browser, there are multiple ways:

  1. Run kubectl in a proxy mode to ensure the identity of the API server. This method is recommended since it uses the stored api server location and verifies the identity using a self-signed cert. No man-in-the-middle (MITM) attack is possible using this method.
  2. Using Go or Python client libraries provide accessing kubectl in proxy mode. This works with client code that is confused by proxies. To protect against man-in-the-middle attacks, you’ll need to import a root cert into your web browser.

Using kubectl:

The following command runs the kubectl proxy

$ kubectl proxy &

Then it starts the serving on port 127.0.0.1:8001

 

Open the browser and navigate to 127.0.0.1:8001

 

Then we can access any sector via port URL. For example, we have to access the APIs app sector, then simply put that in the URL like

127.0.0.1:8001/apis/apps/v1
Output

 

In this way, we can easily access anything we want.

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!