Run Kubernetes dynamically using API

10/22/2019

I want to create pods, manage replica sets, and deployments using a rest API either built with PHP or Python. This needs to be controlled from a web app where the user clicks on a button and a new pod with a specific volume is created. I'm not sure how to achieve this.

I came across KC8 API and Python KC8 client API but I'm unable to achieve what is required. TIA

-- Ibad Rehman
kubernetes
python
server

1 Answer

10/22/2019

Kubernetes is controlled through an HTTP REST API, which is fully specified here. You could write a web app that directly issues the appropriate HTTP requests to the Kubernetes API server.

However, it's much more recommended to use one of the Kubernetes client libraries that exist for different programming languages. These libraries wrap all the HTTP requests in function calls and also take care of things like authentication.

You can find example code using the different client libraries in the GitHub repositories of most libraries (see here).

-- weibeld
Source: StackOverflow