Kubernetes Integration with Python-CGI.

Task Description: Create a WebUI page for kubernetes
Feature necessary.
⚙ It can launch pods with the specific names given by users.
⚙ Run deployment using the image and name given by the user.
⚙ Expose services on given user input port number.
⚙ Scale the replica according to user needs.
⚙ Delete complete environment created.
⚙ Delete specific resources given by the user.
⚙ Extra features related to k8s ( Optional)

Rishabh
2 min readJun 30, 2021

Pre-requisite:

✔ Minikube must be Configured
To install the Minikube check this Document
✔Setup Kubernetes and admin.conf file
To Setup Kubernetes follow this link

Step-1: Installing the Kubectl on Virtual Box:

♦Creating a Kubernetes.repo directly to install Kubectl

cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-\$basearch
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
exclude=kubelet kubeadm kubectl
EOF

♦Installing Kubectl using yum

yum install -y kubectl --disableexcludes=kubernetes

Step-2: Stopping Firewall and Stuff…

systemctl stop firewalldsetenforce 0

Step-3: Setting up the Front-End.

♦Go to “/var/www/html” and create a file named Index.html

Step-3: Setting up the Back-End.

♦Go to “/var/www/cgi-bin” and create a file named dockerps.py

#!/usr/bin/python3 
import cgi
import subprocess
import time
print(“content-type: text/html”)
print()
k = cgi.FieldStorage()
cmd = k.getvalue(“x”)
o = subprocess.getoutput(cmd)
print(o

Step-4: Now transferring the “admin.conf” file to “var/www/cgi-bin”.

Step-5: Finally using browser and accessing the site.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Rishabh
Rishabh

Written by Rishabh

Student from B.tech 2nd Year, A proud ARTH learner, love new technologies, Curious about many thing, likes to explore places, love eating pizza and much more.

No responses yet

Write a response