rancher 2.0 networking in project namespace

7/25/2018

can i ping one workload from other workload by workloadname?

I accustomed on rancher 1.0, where if i created stack with more conteiner so i can ping one from other conteiner by name.

rancher application

for example: I have api and database and I need api to communicate with databases. When i click on execute shell on api and write "ping database", so not working.

I write connection string to database in api environmental variable. And YES i can create database and take database ip a write it to ENV, but this ip will change after each restart.

It's possible to call by some not generate name?

thanks

EDIT: Service discovery: service discovery

Shell: execute shell

As you see, so translate database name is work. Only ping database container not working.

-- Tomáš Kacálek
docker
kubernetes
networking
rancher

2 Answers

7/31/2018

Kubernetes Service IP is implemented using "iptables" on the linux hosts which are part of the cluster. If you examine those rules closely, ONLY the port specified as part of the Service is exposed, not the ICMP port, which means, one cannot ping the Service IP addresses by default. But you would still be able to communicate with the Service on the designated port.

-- leodotcloud
Source: StackOverflow

7/26/2018

To communicate between services you can communicate with cluster IP or with Service Name.

Using the ServiceName will be easier.

The service discovery add a DNS for each of your service. So if you have api, app and database you will have a DNS entry for each of those services.

So within your services, you can refer directly to the DNS.

Example: To connect in JDBC to a schema name test in your database, you would do something like this: jdbc:mysql://database/test

see: https://rancher.com/docs/rancher/v2.x/en/k8s-in-rancher/service-discovery/

If you want to know the clusterIP of you services you can run this command: kubectl get services --all-namespaces

Edit 1: Adding ClusterIP as a way to communicate with a service.

-- Mike
Source: StackOverflow