KUBERNETES IN A WEBAPP

Priyanshu Bhatt
3 min readJun 30, 2021

Hii everyone ,

Earlier I made a web App for the Docker which was quite fun to do ,now here I am again with a web App of Kubernetes where using basic English like “create deployment”,”expose “ etc to run real kubernetes command in one place itself.

you might be thinking how it can be possible to do this ,But with Integration of HTML,CSS,JAVA SCRIPT and python CGI we can actually do that

so lets go step by step what to do to make a web App for kubernetes using the above things:

1)Create a webPage:

using HTML,CSS and Javascript knowledge make an dynamic web page which will act as an host for where user can give input of what they want to do with kubernetes ,using HTML and CSS make a attractive UIand keep the file in the /var/www/html folder here I used Red Hat Enterprises Linus version 8 to use my apche service to host it there and using javascript take the input from input box as the query string and send it using XMLhttprequest() to send it to backend page that you created using python cgi file code which is stored in the /var/www/cgi-bin/ folder to retrieve the values of the query String and perform the subprocess task and display the output in the host page the thing we have to focus more is how we are sending our query string and how to will identify the english grammer words entered by the user to run a command here comes the main role of Java Script using .search () and if else statements we have to tell the java Script to search for certain commonly used words that can be used by the user to run the common commands in the kubernetes.

as using search I also added some commonly used words like if user wont to create a deployment he will provide image and name else he will also write some common words like deploy,deployment or create ,make etc so we will add those few words in our conditions.

the quick snippet of the some part of code i created is :

2)create a python CGI file:

after creating the web Page main task is to create a python CGI code in /var/www/cgi-bin/ folder and by using the modules like “import cgi” “import subprocess” we can use the python CGI programming to become a backend like a server side program and run the program on the behalf of the client and send it to the client as an Asynchronous request to display output of the command in the Web Page created .

now the we done with the coding part ! now we just have to test it and the work is done your Kubernetes web app is ready to use

Thanks for reading!

--

--

Priyanshu Bhatt

AWS Solutions Architect || Terraform Certified Associate || DevOps Engineer || I Share Crisp Tech Stories linkedin.com/in/priyanshubhatt