Reputation: 1476
I'm trying to access remotely an AWS RDS Database instance running on private PVC through
kubectl port-forward
The RDS database public accessiblity is set to "No", also I have an EKS cluster running on the same RDS PVC, the pods and services of EKS are able to communicate with AWS RDS.
So far I have created below service
kind: Service
metadata:
name: postgres-service
spec:
type: ExternalName
externalName: xxx-xxx.xxxxxxx.eu-xx-1.rds.amazonaws.com
And below is the kubectl command that I have executed
kubectl run -it --rm --image=postgres postgres-client -- postgres-service --host=xx-xx.xx.eu-west-1.rds.amazonaws.com --port=5432 --username=xxx --password=xxx --dbname=xxx
and the result I get is
error: timed out waiting for the condition
Upvotes: 2
Views: 1279
Reputation: 30083
If you dont want to use kubectl you can use postgress client pod setup in EKS cluster full time.
Or else you can run command like this :
kubectl run postgresql-client --rm --tty -i --restart='Never' --namespace default --image bitnami/postgresql --env="PGPASSWORD=<YOUR_PASSWORD>" --command -- psql --host <YOUR_HOSTNAME=SVC_NAME_OR_IP> -U <HERE_USERNAME>
make sure you are using the proper namespace name and service name.
Both are in the same VPC means you can direct connect over internal address or IP without creating an external service.
Upvotes: 2