How has the recent turmoil within the OpenAI offices changed your plans to use GPT in a business process or product in 2024?
Increased uncertainty means we are more likely to evaluate alternative AI chatbots and LLMs.
No change in plans, though we will keep an eye on the situation.
With Sam Altman back in charge, we are more likely to go all-in with GPT and LLMs.
What recent turmoil?
API Management / Containers / Kubernetes / Software Development

Take the Kubernetes API for a Spin

Aug 19th, 2016 8:35am by
Featued image for: Take the Kubernetes API for a Spin
Feature image via Pixabay.

For anyone who is fascinated by distributed computing, Kubernetes provides an ultimate playground. It’s one of best implementations of cluster management software of our times. Google must be appreciated for not only open sourcing Kubernetes, but also simplifying it, and making it accessible to the developers.

At the heart of Kubernetes is an application programming interface (API). In fact, everything and anything in the platform is treated as an API object. Tasks such as the creation and deletion of pods, services, and replica sets are all translated into appropriate REST API calls.

This article discovers the hidden gems of Kubernetes API along with a detailed walkthrough. To get more from this tutorial, you are advised to spin up a cluster for yourself.

Architecture & Background

One of the key components of Kubernetes control plane is the API server. It is responsible for dealing with the REST operations while providing the front-end to the cluster’s shared state through which all other components interact. Every operation that involves changing the state of a Kubernetes objects such as a Pod goes through the API server.

Kubectl, the command line interface to Kubernetes, is a simple yet powerful client of this API.

The lesser known fact is that there are multiple client libraries available for the Kubernetes API. While the Go client is the official one, there are 3rd party clients for Node.js, PHP, Python, and Java available on Github.


In a typical Kubernetes cluster, the API is exposed on port 443, which can be accessed through a TLS connection. The self-signed certificate, which is generated during the cluster creation or configuration, is available at $USER/.kube/config on the user’s machine. But the access to the API server can be simplified through the proxy, which we will configure in the tutorial.

The API server performs authentication, authorization, and admission control of clients. Refer to Kubernetes API documentation for more details.

Setting up the Cluster

There are three ways to get the Kubernetes cluster up and running:

  1. Minikube – This is the simplest way to get a Kubernetes cluster on your Mac or Windows machine. Follow the instructions mentioned on the GitHub page.
  2. Vagrant Multi-Node – If you want to go beyond the basics to get a sense of the real Kubernetes cluster, clone the CoreOS Kubernetes repo and fire the vagrant up The folks at CoreOS does a great job of maintaining the repo along with the step-by-step guide.
  3. Google Container Engine – This is by far the simplest way to gain access to a full-blown Kubernetes cluster. Sign up with Google Cloud Platform, download the Cloud SDK and spin up the mighty powerful GKE cluster.

The entire script for this tutorial is also available on GitHub.

Verifying the Installation

Once you have access to a running cluster, verify that everything is intact by running the following commands:



If you see a similar output, the Kubernetes cluster is in perfect shape. We are all set to explore the API.

Configuring the Proxy

The easiest way to access Kubernetes API is to configure a proxy. Luckily, kubectl comes with an option to configure it.

Open a new terminal window and run the following command to create the proxy.


Through this proxy session, any request sent to localhost:8000 will be forwarded to the Kubernetes API server.

Now that we are all set, let’s go ahead and make our first API call. But before that, let’s explore the Swagger UI.

Accessing and Invoking the API

Visit http://localhost:8000/swagger-ui/ from the browser to access Swagger. This may not be available if you are using Minikube.


Expanding the /api/v1 section will show us all the available endpoints.


Let’s now use cURL to play with the API.


Let’s have some more fun playing with the API. To make things readable, install jq, the versatile JSON command line parser.

One of the most commonly used commands is kubectl get nodes, which returns the following output.


The equivalent curl command to get all the nodes is pretty straight forward. Jq is used for making the output prettier and human readable.


If you like, you can also use Postman to explore Kubernetes API.


Let’s take this to the next level by creating a pod through the API.

Creating a Pod and Service from the API

First, let’s define a pod. The below command will create a simple NGINX pod.

We will then create a service definition to expose the NGINX pod that was just scheduled.

The next step is to create the pod object by invoking the following command.


We filtered the cURL output only to show the status. In a few seconds, the NGINX image will be downloaded and scheduled in one of the nodes.

With the NGINX pod in place, let’s also create a service. This process is very similar to the creation of the pod.


Let’s make sure that both the objects are created. We will use kubectl to list the pods and services.



Finally, let’s access the Nginx service through the proxy.


Time to clean up by deleting the pod and the service that we created.


Kubernetes is one of the most extensible container orchestration engines available today. Powered by Google’s decades of experience in managing massive infrastructure, it brings web-scale computing to masses. The API-first approach makes Kubernetes programmable and extensible. As we have seen in the walkthrough, it is easy to get started with the API. Any task that can be performed through the dashboard or kubectl client is exposed as an API.

Group Created with Sketch.
TNS owner Insight Partners is an investor in: Postman.
THE NEW STACK UPDATE A newsletter digest of the week’s most important stories & analyses.