Kubernetes WebApplication

In this, we will be integrating k8s with CGI-bin and run the k8s commands through a web application. For this the user doesn’t need to know the commands of k8s, the user only needs to specify his/her requirement in normal English sentence and the things will be done. So, let’s get started…

We need to install k8s and use kubectl as a client. We then configure admin.conf with the server as IP of minikube.

Now instead of running the commands directly from here, we will be creating a web app using HTML, CSS, and js. At the backend, we will be using python cgi-bin which will give the interface so that we can execute our cmds and show the output back in the web app.

Here is the python cgi-bin backend file:

print("content-type: text/html")
print()
field = cgi.FieldStorage()
cmd = field.getvalue("x")
print(subprocess.getoutput("sudo kubectl " + cmd + " --kubeconfig admin.conf"))

Now we will be using HTML to give input box to the user where he/she can write their requirement and a button. Upon clicking this button it will call a function. This function will perform the things based on the requirement. This code will be placed in javascript file as follows:

We then give our requirements in web portal and our cmds will get proceed further and will give the respective outputs back in the portal.

Thank you! keep learning! keep growing! keep sharing!

Krithika Sharma
If you enjoyed this give it a clap, follow me on Medium for more
Let’s connect on LinkedIn

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store