You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to kubernetes-dev
Hi,
I am trying to setup kubernetes cluster first time and facing some troubles. In docker i am able to connect to my database which runs outside containers. I configure all db with host name inside app config and it resolves it from /etc/hosts file and connect to database. I have option in docker to pass variable using --add-host.
What is the best way to do the same in kubernetes?
Thanks
Gokul
Tim Hockin
unread,
Feb 13, 2016, 7:23:12 PM2/13/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Gokul nath, kubernetes-dev
The general answer to this is to make a Service with no selector and
then an Endpoints that redirects where you want it. This gives you
freedom to change that assignment later without restarting containers.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to kubernetes-dev, gokula...@gmail.com
I tried service and endpoints as suggested. But It assign some new IP when i create a service and resolves to that new IP. What i want is to resolve the IP(static IP) which i specify. (Note: I am trying to connect to external service outside kubernetes cluster)
Please correct me if i am wrong.
Pablo Mercado
unread,
Feb 16, 2016, 5:27:09 AM2/16/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to kubernetes-dev, gokula...@gmail.com
If I'm getting that right, you want to resolve to the real IP of your external resource. Although that can be done, as Tim already wrote, the proper way of using the external resource is creating a service, and then using the internal cluster IP assigned to that service, so that you decouple containers and external resource. Use the environment variable (or DNS name if you have it at your disposal for service resolution) and forget about the external IP.
If you have to stick to the external IP for some reason (I would suggest not going this way) you can create your pods adding environment variables with the external resource location (see pod yaml specification), but take into consideration that if you want to change that IP you would need to deploy brand new containers with the new environment variable.
Tim Hockin
unread,
Feb 17, 2016, 12:31:29 AM2/17/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to kubernetes-dev, gokula...@gmail.com
Thanks. It worked. I am able to connect to external service by using service and endpoint. As you said i need to forget actual external IP and it automatically resolves/redirects to it when service is called.
One more thing, I am able to resolve it from master node as well as pod containers which is running on kubernetes minion. When i try the nslookup from kubernetes minion node it is not working and getting connection refused error.
From minion node command line:
ex: kubectl exec myapp -- nslookup my-service
error: couldn't read version from server: Get http://localhost:8080/api: dial tcp [::1]:8080: getsockopt: connection refused
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.