What is Kubernetes API?
Tags: kubernetesapi, kubernetesapireference, kubernetesapigateway, kubernetes
Published: 2021-11-18 11:13:38

Before discussing any further on Kubernetes API, let’s first understand what Kubernetes is. To put it simply, <b><a href="https://blog.opstree.com/2021/06/02/manage-your-kubernetes-cluster-much-more-with-buildpiper?utm_source=Microblog&utm_medium=Dev.to&utm_campaign=Microblog_Dev.to_+What+is+Kubernetes+API%3F">Kubernetes</a></b> is a portable, open-source platform for the orchestration of containers. A container is an encapsulated bundle of software code and its related configuration files, libraries, and other related data packed into a small packet, capable of running independently in any infrastructure. 

<b>If we look into the <a href="https://www.redhat.com/en/enterprise-open-source-report/2021">State of Enterprise Report 2021</a>, 85% agree that Kubernetes is the key to cloud-native application strategies.</b> 

While Kubernetes adoption is growing at a rapid pace, deploying it is a major challenge that enterprises have to face today. Know more about Kubernetes deployment challenges and the best practices to overcome these here, in this eBook!


<center><b><a href="https://www.opstree.com/buildpiper/ebook.html?utm_source=Microblog&utm_medium=Dev.to&utm_campaign=Microblog_Dev.to_+What+is+Kubernetes+API%3F">The Ultimate Guide to Kubernetes Deployment!</a></b></center>

Before I begin telling you about Kubernetes API, let’s make sure you know what API is. API, i.e., application programming interface, is an interface that manages, creates, and configures Kubernetes clusters.

Now, jumping right into the topic, Kubernetes API is the interface or the front end of Kubernetes through which users interact with their Kubernetes Cluster. <b>There are two parts of the Kubernetes Cluster- one is the Control Plane, and the other is the Application Plane.</b>


   <center><b>Good Read: <a href="https://www.opstree.com/buildpiper/ebook.html?utm_source=Microblog&utm_medium=Dev.to&utm_campaign=Microblog_Dev.to_What+is+Kubernetes+API%3F">An Introduction to Kubernetes Architecture!</a></b></center>

The  Kubernetes API is present in the Control Plane of the Kubernetes Cluster. That means the user interacts through the API with the application plane. Even end-users, the cluster itself, and other external components communicate through the Kubernetes API.

Diving deeper into the world of Kubernetes API, it is structurally a resource-based programmatic interface via HTTPS. The standard HTTP verbs (POST, PUT, PATCH, DELETE, GET) allow retrieving, creating, updating, and deleting primary resources. 

Let’s get familiar with Kubernetes API Terminology.
-<b>Resource Type:</b> it is the name used in the URL (pods, namespaces, services).
-<b>Kind:</b> The concrete representation of all resource types
-<b>Collection:</b> A list of instances of a resource.
-<b>Resource:</b> The single instance of a resource type that usually represents an object.

Most Kubernetes API resource types are objects: they represent a concrete instance of a concept on the cluster, like a pod or namespace.

<b>API Verbs</b>

Kubernetes also uses its own verb forms. These are easily distinguishable from API verb forms, as they are often written in lowercase. In the case of Kubernetes:

The term <b>list</b> describes returning a collection of resources to distinguish from retrieving a single resource which is usually called a <b>get</b>.

Kubernetes internally classifies PUT requests as either <b>create</b> or <b>update</b> based on the state of the existing object.
An <b>update</b> is different from a <b>patch</b>; the HTTP verb for a <b>patch</b> is PATCH.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c283ocpwctovinut9gts.png)

<b>Detection of Changes through Kubernetes API!</b>

-Clients can make an initial request for an object or a collection and then track changes since that initial request using a <b>watch</b>.
-Every Kubernetes object has a <b>resourceVersion field</b>. The client can use it to initiate a watch against the API server. The <b>watch</b> mechanism allows fetching the current state and implementing subsequent changes without losing any event. If the <b>watch</b> gets disconnected, the client can start a new watch from the last returned <b>resourceVersion</b>.
-To subscribe to collections, Kubernetes client libraries offer some form of a standard tool for this <b>list-then-watch logic</b>.

<b>Kubernetes API Gateway</b>

Kubernetes API Gateway is required to manage, secure, and present APIs. Being deployed as a software component, it acts as the single entry point into Virtual Machines within Kubernetes. In other words, the primary responsibility of a Kubernetes API gateway is that it enables multiple APIs, microservices, and backend systems to be accessed reliably and safely by users.
An API gateway deployed in Kubernetes faces two primary challenges:
-It should be able to scale 100s of services and the associated APIs, and
-The gateway should be able to support a broad range of microservice architectures, protocols, and configurations.

<b>Kubernetes API Reference:</b>

Kubernetes is a fully resource-centred system. This means Kubernetes maintains an internal state of resources. Users can fully control Kubernetes using these resources. Based on the current state of the resources, Kubernetes can find out what needs to be done. Because of this, the Kubernetes API reference is organised as a list of resource types with their associated operations.

The Kubernetes API reference helps in knowing about the different terminologies related to Kubernetes for better management of the Kubernetes cluster. 

Understanding Kubernetes API, Kubernetes API gateway and Kubernetes API Reference is incomplete without knowing in detail about the Kubernetes architecture. You can refer to this blog on  for a better understanding of Kubernetes architecture.

<center><b><a href="https://blog.opstree.com/2021/11/18/an-introduction-to-kubernetes-architecture%ef%bf%bc/">An Introduction to Kubernetes Architecture!</a></b></center>