JupyterHub与OpenLDAP集成

原文

1.文档编写目的


Fayson在前面文章《如何在非安全的CDH集群中部署Jupyter并集成Spark2》及《如何在非安全的CDH集群中部署多用户JupyterHub服务并集成Spark2》中介绍了Jupyter与JupyterHub的部署与Spark2集成。JupyterHub的用户默认是基于OS系统用户,对于用户的管理和维护都需要在服务器上进行操作不便于管理。本篇文章Fayson主要介绍在JupyterHub中如何与OpenLDAP服务集成。

  • 测试环境

1.CM5.15.0和CDH版本5.14.2

2.JupyterHub版本为0.9.2

3.Python版本为3.6.5

  • 前置条件

1.JupyterHub已部署成功

2.JupyterHub与OpenLDAP集成


在JupyterHub中默认只支持操作系统PAM默认的认证方式,如果需要JupyterHub支持OpenLDAP认证,则需要安装OpenLDAP认证的插件,插件地址:https://github.com/jupyterhub/ldapauthenticator

1.在Python3环境中安装jupyterhub-ldapauthenticator包,命令如下:

[root@cdh03 ~]# /opt/cloudera/anaconda3/bin/pip install jupyterhub-ldapauthenticator

(可左右滑动)

安装完成后验证是否安装成功

[root@cdh03 ~]# /opt/cloudera/anaconda3/bin/pip show jupyterhub-ldapauthenticator

(可左右滑动)

2.修改/etc/jupyterhub/jupyterhub_config.py文件,增加OpenLDAP配置,在文件默认增加内容如下:

#指定JupyterHub认证类型
c.JupyterHub.authenticator_class = 'ldapauthenticator.LDAPAuthenticator'
#OpenLDAP服务地址
c.LDAPAuthenticator.server_address = 'ldap://cdh01.fayson.com'
#访问用户和组的DN
c.LDAPAuthenticator.bind_dn_template = [
    "uid={username},ou=People,dc=fayson,dc=com",
    "uid={username},ou=Group,dc=fayson,dc=com"
]

(可左右滑动)

3.启动Jupyterhub服务

[root@cdh03 jupyterhub]# /opt/cloudera/anaconda3/bin/jupyterhub -f /etc/jupyterhub/jupyterhub_config.py --debug

(可左右滑动)

如上显示启动成功,在启动命令后添加--debug参数可以显示DEBUG日志,-f指定JupyterHub启动加载的配置文件。

3.集成验证


1.在OpenLDAP上创建一个testldap测试用户

2.在浏览器输入http://cdh03.fayson.com:8000访问JupyterHub,使用testldap用户登录

登录成功

打开一个Notebook,并运行一段测试的pyspark代码

查看Yarn上的作业

4.总结


1.JupyterHub与OpenLDAP集成需要安装jupyterhub-ldapauthenticator插件。

2.可以通过配置Group限制访问JupyterHub的用户组,更多配置可参考GitHub:https://github.com/jupyterhub/ldapauthenticator

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值