Fix Python App Deployed on Kubernetes Cluster

Ticker

6/recent/ticker-posts

Fix Python App Deployed on Kubernetes Cluster

 Question: One of the DevOps engineers was trying to deploy a python app on Kubernetes cluster. Unfortunately, due to some mis-configuration, the application is not coming up. Please take a look into it and fix the issues. Application should be accessible on the specified nodePort.

The deployment name is python-deployment-devops, its using poroko/flask-demo-appimage. The deployment and service of this app is already deployed.

nodePort should be 32345 and targetPort should be python flask app's default port.

Note: The kubectl on jump_host has been configured to work with the Kubernetes cluster.

Please Note :-  Perform the below commands based on your question server,  user name & other details that might differ. So please read the task carefully before executing it. 
All the Best 👍
Solution:  

1. Check existing running deployment, pods & services

thor@jump_host ~$ kubectl get pods

NAME                                         READY   STATUS             RESTARTS   AGE

python-deployment-xfusion-66fbc54cf5-q5bb8   0/1     ImagePullBackOff   0          23s

thor@jump_host ~$

thor@jump_host ~$ kubectl get deploy

NAME                        READY   UP-TO-DATE   AVAILABLE   AGE

python-deployment-xfusion   0/1     1            0           29s

thor@jump_host ~$

thor@jump_host ~$ kubectl get svc

NAME                     TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE

kubernetes               ClusterIP   10.96.0.1       <none>        443/TCP          18m

python-service-xfusion   NodePort    10.96.103.162   <none>        8080:32345/TCP   50s

thor@jump_host ~$

2. Describe the configuration of the deployment

thor@jump_host ~$ kubectl describe deploy

Name:                   python-deployment-xfusion

Namespace:              default

CreationTimestamp:      Fri, 10 Sep 2021 15:16:43 +0000

Labels:                 <none>

Annotations:            deployment.kubernetes.io/revision: 1

Selector:               app=python_app

Replicas:               1 desired | 1 updated | 1 total | 0 available | 1 unavailable

StrategyType:           RollingUpdate

MinReadySeconds:        0

RollingUpdateStrategy:  25% max unavailable, 25% max surge

Pod Template:

  Labels:  app=python_app

  Containers:

   python-container-xfusion:

    Image:        poroko/flask-app-demo

    Port:         5000/TCP

    Host Port:    0/TCP

    Environment:  <none>

    Mounts:       <none>

  Volumes:        <none>

Conditions:

  Type           Status  Reason

  ----           ------  ------

  Available      False   MinimumReplicasUnavailable

  Progressing    True    ReplicaSetUpdated

OldReplicaSets:  <none>

NewReplicaSet:   python-deployment-xfusion-66fbc54cf5 (1/1 replicas created)

Events:

  Type    Reason             Age   From                   Message

  ----    ------             ----  ----                   -------

  Normal  ScalingReplicaSet  72s   deployment-controller  Scaled up replica set python-deployment-xfusion-66fbc54cf5 to 1

thor@jump_host ~$ kubectl describe services python-service-xfusion

Name:                     python-service-xfusion

Namespace:                default

Labels:                   <none>

Annotations:              <none>

Selector:                 app=python_app

Type:                     NodePort

IP:                       10.96.103.162

Port:                     <unset>  8080/TCP

TargetPort:               8080/TCP

NodePort:                 <unset>  32345/TCP

Endpoints:               

Session Affinity:         None

External Traffic Policy:  Cluster

Events:                   <none>

thor@jump_host ~$

3. Refer the logs to identify the  issues 

thor@jump_host ~$ kubectl logs python-deployment-xfusion-66fbc54cf5-q5bb8

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

thor@jump_host ~$

4. Kindly refer to the below video for fixing  issues ahead 

Happy Learning!!!!

Apart from this if you need more clarity,  I have made a  tutorial video on this, please go through and share your comments. Like and share the knowledge



Post a Comment

0 Comments

Latest Posts

KodeKloud Kubernetes Security CKS  Lab Challenge 4 |  Audit-policy | Install & configure falco utility | Inspect the API server audit logs and identify the user