Kubernetes 通过 Deployment 部署Jupyterlab

概要

在Kubernetes上部署jupyterlab服务,链接Kubernetes集群内的MySQL,实现简单的数据开发功能。

前置条件

镜像准备:自定义Docker镜像--Jupyterlab-CSDN博客

MySQL-Statefulset准备:StatefulSet 简单实践 Kubernetes-CSDN博客

步骤

1-namespace.yaml

apiVersion: v1
kind: Namespace
metadata:
  name: jupyterlab
  labels:
    app1: jupyterlab
    app.kubernetes.io/name: jupyterlab

2-jupyter-config.yaml

关键配置:

  • c.ServerApp.allow_remote_access = True
  • c.ServerApp.ip = '*'
  • c.ServerApp.open_browser = False  
  • c.ServerApp.password = ''
  • c.ServerApp.port = 8888

c.ServerApp.ip = '' 默认事localhost,配置 "*" 便于访问,便于nodeport的访问

如何生成password,参考:

jupyter-lab 设置密码(password) - 简书 (jianshu.com)

详细内容:

apiVersion: v1
kind: ConfigMap
metadata:
  labels:
    app1: jupyterlab
    app.kubernetes.io/name: jupyterlab
  name: jupyter-config
  namespace: jupyterlab
data:
  jupyter_lab_config.py: |-
    # Configuration file for lab.

    #------------------------------------------------------------------------------
    # Application(SingletonConfigurable) configuration
    #------------------------------------------------------------------------------

    ## This is an application.

    ## The date format used by logging formatters for %(asctime)s
    #c.Application.log_datefmt = '%Y-%m-%d %H:%M:%S'

    ## The Logging format template
    #c.Application.log_format = '[%(name)s]%(highlevel)s %(message)s'

    ## Set the log level by value or name.
    #c.Application.log_level = 30

    #------------------------------------------------------------------------------
    # JupyterApp(Application) configuration
    #------------------------------------------------------------------------------

    ## Base class for Jupyter applications

    ## Answer yes to any prompts.
    #c.JupyterApp.answer_yes = False

    ## Full path of a config file.
    c.JupyterApp.config_file = '/root/.jupyter/jupyter_lab_config.py'

    ## Specify a config file to load.
    #c.JupyterApp.config_file_name = ''

    ## Generate default config file.
    #c.JupyterApp.generate_config = False

    #------------------------------------------------------------------------------
    # ExtensionApp(JupyterApp) configuration
    #------------------------------------------------------------------------------

    ## Base class for configurable Jupyter Server Extension Applications.
    #  
    #  ExtensionApp subclasses can be initialized two ways:
    #  1. Extension is listed as a jpserver_extension, and ServerApp calls
    #      its load_jupyter_server_extension classmethod. This is the
    #      classic way of loading a server extension.
    #  2. Extension is launched directly by calling its `launch_instance`
    #      class method. This method can be set as a entry_point in
    #      the extensions setup.py

    ## 
    #c.ExtensionApp.default_url = ''

    ## Handlers appended to the server.
    #c.ExtensionApp.handlers = []

    ## Whether to open in a browser after starting. The specific browser used is
    #  platform dependent and determined by the python standard library `webbrowser`
    #  module, unless it is overridden using the --browser (ServerApp.browser)
    #  configuration option.
    #c.ExtensionApp.open_browser = False

    ## Settings that will passed to the server.
    #c.ExtensionApp.settings = {}

    ## paths to search for serving static files.
    #  
    #  This allows adding javascript/css to be available from the notebook server
    #  machine, or overriding individual files in the IPython
    #c.ExtensionApp.static_paths = []

    ## Url where the static assets for the extension are served.
    #c.ExtensionApp.static_url_prefix = ''

    ## Paths to search for serving jinja templates.
    #  
    #  Can be used to override templates from notebook.templates.
    #c.ExtensionApp.template_paths = []

    #------------------------------------------------------------------------------
    # LabServerApp(ExtensionAppJinjaMixin,LabConfig,ExtensionApp) configuration
    #------------------------------------------------------------------------------

    ## A Lab Server Application that runs out-of-the-box

    ## "A list of comma-separated URIs to get the allowed extensions list
    #  
    #  .. versionchanged:: 2.0.0
    #      `LabServerApp.whitetlist_uris` renamed to `allowed_extensions_uris`
    #c.LabServerApp.allowed_extensions_uris = ''

    ## Deprecated, use `LabServerApp.blocked_extensions_uris`
    #c.LabServerApp.blacklist_uris = ''

    ## A list of comma-separated URIs to get the blocked extensions list
    #  
    #  .. versionchanged:: 2.0.0
    #      `LabServerApp.blacklist_uris` renamed to `blocked_extensions_uris`
    #c.LabServerApp.blocked_extensions_uris = ''

    ## The interval delay in seconds to refresh the lists
    #c.LabServerApp.listings_refresh_seconds = 3600

    ## Th
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值