Use of kubeflow-6-jupyter notebook

The essence of using the notebook servers function in kubeflow is to set up a jupyter lab container and run a jupyter service in the container.
The name of the notebook service, which cannot be repeated by default. The notebook service mirror can choose an existing mirror, or you can use a personalized mirror that contains your own python environment.

The default mount address of the workspace in the container is /home/jovyan, but in fact its files are stored in the respective pv under the local-path-provisioner definition directory. By default, the contents of the workspace are permanently saved. You can use a workspace personally or share it with others.

10.23.241.142   myuse2
10.23.241.97    myuse1

1 Build a custom kubeflow notebook image

The basic requirement for building a notebook mirror is to install the toolkit of jupyter and notebook in the mirrored python environment.

1.1 Dockerfile

FROM python:3.6
MAINTAINER bingbing <[email protected]>
RUN pip3 install pip -U
RUN pip3 config set global.index-url http://mirrors.aliyun.com/pypi/simple
RUN pip3 config set install.trusted-host mirrors.aliyun.com
RUN pip3 install notebook
RUN pip3 install jupyter
RUN mkdir /home/jovyan
ENV NB_PREFIX /
CMD ["sh","-c", "jupyter notebook --notebook-dir=/home/jovyan --ip=0.0.0.0 --no-browser --allow-root --port=8888 --NotebookApp.token='' --NotebookApp.password='' --NotebookApp.allow_origin='*' --NotebookApp.base_url=${NB_PREFIX}"]

Parameter meaning:

--notebook-dir=/home/jovyan 指明了notebook服务的工作路径
--ip=0.0.0.0 jupyter服务监听所有ip
--allow-root 允许使用root权限运行notebook
设置notebook服务端口 --port=8888
不需要用户认证,免密登入 --NotebookApp.token='' --NotebookApp.password='' --NotebookApp.allow_origin='*'

1.2 Create a mirror image my-notebook-py3:v1.0

# mkdir /root/mytestnotebook
# cp Dockerfile /root/mytestnotebook
# docker pull python:3.6
# docker build -t my-notebook-py3:v1.0 .

1.3 Test run image

#docker run -id --name=c_mynotebook -p 8888:8888 my-notebook-py3:v1.0
#docker exec -it c_mynotebook /bin/bash进入容器
#docker stop c_mynotebook停止容器
#docker container prune#批量删除已停止的容器

http://10.23.241.97:8888
Insert picture description hereupload the file rulesRunning.log via upload, enter the container, and find it is located in the /home/jovyan directory.

Insert picture description here

1.4 Incremental Mirroring

Regardless of the size of the image file, storing images in containers is a more user-friendly way.
Proceed as follows:

docker ps找到当前容器的id
docker commit container-id image:tag将当前容器存为指定名字可标签的镜像

1.5 kubeflow uses the mirror my-notebook-py3:v1.0

(1) Log in to kubeflow's dashboard
http://10.23.241.97:31380 to log in to kubeflow's dashboard.
The default user name and password
(2) The image is published to multiple nodes
#docker save -o my-notebook-py3-v1.0.tar my-notebook-py3:v1.0 to
transfer the image to another node
#docker load -i my-notebook-py3-v1.0.tar
(3) Start the notebook server

Insert picture description here

(4) After successful creation
Insert picture description here

(5) Click to connect
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_20466211/article/details/113625734