metadata: labels: app: k8s-21e497d4-42e1-479a-86a5-73f9da1fd5e6 type: webApp userId: '1' name: k8s-21e497d4-42e1-479a-86a5-73f9da1fd5e6 spec: containers: - env: - name: PUID value: '1011' - name: PGID value: '1011' - name: DEFAULT_WORKSPACE value: /config/workspace image: registry.cn-hangzhou.aliyuncs.com/sj-bioinfo/linuxserver-code-server imagePullPolicy: Always name: k8s-21e497d4-42e1-479a-86a5-73f9da1fd5e6 volumeMounts: - mountPath: /data/k8sData name: nfdata subPath: k8sData - mountPath: /data/workspace/1 name: nfdata subPath: workspace/1 - mountPath: /config/workspace name: nfdata subPath: workspace/1 - mountPath: /config/.kube name: nfdata subPath: user/.kube - mountPath: /etc/hosts name: nfdata subPath: user/hosts - mountPath: /data name: nfdata - mountPath: /data23 name: nfdata23 - mountPath: /ssd2/software name: software - mountPath: /data/resultData name: nfdata subPath: resultData - mountPath: /data/databases name: nfdata subPath: databases restartPolicy: Always securityContext: runAsGroup: 0 runAsUser: 0 volumes: - name: software persistentVolumeClaim: claimName: software - name: nfdata23 persistentVolumeClaim: claimName: nfdata23 - name: nfdata persistentVolumeClaim: claimName: nfdata metadata: name: k8s-21e497d4-42e1-479a-86a5-73f9da1fd5e6 spec: type: NodePort ports: - name: client nodePort: 32012 port: 8443 protocol: TCP targetPort: 8443 selector: app: k8s-21e497d4-42e1-479a-86a5-73f9da1fd5e6 sessionAffinity: ClientIP
jupyter lab --NotebookApp.token='' --NotebookApp.ip='0.0.0.0' --NotebookApp.base_url='/jupyter/'
- id: vscode-cloud uri: http://192.168.10.177:32007 predicates: - Path=/vscode/** filters: - RewritePath=/vscode/?(?<segment>.*), /$\{segment} - id: vscode2 uri: http://192.168.10.177:32007 predicates: - Path=/vscode2/** filters: - StripPrefix=1 - id: jupyter uri: http://192.168.10.30:8888 predicates: - Path=/jupyter/**
注意: 代理jupyter与代理vscode不同,不能使用filters: StripPrefix=1
jupyter
vscode
filters: StripPrefix=1
http://192.168.10.30:40000/vscode/
http://192.168.10.30:40000
/vscode/
/vscode/?folder=/data
对于jupyter,当我们试图采用与vscode相同的方式代理时,
jupyter lab --NotebookApp.token='' --NotebookApp.ip='0.0.0.0'
- id: jupyter uri: http://192.168.10.30:8888 predicates: - Path=/jupyter/** filters: - StripPrefix=1
当你试图访问http://192.168.10.30:40000/jupyter/浏览器会跳跳转到http://192.168.10.30:40000/lab?,由于StripPrefix=1会导致实际访问路径是没有jupyter的,并且http://192.168.10.30:40000这个ip下是没有路由lab的。因此我们首先需要去掉StripPrefix=1
http://192.168.10.30:40000/jupyter/
http://192.168.10.30:40000/lab?
StripPrefix=1
lab
- id: jupyter uri: http://192.168.10.30:8888 predicates: - Path=/jupyter/**
结果如下:
[W 2024-11-16 14:59:23.440 ServerApp] 404 GET /jupyter (e70b3f6436bc444490f4ec0b5624685b@192.168.10.30) 1.51ms referer=None
此时就需要添加jupyter的参数base_url
base_url
--NotebookApp.base_url='/jupyter'
接下来访问http://192.168.10.30:40000/jupyter/lab就可以成功!注,如果跨域可以添加参数--NotebookApp.allow_origin='*'
http://192.168.10.30:40000/jupyter/lab
--NotebookApp.allow_origin='*'