AWS Kubernetes RDS connection

3/10/2018

I'm having some trouble with my AWS Kubernetes instance.

I'm trying to get my django instances to connect to the RDS service via the DB endpoint.

DATABASES = {
    'default': {
        'ENGINE': 'django.contrib.gis.db.backends.postgis',
        'NAME': os.environ['NAME'],
        'USER': os.environ['USER'],
        'PASSWORD': os.environ['PASSWORD'],
        'HOST': os.environ['HOST'],
        'PORT': os.environ['PORT']
    }
}

The host string would resemble this service.key.region.rds.amazonaws.com and is being passed to the container via env in the deploy.yml

containers:
  - name: service
    env:
      - name: HOST
        value: service.key.region.rds.amazonaws.com

This set up works locally in kubernetes but not when I put it in the cluster I have on AWS. It returns the following error instead:

django.db.utils.OperationalError: could not translate host name

Any suggestions or am I missing something in how AWS likes handling things?

-- macintoshPrime
amazon-rds
amazon-web-services
django
kubernetes

1 Answer

3/10/2018

Assuming your AWS deployment is now in the same VPC as your RDS, then you will need to change your host to use the private IP.

-- the4thv
Source: StackOverflow