I'm running a django + postgrsq/pgbouncer + redis project on Kuerbenetes (OVH public cloud)
Each on their own pod and I sometimes encounter this kind of error
django.db.utils.OperationalError: could not translate host name "pgbouncer" to address: Try again
redis.exceptions.ConnectionError: Error -3 connecting to redis:6379. Try again.
requests.exceptions.ConnectionError: HTTPConnectionPool
As if Django pod sometimes lost connection with the other pods (redis / pgbouncer or other services we use)
It mainly happens if I send concurrency requests (not a lot) and it is very random
Pods are declared as type: ClusterIP on the default namespace and I access them from Django using their service name
I put below the config for Redis/Django-rq as an example but not sure it will help as it happens for any other services used by Django.
Django settings.py
RQ_QUEUES = {
'default': {
'HOST': 'redis',
'PORT': 6379,
'DB': 0,
},
}
redis yaml file
apiVersion: v1
kind: Service
metadata:
name: redis
labels:
app: redis
spec:
type: ClusterIP
ports:
- port: 6379
targetPort: 6379
protocol: TCP
name: http
selector:
app: redis
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis
labels:
app: redis
spec:
selector:
matchLabels:
app: redis
template:
metadata:
labels:
app: redis
spec:
restartPolicy: Always
containers:
- name: redis
image: redis
imagePullPolicy: Always
ports:
- containerPort: 6379
Can someone already had this kind of issue or an idea how to figure out why this happens (and avoid/fix it) ?
Thanks