Kubernetes Integration with Python-CGI

amit soni
3 min readJul 4, 2021

What is Kubernetes ?

Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. It has a large, rapidly growing ecosystem. Kubernetes services, support, and tools are widely available.

What is CGI?

CGI is a Python server site program that helps to execute internal commands of the Operating System. CGI stands for Common Gateway Interface, Its helps to make API program in python.

How to Integrate K8s with python CGI?

First, we have to install and start ‘minikube’ as:

minikube start

After that, we start a webserver.

systemctl start httpd

Next, we have to get started with our HTML file(front-end) and Python- CGI file(for our Back-end).

Copy or create HTML code in:- /var/www/html/

/var/www/html/

Copy or create a CGI file in:- /var/www/cgi-bin/

/var/www/cgi-bin/

Note → Here admin.conf file is a k8s configuration file you can retrive it your minikube cluster or k8s cluster.

make sure your python cgi file executable using:- chmod +x <filename.py>

chmod +x test.py

You can get these files from my GitHub repo below:

Now we have to start our HTML code in Google Chrome(Windows) using the IP of VM.

The k8s commands are executed on this website:

kubectl get pods
kubectl run pod — image=vimal13/apache-webserver-php
kubectl get pod

Now, We can performing the different operations of K8s:-

1. create, delete, resources and also

2. create deployment, services etc.

Thanks

--

--