I have created a kubeadm cluster with one master and one worker node running. I am trying to deploy the voting-app in this cluster and getting an error when voting-app tries to communicate with the redis pod. Before clicking the voting option from the URL, the pods were up and running.
10.244.1.1 - - [13/Feb/2023:06:13:47 +0000] "GET / HTTP/1.1" 200 1287 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.78"
[2023-02-13 06:13:53,537] ERROR in app: Exception on / [POST]
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/app/app.py", line 31, in hello
redis.rpush('votes', data)
File "/usr/local/lib/python2.7/site-packages/redis/client.py", line 2016, in rpush
return self.execute_command('RPUSH', name, *values)
File "/usr/local/lib/python2.7/site-packages/redis/client.py", line 898, in execute_command
conn = self.connection or pool.get_connection(command_name, **options)
File "/usr/local/lib/python2.7/site-packages/redis/connection.py", line 1192, in get_connection
connection.connect()
File "/usr/local/lib/python2.7/site-packages/redis/connection.py", line 563, in connect
raise ConnectionError(self._error_message(e))
ConnectionError: Error -3 connecting to redis:6379. Try again.
When I click the voting button, it throws Internal Server Error (500) and then the worker app will get CrashLoopBackOff state.
System.AggregateException: One or more errors occurred. (Resource temporarily unavailable) ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: Resource temporarily unavailable
at System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6)
at System.Net.Dns.ResolveCallback(Object context)
--- End of stack trace from previous location where exception was thrown ---
kubectl get pods,svc -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
pod/postgres-pod 1/1 Running 0 45m 10.244.1.83 worker-1 <none> <none>
pod/redis-pod 1/1 Running 0 46m 10.244.1.82 worker-1 <none> <none>
pod/result-app-pod 1/1 Running 0 44m 10.244.1.85 worker-1 <none> <none>
pod/voting-app-pod 1/1 Running 0 41m 10.244.1.86 worker-1 <none> <none>
pod/worker-app-pod 1/1 Running 0 9s 10.244.1.88 worker-1 <none> <none>
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
service/db ClusterIP 10.110.106.32 <none> 5432/TCP 45m app=demo-voting-app,name=postgres-pod
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 13d <none>
service/redis ClusterIP 10.104.69.203 <none> 6379/TCP 45m app=demo-voting-app,name=redis-pod
service/result-service NodePort 10.103.67.16 <none> 80:30005/TCP 44m app=demo-voting-app,name=result-app-pod
service/voting-service NodePort 10.101.211.227 <none> 80:30004/TCP 41m app=demo-voting-app,name=voting-app-pod
kubectl describe pods voting-app-pod | grep Image
Image: kodekloud/examplevotingapp_vote:v1
Image ID: docker.io/kodekloud/examplevotingapp_vote@sha256:56c6e895bbf9eb49b8696d84b296c13b43e1855a73500484adc25f17246ce498
kubectl describe pods redis-pod | grep Image
Image: redis
Image ID: docker.io/library/redis@sha256:6a59f1cbb8d28ac484176d52c473494859a512ddba3ea62a547258cf16c9b3ae
kubectl describe pods worker-app-pod | grep Image
Image: kodekloud/examplevotingapp_worker:v1
Image ID: docker.io/kodekloud/examplevotingapp_worker@sha256:741e3aaaa812af72ce0c7fc5889ba31c3f90c79e650c2cb31807fffc60622263
I have tried deploying the application as pods and as deployment. In both cases, I am getting the same error. I would appreciate any help. (edited)