1、环境
win7、vituralblx(3)、cetnos7、k8s1.15.2、NFS
https://blog.csdn.net/u011739062/article/details/99643177
https://mp.csdn.net/postedit/99473145
2.安装jupyterhub(k8s)
官网地址:https://zero-to-jupyterhub.readthedocs.io/en/latest/
2.1 helm版本2.14.3(参考https://www.jianshu.com/p/200020e7a843)
先pull 镜像到本地 gcr.io/kubernetes-helm/tiller v2.14.3
再登录阿里hub账号(google网络问题初始化失败)
helm init --upgrade -i gcr.io/kubernetes-helm/tiller:v2.14.3 --stable-repo-url https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
2.2 按照官方教程
首先建好pv、pvc 以及配置好config.yaml
[root@test001 nfs-pv]# cat nfs-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: nfs-pv
spec:
capacity:
storage: 1000Mi
accessModes:
- ReadWriteMany
nfs:
# FIXME: use the right IP
server: 192.168.56.103
path: "/new_disk/nfs"
[root@test001 nfs-pv]# cat nfs-pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: hub-db-dir
namespace: jhub
spec:
accessModes:
- ReadWriteMany
storageClassName: ""
resources:
requests:
storage: 900Mi
[root@test001 nfs-pv]# cat /root/config.yaml
proxy:
secretToken: "461e64c9907351b6cd18152da94e49cbeb903427a74e28a7ee12e9b2f39062a2"
service:
type: LoadBalancer
hub:
uid: 1000
fsGid: 1000
image:
name: jupyterhub/k8s-hub
tag: 0.9-dcde99a
db:
type: sqlite-memory
extraConfig: |-
config = '/etc/jupyter/jupyter_notebook_config.py'
c.Spawner.cmd = ['jupyter-labhub']
singleuser:
uid: 1000
fsGid: 100
defaultUrl: "/lab"
image:
name: jupyter/all-spark-notebook
tag: 2ce7c06a61a1
storage:
type: "static"
static:
pvcName: "hub-db-dir"
subPath: 'home/{username}'
extraEnv:
CHOWN_HOME: 'yes'
memory:
limit:
guarantee: 1G
这里选择小的一个官方镜像(其他自选,配置启动不同)按照官方(忽略一些步骤)
helm upgrade --install $RELEASE jupyterhub/jupyterhub \
--namespace $NAMESPACE \ --version=0.8.2 \
--version=0.9-2d435d6 \
--values config.yaml
hub-db-dir 和它安装对应(讲道理应该可以自定义)
安装好之后发现 跨域等问题
2.暴露外部访问
官方支持的k8s部署是云服务,这里虚拟机就不支持LoadBalancer,方案多种
1.ingress
https://zhuanlan.zhihu.com/p/50407362
2.metallb
我这边使用这个
1.安装metallb
kubectl apply -f https://raw.githubusercontent.com/google/metallb/v0.8.1/manifests/metallb.yaml
2.测试metallb(忽略)
3.发现proxy-public不再是pending,已经OK
NFS磁盘问题(要和镜像里权限一致)
[root@master k8s]# ll /nfs/home/
drwxr-xr-x 2 1000 users 6 8月 17 16:21 wnagly
drwxr-xr-x 4 1000 users 36 8月 17 16:36 tom
[root@master k8s]#
外部访问 http://192.168.56.102 正常spwaner