Deploying voting app on kubernetes - Kubernetes for beginners course

In the demo for deploying the voting app on Kubernetes using “pods”, I’m unable to create the “worker-app-pod” as the error says “ImagePullBackOff” whereas I’m able to pull the same image via the docker pull command directly.

image used - kodekloud/examplevotingapp_worker:v1

worker-app-pod.yaml:
apiVersion: v1
kind: Pod
metadata:
name: worker-app-pod
labels:
name: worker-app-pod
app: demo-voting-app
spec:
containers:

  • name: worker-app
    image: kodekloud/examplevotingapp_worker:v1
1 Like

Hello @jhaabhishek115,
Please follow these full steps to know what you have missed and try again :

Note: We will create deployments again so please before following the steps, Run kubectl delete deployment --all to delete old deployments and avoid any conflicts.

  1. Run git clone https://github.com/mmumshad/example-voting-app-kubernetes-v2.git

  2. Run cd example-voting-app-kubernetes-v2/

  3. Run vim postgres-deployment.yml and modify it’s content as below then save and exit.

Note: It’s a new update from Postgres.

apiVersion: apps/v1
 kind: Deployment
 metadata:
   name: postgres-deployment
   labels:
     app: demo-voting-app
 spec:
   replicas: 1
   selector:
     matchLabels:
       name: postgres-pod
       app: demo-voting-app
   template:
     metadata:
       name: postgres-pod
       labels:
         name: postgres-pod
         app: demo-voting-app
     spec:
       containers:
       - name: postgres
         image: postgres:9.4
         env:
         - name: POSTGRES_USER
           value: postgres
         - name: POSTGRES_PASSWORD
           value: postgres
         - name: POSTGRES_HOST_AUTH_METHOD
           value: trust
         ports:
         - containerPort: 5432
  1. Run kubectl create -f . if you create deployments for the first time, if you created the same deployments before Run kubectl apply -f . .

  2. Run kubectl get service to get the exposed ports.

For example if the output of the command as above you can accces the voting app by hitting One_of_the_worker_nodes_IP:32733 on your browser and the same for the resulting app >> One_of_the_worker_nodes_IP:30013.

Check :

Note: The voting application only accepts one vote per client. It does not register votes if a vote has already been submitted from a client.

Hope this helps!

I haven’t yet created deployments yet.
Deployments are created in the next tutorial.
I have successfully created 4 pods but facing an error in creating the worker-app-pod “Error: ImagePullBackOff”.
I am able to pull the same image via the docker pull command in one go.
image - kodekloud/examplevotingapp_worker:v1

so, should I delete all the pods and go on to create deployments?

1 Like

If the code on Postgres-pod is incorrect, I’d not be able to connect to the PostgreSQL DB but the issue here is that worker-app-pod which is a standalone pod isn’t able to pull the image and as a result pod is not getting created.

I have created the deployments , but again the worker-app-deploy is not working as it is unable to pull the image.
Error: ImagePullBackOff
image: kodekloud/examplevotingapp_worker:v1

I tried a lab-based environment. All deployments and services are running but the vote is not getting reflected and the error I get is: Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

Hi @jhaabhishek115

What do the pod logs for the worker app say, assuming you got past the ImagePullBackoff issue?

Bear in mind that the worker app should not be deployed until both the redis and postgres deployments, and their services are running correctly. The worker service expects to be able to connect to both of them and will fail if it can’t.

The logs for worker-app-pod: Connected to db
Found redis at 10.107.22.36
Connecting to redis
Waiting for redis
Connecting to redis
Waiting for redis

Yes, I have created the worker app after redis and postgres are up and running.

1 Like

Hi Team,

i see the same issue while running the worker-app-pod.yaml.

its unable to pull the image.

Error: ImagePullBackOff
Normal Pulling 20s (x2 over 2m33s) kubelet Pulling image “kodekloud/examplevotingapp_worker:v1”

worker-app:
Container ID:
Image: kodekloud/examplevotingapp_worker:v1
Image ID:
Port:
Host Port:
State: Waiting
Reason: ImagePullBackOff
Ready: False

Can someone please help me on this?

Thanks in advance.

Hi @munigantipavan2

Please reset the lab and try again.

Thanks for the response.
Let me try it once again.

Hi Alistair

i have deleted all the pods and services.
and followed this process of creating voter pod and service, redis pod and service, postgres pod and service, worker pod.

But im still seeing this issue.
Its not on the lab, its on my local

Warning Failed 1s kubelet Failed to pull image “kodekloud/examplevotingapp_worker:v1”: rpc error: code = Unknown desc = context deadline exceeded

Thanks,

same error

can you please give some advice with image error

I also am facing the same issue. This is being done on local machine on minikube.
Worker pod when started goes in Backoff and keeps retrying. Upon checking further, found below container logs.

Hello @munigantipavan2, @carlosandresguerrero and @Satyabrata-Dash,
Please follow these full steps to know what you have missed and try again :

Note: We will create deployments again so please before following the steps, Run kubectl delete deployment --all to delete old deployments and avoid any conflicts.

  1. Run git clone https://github.com/mmumshad/example-voting-app-kubernetes-v2.git
  2. Run cd example-voting-app-kubernetes-v2/
  3. Run vim postgres-deployment.yml and modify it’s content as below then save and exit.

Note: It’s a new update from Postgres.

apiVersion: apps/v1
 kind: Deployment
 metadata:
   name: postgres-deployment
   labels:
     app: demo-voting-app
 spec:
   replicas: 1
   selector:
     matchLabels:
       name: postgres-pod
       app: demo-voting-app
   template:
     metadata:
       name: postgres-pod
       labels:
         name: postgres-pod
         app: demo-voting-app
     spec:
       containers:
       - name: postgres
         image: postgres:9.4
         env:
         - name: POSTGRES_USER
           value: postgres
         - name: POSTGRES_PASSWORD
           value: postgres
         - name: POSTGRES_HOST_AUTH_METHOD
           value: trust
         ports:
         - containerPort: 5432
  1. Run kubectl create -f . if you create deployments for the first time, if you created the same deployments before Run kubectl apply -f . .
  2. Run kubectl get service to get the exposed ports.

For example if the output of the command as above you can accces the voting app by hitting One_of_the_worker_nodes_IP:32733 on your browser and the same for the resulting app >> One_of_the_worker_nodes_IP:30013.

Check :

Note: The voting application only accepts one vote per client. It does not register votes if a vote has already been submitted from a client.

Hope this helps!

Hello Team,

The issue with worker-app-pod still persists. I get CrashLoopBackOff error. All the steps and procedures are followed correctly @Ayman your last answer does not help. Please check into what is the actual cause.

Looking forward to a soution.

Thanks!

I just deployed it and it is working fine - observe the uptime and no crashloops…

The order in which you deploy the resources is significant. The worker app makes use of both the postgres and redis databases meaning that they must both be running without crashlooping and their services deployed before you apply the worker app. This is called a dependency relationship. Worker depends on the other two.

Additionally the voting and results apps depend on each of the databases (can’t remember which way round it is) but it means they too must also be deployed after the databases.

Order of deployment is therefore

  1. postgres and redis (doesn’t matter which way round, they are not inter-dependent). Ensure both are running without crash loop before proceeding.
  2. services for postgres and redis
  3. worker, voting and results apps
  4. voting and results services.

Hi there!

Same here, I recently ran into the same issue with the pod/worker-app-pod CrashLoopBackOff error, so there order deployment really does matter.
Many thanks to Alistair for being such a huge help to all of us!

Have a Great Day!