Fixed a python App deployed on a Kubernetes Cluster

Franklin C. Godwin
2 min readJan 12, 2022

Fixed a python App deployed on a Kubernetes Cluster and added a requirement for the #kubernetescluster by changing the targetPort to be python flask app’s default port.

More info available here github

N.B: Editing pod definition file is not the same procedure as editing Deployment definition file

Error Message displayed on the URL

502 Bad Gateway

nginx/1.21.1

Troubleshooting commands: Before using the troubleshooting command or viewing the log, get the name of the pod name.

Kubectl get po

Kubectl logs <pod-name>

Additional troubleshooting commands are

kubectl describe pod <pod-name> | grep Events -A10

Error message shown after running the kubectl log command

Error from server (BadRequest): container “python-container-

xfusion” in pod “python-deployment-xfusion-66fbc54cf5-q5bb8”

is waiting to start: trying and failing to pull image

Commands used are

Edit the image name in the Deployment definition file to match the requirements for python App deployed on a Kubernetes Cluster and save the file using the vim command.

kubectl edit deployment

Wait for the pod and deployment status = running

kubectl get deployment

For the second requirement regarding targetPort, view the service definition file using the command below, edit the targetPort and save the file

kubectl get svc

kubectl edit svc

Verify the information using the command

kubectl get pod,svc -o wide

--

--