mesosphere / mesos-rxjava

RxJava client for Apache Mesos HTTP APIs
Apache License 2.0
42 stars 27 forks source link

Add option to disable master redirection #72

Open Payero opened 7 years ago

Payero commented 7 years ago

I am not completely familiar with the internals of a Mesos cluster, but I have a question. My settings is simple: 1 AWS EC2 instance running mesos and 1 laptop running the Sleepy framework. When I run the framework the MesosClient probes the endpoint using the EC2 public IP address and returns a new link to the master.

2017-03-31 17:58:59,881 INFO [main ] c.m.mesos.rx.java.MesosClient - Probing Mesos server at http://**aws-public-ip**:5050/redirect

This probe gets redirected to: Using new Mesos URI: {} http://**aws-private-ip**:5050/api/v1/scheduler

Because it gets redirected to the private IP and the laptop is on a different subnet it cannot connect to it. In order to get it to work I added a kludge where I look for a system property and if is set then skip the redirect. This kludge works, but I was wondering if there is a better way to do this.

Thanks Oscar

luizmiranda7 commented 7 years ago

Have you tried to set the ip property into your mesos-master configuration? I had the same error and I resolved it by this way.

Payero commented 7 years ago

Luiz, Thanks for the reply, I did not know there was a property for that already. Where can I find the name of the property to use?

Oscar

luizmiranda7 commented 7 years ago

Payero,

The configuration that must be present is "hostname", not "ip".

As you can see in the manual (http://mesos.apache.org/documentation/latest/configuration/) there are several configurations for mesos master and slave nodes. If you are starting the master as service all the configs are mapped at /etc/mesos-master/ path just as files. For example:

If you want to set the quorum of your mesos-master, you just need to add a file called quorum (with no extensions) at /etc/mesos-master/ and then add an integer to you file (1, 2, 3 ...).

Once mesos is starting, the service reads the folder and for each file found, mesos will read its content and transform it into the named configuration of your file. So basically, if I create a file called hostname with content equal to "www.google.com" mesos will start with: --hostname=www.google.com.

BenWhitehead commented 7 years ago

@Payero Thanks for reaching out.

The ip address returned by Mesos is the ip it has been configured to bind to for all of its communication, including between the masters and agents of the cluster. The property used to config the ip address mesos will listen on (masters and agents) is LIBPROCESS_IP (full docs about can be found here). By default if the environment variable isn't specified mesos will usually just use the ip address of eth0.

In general it's not a great idea to have your mesos master directly accessible for framework registration outside the cluster as this can lead to rogue frameworks taking resources. If you have access to the cluster, using a vpn or using ssh/scp to run your framework inside the cluster will generally be easier from an architecture standpoint.

I'd like to leave this issue one, and rename it to "Add option to disable master redirection" if that's okay with you?

Payero commented 7 years ago

Ben, Thanks for the reply, the reason why I want to run the framework from the outside is to facilitate development and testing. Once that is completed or "stable" then I will move it to the cloud. I enabled authentication so only agents and frameworks authorized to register can do so. I will be fine renaming the issue, thanks for the help,

Oscar

BenWhitehead commented 7 years ago

@Payero Sounds good, and good call turning on auth in mesos itself to protect yourself.

varpa89 commented 6 years ago

+1 for this issue =)