INTEGRATION OF KUBERNETES IN WEBAPP

Dharmika D
3 min readAug 12, 2021

Hello everyone!!

I have come up with another webapp for kubernetes. Earlier I had made a webapp to run the docker commands.

Here I am again with webapp for kubernetes where we can run kubernetes commands with general english statements instead of kube commands. Example — when we write ‘run deployment using httpd image’ then it run complete deployment command in backend.

Let’s go step by step what to do to make a web App for kubernetes.

Step:1 Create webpage

→ using HTML,CSS and Javascript knowledge create a dynamic web page which will act as an host.

→ user can give input of what they want to do with kubernetes in the webpage created.

→Using HTML and CSS make the webpage attractive and keep the file in the /var/www/html folder in Red Hat Enterprises Linus version 8(the OS i used to make this website, you can use any OS as local system to create python CGI programs that will run the commands ).

→ I used 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 want 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.

CODE SNIPPET

Step:2 Create python CGI program file

after creating the web Page, we create a python CGI code in /var/www/cgi-bin/ folder using the modules → “import cgi” , “import subprocess” we make the python CGI programming a backend program 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 .

CODE SNIPPET

Coding part is done!! We have to test it and output is displayed on the web application. Kubernetes in WebApp is successfully executed.

CODE AVAILABLE IN GITHUB

GITHUB LINK: https://github.com/Dharmika228/Kube_weapp

This task is done under guidance of my mentor Mr. Vimal Daga sir

THANK YOU !☺

--

--