简体   繁体   中英

AWS Kubernetes RDS connection

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?

假设您的AWS部署现在与RDS位于同一VPC中,那么您将需要更改主机以使用专用IP。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM