Demo Deploying Voting app -worker pod failed to start

After executing the command to create and start worker pod with yaml file; pod status showing CrashLoopBackOff.

Please help to troubleshoot and solve this.

C:\Users\sskkube\Documents\Kube-practise\Demo-VotingApp>kubectl describe pod worker-app-pod
Name: worker-app-pod
Namespace: default
Priority: 0
Node: docker-desktop/192.168.65.4
Start Time: Thu, 03 Feb 2022 14:14:38 +0000
Labels: app=demo-voting-app
name=worker-app-pod
Annotations:
Status: Running
IP: 10.1.0.98
IPs:
IP: 10.1.0.98
Containers:
worker-app:
Container ID: docker://45ca34bbaf5130969fa2ab6ad8ea04987976a79f2ffbe74406876280c64d3712
Image: kodekloud/examplevotingapp_worker:v1
Image ID: docker-pullable://kodekloud/examplevotingapp_worker@sha256:741e3aaaa812af72ce0c7fc5889ba31c3f90c79e650c2cb31807fffc60622263
Port:
Host Port:
State: Terminated
Reason: Error
Exit Code: 1
Started: Thu, 03 Feb 2022 14:16:08 +0000
Finished: Thu, 03 Feb 2022 14:16:09 +0000
Last State: Terminated
Reason: Error
Exit Code: 1
Started: Thu, 03 Feb 2022 14:15:25 +0000
Finished: Thu, 03 Feb 2022 14:15:25 +0000
Ready: False
Restart Count: 4
Environment:
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-4lv8m (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
kube-api-access-4lv8m:
Type: Projected (a volume that contains injected data from multiple sources)
TokenExpirationSeconds: 3607
ConfigMapName: kube-root-ca.crt
ConfigMapOptional:
DownwardAPI: true
QoS Class: BestEffort
Node-Selectors:
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message


Normal Scheduled 97s default-scheduler Successfully assigned default/worker-app-pod to docker-desktop
Normal Pulled 7s (x5 over 95s) kubelet Container image “kodekloud/examplevotingapp_worker:v1” already present on machine
Normal Created 7s (x5 over 95s) kubelet Created container worker-app
Normal Started 7s (x5 over 94s) kubelet Started container worker-app
Warning BackOff 5s (x8 over 90s) kubelet Back-off restarting failed container

@reach.suryask
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!

1 Like

Thanks Ayman,
After updating postgres pod in env with below key value it got worked.

    - name: POSTGRES_HOST_AUTH_METHOD
      value: trust
2 Likes

Thank you - just had this problem and fixed it. This should be added to the course lecture as it is missing there.

1 Like

Hello everybody! :slight_smile:

And today was my turn, this would be really nice to be added to the lecture. I’ve spent some time looking around before get here.

Thank You All!

Cheers

Hi Team, I am facing an issue while deploying worker deployment: Using https://github.com/kodekloudhub/example-voting-app/blob/master/k8s-specifications/worker-app-deploy.yaml

Warning BackOff 23s (x48 over 10m) kubelet Back-off restarting failed container:

Events:
Type Reason Age From Message


Normal Scheduled 10m default-scheduler Successfully assigned default/worker-deployment-69968cb55b-mdbcl to gke-archt-default-pool-85ac1a95-f20t
Normal Pulled 9m13s (x5 over 10m) kubelet Container image “kodekloud/examplevotingapp_worker:v1” already present on machine
Normal Created 9m13s (x5 over 10m) kubelet Created container worker-app
Normal Started 9m13s (x5 over 10m) kubelet Started container worker-app
Warning BackOff 23s (x48 over 10m) kubelet Back-off restarting failed container

Please help me

Regards
Ayush Sahu
[email protected]