How communicate with mesos when mesos is SSL_ENABLED
mesos has supported SSL_ENABLED.
When I setup the env in master node:
SSL_ENABLED=true
SSL_KEY_FILE=xxx
SSL_CERT_FILE=xxx
marathon can not register to mesos master successfully.
marathon version 0.9.2 mesos version 0.24.1
syslog:
Oct 31 01:58:43 ip-172-31-43-77 marathon[14040]: I1031 01:58:43.929865 14110 sched.cpp:318] Authenticating with master [email protected]:5050 Oct 31 01:58:43 ip-172-31-43-77 marathon[14040]: I1031 01:58:43.929872 14110 sched.cpp:325] Using default CRAM-MD5 authenticatee Oct 31 01:58:43 ip-172-31-43-77 marathon[14040]: I1031 01:58:43.929939 14110 authenticatee.cpp:115] Creating new client SASL connection
Oct 31 01:58:43 ip-172-31-43-77 marathon[14040]: I1031 01:58:43.929852 14110 sched.cpp:387] Failed to authenticate with master [email protected]:5050: Authentication discarded
Have you provided: --mesos_authentication_principal and --mesos_authentication_secret_file for mesos authentication?
Did you compile Mesos with --enable--ssl --enable-libevent?
And did you start Marathon with --ssl_keystore_path <...> --ssl_keystore_password <...>?
Also, can you tell us all the arguments you used to set up Mesos and Marathon? (And perhaps more complete logs.)
In addition to compiling Mesos itself with --enable-ssl --enable-libevent, you will also need to build Marathon against the ssl-enabled libmesos, and set the SSL_ENABLED/etc. environment variables when launching the Marathon scheduler. Encryption is a two-way street, so both Mesos and the framework schedulers (e.g. Marathon) must enable it.
The --ssl_keystore_* flags are for https communication from your browser/client to the Marathon web UI, and are not necessary for encrypted communication with Mesos (although encrypting the Marathon UI is also recommended).
I would recommend disabling framework authentication (don't set --mesos_authentication_* in Marathon, or --authenticate on the Mesos master), so we can verify that SSL encryption is causing the issue, not something with your authentication setup (unless authentication works fine without SSL).
@adam-mesos I have compiled Mesos 0.26.0 with the right enable flags and ran it with SSL_ENABLED=true and cert verification off. Marathon 0.14.0 is still failing to register with Mesos master nodes with a error which is likely caused because of a failed SSL handshake. My guess is that Marathon (run without authentication flags and against ssl enabled libmesos as pointed by you) is trying to register with mesos over http while Mesos might be forcing it to do SSL-handshake which its clearly unable to handle yet.
Marathon logs:
2016-02-11 17:14:32,611:32244(0x7feaf5097700):ZOO_INFO@check_events@1752: session establishment complete on server [192.168.1.47:2181], sessionId=0x352c79a8f860098, negotiated timeout=10000
I0211 17:14:32.611419 1224 group.cpp:331] Group process (group(1)@192.168.1.16:44993) connected to ZooKeeper
I0211 17:14:32.611448 1224 group.cpp:805] Syncing group operations: queue size (joins, cancels, datas) = (0, 0, 0)
I0211 17:14:32.611460 1224 group.cpp:403] Trying to create path '/mesos' in ZooKeeper
I0211 17:14:32.614714 1218 detector.cpp:156] Detected a new leader: (id='59')
I0211 17:14:32.614881 1218 group.cpp:674] Trying to get '/mesos/json.info_0000000059' in ZooKeeper
I0211 17:14:32.616231 1218 detector.cpp:482] A new leading master ([email protected]:5050) is detected
I0211 17:14:32.616317 1218 sched.cpp:264] New master detected at [email protected]:5050
I0211 17:14:32.616498 1218 sched.cpp:274] No credentials provided. Attempting to register without authentication
E0211 17:14:32.617075 1227 process.cpp:1911] Failed to shutdown socket with fd 41: Transport endpoint is not connected
[2016-02-11 17:14:32,618] INFO Reset offerLeadership backoff (mesosphere.marathon.MarathonSchedulerService$$EnhancerByGuice$$f5465784:main-EventThread)
[2016-02-11 17:14:32,624] INFO Scheduler actor ready (mesosphere.marathon.MarathonSchedulerActor:marathon-akka.actor.default-dispatcher-8)
[2016-02-11 17:14:47,625] INFO Syncing tasks for all apps (mesosphere.marathon.SchedulerActions:marathon-akka.actor.default-dispatcher-9)
[2016-02-11 17:14:47,629] INFO Message [mesosphere.marathon.MarathonSchedulerActor$TasksReconciled$] from Actor[akka://marathon/user/MarathonScheduler/$a#-1484234496] to Actor[akka://marathon/deadLetters] was not delivered. [1] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'. (akka.actor.DeadLetterActorRef:marathon-akka.actor.default-dispatcher-10)
Mesos verbose logs:
I0211 17:14:31.300258 13086 hierarchical.cpp:876] Performed allocation for 3 slaves in 120678ns
I0211 17:14:32.301213 13086 hierarchical.cpp:977] No resources available to allocate!
I0211 17:14:32.301245 13086 hierarchical.cpp:1070] No inverse offers to send out!
I0211 17:14:32.301257 13086 hierarchical.cpp:876] Performed allocation for 3 slaves in 120678ns
I0211 17:14:32.617447 13088 libevent_ssl_socket.cpp:1025] Socket error: error:1407609C:SSL routines:SSL23_GET_CLIENT_HELLO:http request
I0211 17:14:33.302223 13086 hierarchical.cpp:977] No resources available to allocate!
I0211 17:14:33.302259 13086 hierarchical.cpp:1070] No inverse offers to send out!
I0211 17:14:33.302270 13086 hierarchical.cpp:876] Performed allocation for 3 slaves in 115930ns
Could you please help ? Am I missing something here ?. If not, this seems to be a lacking feature for folks who want to run their entire infrastructure over SSL only.
@TalonOne You'll also need to set the SSL environment variables described at http://mesos.apache.org/documentation/latest/ssl/ when starting your Marathon scheduler process.
@adam-mesos Ah! I didnt know that. Yes, with all those environment variables set, it seems to work now. I will let it run for a few days to monitor though. Thanks!
Tl:dr; Is there a way in Marathon to set a bunch of environment variables in CommandInfo.environment while not exposing those values inside docker containers env.
@adam-mesos @aquamatthias: It turns out, Mesos expects all SSL_* variables to be set inside 'CommandInfo.environment` for its executor to report status into the slave node over HTTPS. Is there a way to do this under covers and not expose those environment variables inside the running container. #1813
At the moment setting these variables in the app JSON would also set them inside the containers environment variables, which is not secure (though the container does not have access to cert/keys).
If not, this would be necessary for smooth transitioning to HTTPS in a Mesos/Marathon cluster while ensuring there is no information leakage into containers spun by the executors.
Ref: https://issues.apache.org/jira/browse/MESOS-4750
@adam-mesos @TalonOne I am running into a similar issue here whenever I have SSL_SUPPORT_DOWNGRADE=false in addition to the aforementioned SSL_* environment variables. On both Marathon and Mesos Master I have set that environment variable. The log I see is as follows:
Failed to authenticate with master [email protected]:5050: Authentication discarded
Removing the downgrade option, which defaults to allowing SSL downgrading, causes everything to work fine. I think that I need to authenticate with the master's hostname and not IP to make this work, though I am not sure. I have the proper LIBPROCESS_IP set and with the downgrade option set to true, I am able to hit my hostname over ssl fine. I would just like to get rid of http altogether. Can someone point me to the right direction?
@koadr I got it working by authenticating with mesos master ip
Successfully authenticated with master [email protected]:5050
Also, as pointed in the comment just above yours, did you set the SSL_* environmental flags in the JSON used to launch the Marathon app ? You would need them.
I atleast needed these in my app.json to get it all working:
"env": {
"SSL_ENABLED" : "1",
"SSL_SUPPORT_DOWNGRADE": "0",
"SSL_VERIFY_CERT" : "1",
"SSL_REQUIRE_CERT" : "1",
"SSL_KEY_FILE": "/var/mesos/mesos.key",
"SSL_CERT_FILE": "/var/mesos/mesos.cert",
"SSL_CA_FILE" : "/var/mesos/ca.pem",
"SSL_ENABLE_TLS_V1_2": "1"
}
The side effect is that your container would have all the SSL_* flags available in the shell environment, not idea, but I couldn't find a better solution at the moment. These variables are used only by the Executor and not my the actual container (even though available as env variables for the shell), so you dont have to mount /var/mesos into the container, there by NOT exposing Mesos secrets inside the container.
@adam-mesos @aquamatthias Is there a way to set environment variables in `CommandInfo.environment" withouth exposing those variables inside the running containers ? Please let us know. That would be ideal.
@TalonOne I wasn't having the issue with a marathon app, but rather connecting to any framework in general. I am using upstart confs for mesos master(s), slaves, marathon, and chronos. My upstart has all SSL_* envs.
description "mesos master"
limit nofile {{mesos_ulimit}}
start on stopped rc RUNLEVEL=[2345]
respawn
env SSL_ENABLED={{enable_ssl}}
env SSL_SUPPORT_DOWNGRADE={{support_ssl_downgrade}}
env SSL_KEY_FILE={{ssl_key_file}}
env SSL_CERT_FILE={{ssl_cert_file}}
env SSL_CA_FILE={{ssl_ca_file}}
env SSL_VERIFY_CERT={{ssl_verify_cert}}
env SSL_ENABLE_TLS_V1_1={{ssl_enable_tls_v1_1}}
exec /usr/local/mesos-{{mesos_version}}/build/bin/mesos-master.sh --quorum={{mesos_quorum}} --work_dir={{mesos_work_dir}} \
--port={{mesos_master_port}} --cluster={{mesos_cluster_name}} --ip={{mesos_ip}} --log_dir={{mesos_log_location}} \
--zk={{ mesos_zookeeper_masters }} --hostname={{ mesos_hostname }} --acls={{mesos_acls_path}} --authenticate=true \
--authenticate_http=true --authenticate_slaves=true --credentials={{mesos_credentials_path}}
I have similar files for marathon, mesos-slave, and chronos. The problem I have is only for cases when SSL_SUPPORT_DOWNGRADE is set to false. SSL works great with downgrade available. Just preventing outright is what breaks for me. I'm not 100% sure why.
I have the same issue. I'm using mesos 0.27.1 with SSL and framework + slave authentication enabled. Sometimes frameworks (marathon) and slaves can connect with no problem but most of the time they get stuck in this loop where mesos-master is queuing up the authentication requests and they all time out, leaving the framework or slave forever attempting to authenticate.
The really shitty workaround appears to be stopping everything that is stuck in an authentication loop, then waiting some time (maybe 5-10m) then starting them 1 by 1. Then they will often connect.
It appears that mesos is getting in a bad state with a massive queue of some sort so that it can never respond to authentication requests on time. This is really annoying when I am trying to create a setup that is resilient to machine failures and a lot of the time all of my slaves and/or frameworks are not connecting and all of my services get killed and not restarted.
This thread has brought up at least a few legitimate Mesos issues, and I'd like to push these further in the Mesos dev community (not just Marathon). Please add any relevant logs/thoughts/discussion to the appropriate Mesos JIRAs.
- MESOS-3815 Executors don't work with SSL enabled, unless you explicitly add the SSL variables to the executor's environment. However, it's debatable whether we even need encryption over the local socket.
- @TalonOne "Is there a way to set environment variables in `CommandInfo.environment" without exposing those variables inside the running containers?" -You've exposed one of the contradictions of default vs. custom executors. While the default executor is known Mesos code, safe to run outside of the container (with different environment variables than its task), a custom executor is untrusted user code which the operator would want to see isolated inside the container. In the latter case, the credentials and environment variables would need to be exposed inside the container for the custom executor to use them. Relevant discussion going on at MESOS-3836 You may also be interested in the "Unified Containerizer" project MESOS-2840
- MESOS-2043 Authentication discarded timeouts. I'm beginning to suspect this is because we never implemented a backoff on authentication retries. Bumping this one up in priority. @koadr @kevincox
Note: This issue has been migrated to https://jira.mesosphere.com/browse/MARATHON-3549. For more information see https://groups.google.com/forum/#!topic/marathon-framework/khtvf-ifnp8.