CrashLoopBackOff error when running worker-app-pod

Hi,
I was able to run all the pod except the worker pod. getting the below error:

NAME READY STATUS RESTARTS AGE
pod/db-app-pod 1/1 Running 0 3m1s
pod/redis-app-pod 1/1 Running 0 91s
pod/result-app-pod 1/1 Running 1 16m
pod/voting-app-pod 1/1 Running 0 16m
pod/worker-app-pod 0/1 CrashLoopBackOff 2 41s

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/db ClusterIP 10.97.247.97 5432/TCP 2m49s
service/kubernetes ClusterIP 10.96.0.1 443/TCP 8d
service/redis ClusterIP 10.97.13.209 6379/TCP 13m
service/result-service NodePort 10.105.162.193 80:30005/TCP 13m
service/voting-service NodePort 10.110.200.160 80:30004/TCP 13m

using “kubectl describe pod worker-app-pod” :

Name: worker-app-pod
Namespace: default
Priority: 0
Node: minikube/192.168.99.101
Start Time: Wed, 26 Aug 2020 22:14:08 +0530
Labels: app=demo-voting-app
name=worker-app-pod
Annotations: Status: Running
IP: 172.17.0.5
IPs:
IP: 172.17.0.5
Containers:
worker-app:
Container ID: docker://b80a62e8827abe7bfe1413d15efdeff3145fe9563fdb765bd736ce049a3a013b
Image: shivansh123321/worker
Image ID: docker-pullable://shivansh123321/worker@sha256:c364804d835e9ca3d5966b5a3ac4efdc73e570de070474e052d3cb4f0766f10a
Port:
Host Port:
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: Error
Exit Code: 1
Started: Wed, 26 Aug 2020 22:17:21 +0530
Finished: Wed, 26 Aug 2020 22:17:22 +0530
Ready: False
Restart Count: 5
Environment:
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-dzm7w (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
default-token-dzm7w:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-dzm7w
Optional: false
QoS Class: BestEffort
Node-Selectors:
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message


Normal Scheduled 4m47s default-scheduler Successfully assigned default/worker-app-pod to minikube
Normal Created 3m54s (x4 over 4m43s) kubelet, minikube Created container worker-app
Normal Started 3m54s (x4 over 4m43s) kubelet, minikube Started container worker-app
Warning BackOff 3m24s (x7 over 4m37s) kubelet, minikube Back-off restarting failed container
Normal Pulling 3m10s (x5 over 4m46s) kubelet, minikube Pulling image “shivansh123321/worker”
Normal Pulled 3m8s (x5 over 4m43s) kubelet, minikube Successfully pulled image “shivansh123321/worker”

Please let me know what is the issue?
Thank you

Hello, @Shivansh123321
What is the image you choose? Just to deploy only image is not enough. You have to write some code to make it container alive after pulling your image.

Hi @Tej-Singh-Rana ,

I used the image mentioned in the video :
source: GitHub - dockersamples/example-voting-app: Example distributed app composed of multiple containers for Docker, Compose, Swarm, and Kubernetes.
I build the images and pushed them to my docker hub repo.

I was able to get the voting app screen and result app screen up with port:30004 and 30005 respectively but there is problem with the worker app .as I am always getting CrashLoopBackOff msg.
due to this, the data is not being updated in the Postgres database.

1 Like

I have the same issue. Help please. Is the image or the image source not right anymore?

1 Like

I’m going through same issue also, I don’t want to submit it like that because I believe I will fail the task. Something is wrong with the image or dns issue.

1 Like

same issue. help? something rioung with worker image?

1 Like

Hi,

Kindly follow these sequence for creation of Deployments & Services in questions

Vote Deployment + Service
Redis Deployment + Service
DB Deployment + Service
Result Deployment + Service
Worker Deployment

This is resolving an issue of worker pod crashing.

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.

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!

1 Like

Hi Shivansh did you get a fix for your problem as I am getting the same issue

Hi @drwolf Did you find fix ?

@Ayman Could you please give more details about this change on the postgress manifest? Why keep the user and password if I’m passing the POSTGRES_HOST_AUTH_METHOD as ‘trust’?

There was a problem in the worker app original image and this was a workaround to add both credential methods so that the voting app works fine.

But for now, this issue is resolved, and using POSTGRES_HOST_AUTH_METHOD without adding the password will work fine.

1 Like

Now, it doesn’t connect to Redis… @Ayman

Kindly clarify which modification you have done with?

Sorry, I had unintentionally modified the Redis’ ports. Problem solved. Thank you very much.

With pleasure and happy learning

For me adding in env: POSTGRES_HOST_AUTH_METHOD value: trust in postgres pod worked finally :smiley:

4 Likes

getting error “CrashLoopBackOff” in creating pods for worker app. although my all the other 4 aps are installed and running fine.

Hello @deovrat.dubey,
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!

Thanks,
KoudKloud Support

1 Like

HI Ayman, you might be suggesting me for Deploying microservices using Deployments.
but i want to deploy microservice via installing pods and services manually one by one. in this case all the services and pods are installed and running except the worker pod which is giving the error can you provide me the solution and reason for this case.