marathon 配置https 访问
最近因为安全要求对原本http
访问的marathon 配置为https
访问, 对如何配置ssl进行了说明,但这里主要说明采用rpm 安装的marathon https访问配置, 以下是配置过程和说明
1.创建jks证书
官方文档提供生成jks的方式,但略显复杂,这里提供一个简单生成jks方式
#生成jks证书export MARATHON_SSL_KEYSTORE_PASSWORD="password"keytool -keystore marathon.jks -deststorepass $MARATHON_SSL_KEYSTORE_PASSWORD -alias marathon -genkey -keyalg RSA
生成的marathon.jks
后面配置marathon时候将会引用到
2.安装marathon
这里使用的是rpm/deb包进行marathon 安装,mesosphere 官方提供了对应的仓库包下载地址, 我这里下载centos7x版本的仓库,执行如下命令进行安装配置
#1.安装仓库包rpm -i http://repos.mesosphere.io/el/7/noarch/RPMS/mesosphere-el-repo-7-2.noarch.rpm#2.安装mesos,marathonyum makecache fast && yum install mesos marathon -y
3. 配置marathon https
这里简单说一下一个必要的zookeeper配置, 默认应用/etc/mesos/zk
文件为zookeeper配置,如果你的zookeeper是集群方式则用,
区分多个实例即可
官方推荐使用http_credentials
验证加上ssl证书方式保障传输安全以及http认证,配置https有两种方式,一种是采用直接配置/usr/lib/systemd/system/marathon.service
另外一种是采用配置变量目录应用/etc/marathon/conf/
,两种方式配置如下
marathon.service 配置方式
#1.在ExecStart=/usr/bin/marathon 后面增肌,注意--http_credentials 后面需要你带 账号:密码信息以配置https访问的认证账号密码ExecStart=/usr/bin/marathon --ssl_keystore_path /root/cert/marathon.jks --ssl_keystore_password marathon.jks密码 --disable_http --http_credentials 账号:密码 --leader_proxy_ssl_ignore_hostname#2.重载systemctl daemon-reload#3.启动marathonsystemctl start marathon#4.查看日志tail -f /var/log/messages
变量引用配置
需要创建/etc/marathon/conf/
目录,将对应的配置在conf目录下创建对应的文件,将参数写入文件中,下面是例子
#1.配置mkdir -p /etc/marathon/conf && \echo '/marathon.jks'>/etc/marathon/conf/ssl_keystore_path && \echo 'jks密码' >/etc/marathon/conf/ssl_keystore_password && \echo ''>/etc/marathon/conf/disable_http && \echo '账号:密码'>/etc/marathon/conf/http_credentials && \echo ''>/etc/marathon/conf/leader_proxy_ssl_ignore_hostname#2.启动marathonsystemctl start marathon
4. 遇到的问题
4.1 while proxying 报错导致marathon 异常
错误信息:
WARN /v2/deployments (org.eclipse.jetty.servlet.ServletHandler:563)java.lang.RuntimeException: while proxying at mesosphere.marathon.api.LeaderProxyFilter.doFilter(LeaderProxyFilter.scala:147) [...]
此问题见 , 简单来说就是我们的ca证书非公共认证的签名,导致leader proxy
报错, 官方后面提供了对应的解决办法,但经过测试并不太好实现, 这里有一个简单的方式避免就是配置leader_proxy_ssl_ignore_hostname
参数
4.2 LIBPROCESS_IP 环境变量问题导致未注册到mesos
错误信息:
Scheduler driver bound to loopback interface! Cannot communicate with remote master(s). You might want to set 'LIBPROCESS_IP' environment variable to use a routable IP address.
这里很多人弄错了一点LIBPROCESS_IP
环境变量不能通过export LIBPROCESS_IP=本机ip
进行配置,必须写入到配置文件/etc/sysconfig/marathon
#配置LIBPROCESS_IP 变量echo "LIBPROCESS_IP=服务器ip" >> /etc/sysconfig/marathon