0

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

wzxecr
  • 11
  • 4

1 Answers1

0

As per Mik Goldwyn answered from a post with the same concern, edited by Mostafa Barmshory:

The following command (which removes all unused containers, networks, images, and optionally, volumes) solve my problem:

docker system prune

See docker document for more information

Dion V
  • 356
  • 2
  • 7
  • Thanks but no. In the post you mention connection never worked and the command is for Docker whereas I'm running my containers on kubernetes. In my case most of the time all is ok. But sometimes connection is lost (mostly when running lots of concurrency requests). And thus some requests failed. – wzxecr Apr 04 '23 at 14:22