• Kubernetes 通过 Deployment 部署Jupyterlab


    概要

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

    前置条件

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

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

    步骤

    1-namespace.yaml

    1. apiVersion: v1
    2. kind: Namespace
    3. metadata:
    4. name: jupyterlab
    5. labels:
    6. app1: jupyterlab
    7. 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)

    详细内容:

    1. apiVersion: v1
    2. kind: ConfigMap
    3. metadata:
    4. labels:
    5. app1: jupyterlab
    6. app.kubernetes.io/name: jupyterlab
    7. name: jupyter-config
    8. namespace: jupyterlab
    9. data:
    10. jupyter_lab_config.py: |-
    11. # Configuration file for lab.
    12. #------------------------------------------------------------------------------
    13. # Application(SingletonConfigurable) configuration
    14. #------------------------------------------------------------------------------
    15. ## This is an application.
    16. ## The date format used by logging formatters for %(asctime)s
    17. #c.Application.log_datefmt = '%Y-%m-%d %H:%M:%S'
    18. ## The Logging format template
    19. #c.Application.log_format = '[%(name)s]%(highlevel)s %(message)s'
    20. ## Set the log level by value or name.
    21. #c.Application.log_level = 30
    22. #------------------------------------------------------------------------------
    23. # JupyterApp(Application) configuration
    24. #------------------------------------------------------------------------------
    25. ## Base class for Jupyter applications
    26. ## Answer yes to any prompts.
    27. #c.JupyterApp.answer_yes = False
    28. ## Full path of a config file.
    29. c.JupyterApp.config_file = '/root/.jupyter/jupyter_lab_config.py'
    30. ## Specify a config file to load.
    31. #c.JupyterApp.config_file_name = ''
    32. ## Generate default config file.
    33. #c.JupyterApp.generate_config = False
    34. #------------------------------------------------------------------------------
    35. # ExtensionApp(JupyterApp) configuration
    36. #------------------------------------------------------------------------------
    37. ## Base class for configurable Jupyter Server Extension Applications.
    38. #
    39. # ExtensionApp subclasses can be initialized two ways:
    40. # 1. Extension is listed as a jpserver_extension, and ServerApp calls
    41. # its load_jupyter_server_extension classmethod. This is the
    42. # classic way of loading a server extension.
    43. # 2. Extension is launched directly by calling its `launch_instance`
    44. # class method. This method can be set as a entry_point in
    45. # the extensions setup.py
    46. ##
    47. #c.ExtensionApp.default_url = ''
    48. ## Handlers appended to the server.
    49. #c.ExtensionApp.handlers = []
    50. ## Whether to open in a browser after starting. The specific browser used is
    51. # platform dependent and determined by the python standard library `webbrowser`
    52. # module, unless it is overridden using the --browser (ServerApp.browser)
    53. # configuration option.
    54. #c.ExtensionApp.open_browser = False
    55. ## Settings that will passed to the server.
    56. #c.ExtensionApp.settings = {}
    57. ## paths to search for serving static files.
    58. #
    59. # This allows adding javascript/css to be available from the notebook server
    60. # machine, or overriding individual files in the IPython
    61. #c.ExtensionApp.static_paths = []
    62. ## Url where the static assets for the extension are served.
    63. #c.ExtensionApp.static_url_prefix = ''
    64. ## Paths to search for serving jinja templates.
    65. #
    66. # Can be used to override templates from notebook.templates.
    67. #c.ExtensionApp.template_paths = []
    68. #------------------------------------------------------------------------------
    69. # LabServerApp(ExtensionAppJinjaMixin,LabConfig,ExtensionApp) configuration
    70. #------------------------------------------------------------------------------
    71. ## A Lab Server Application that runs out-of-the-box
    72. ## "A list of comma-separated URIs to get the allowed extensions list
    73. #
    74. # .. versionchanged:: 2.0.0
    75. # `LabServerApp.whitetlist_uris` renamed to `allowed_extensions_uris`
    76. #c.LabServerApp.allowed_extensions_uris = ''
    77. ## Deprecated, use `LabServerApp.blocked_extensions_uris`
    78. #c.LabServerApp.blacklist_uris = ''
    79. ## A list of comma-separated URIs to get the blocked extensions list
    80. #
    81. # .. versionchanged:: 2.0.0
    82. # `LabServerApp.blacklist_uris` renamed to `blocked_extensions_uris`
    83. #c.LabServerApp.blocked_extensions_uris = ''
    84. ## The interval delay in seconds to refresh the lists
    85. #c.LabServerApp.listings_refresh_seconds = 3600
    86. ## The optional kwargs to use for the listings HTTP requests as
    87. # described on https://2.python-requests.org/en/v2.7.0/api/#requests.request
    88. #c.LabServerApp.listings_request_options = {}
    89. ## Deprecated, use `LabServerApp.allowed_extensions_uris`
    90. #c.LabServerApp.whitelist_uris = ''
    91. #------------------------------------------------------------------------------
    92. # LabApp(NBClassicConfigShimMixin,LabServerApp) configuration
    93. #------------------------------------------------------------------------------
    94. ## The app directory to launch JupyterLab from.
    95. #c.LabApp.app_dir = None
    96. ## Whether to enable collaborative mode.
    97. #c.LabApp.collaborative = False
    98. ## Whether to start the app in core mode. In this mode, JupyterLab will run using
    99. # the JavaScript assets that are within the installed JupyterLab Python package.
    100. # In core mode, third party extensions are disabled. The `--dev-mode` flag is an
    101. # alias to this to be used when the Python package itself is installed in
    102. # development mode (`pip install -e .`).
    103. #c.LabApp.core_mode = False
    104. ## The default URL to redirect to from `/`
    105. #c.LabApp.default_url = '/lab'
    106. ## Whether to start the app in dev mode. Uses the unpublished local JavaScript
    107. # packages in the `dev_mode` folder. In this case JupyterLab will show a red
    108. # stripe at the top of the page. It can only be used if JupyterLab is installed
    109. # as `pip install -e .`.
    110. #c.LabApp.dev_mode = False
    111. ## Whether to expose the global app instance to browser via window.jupyterlab
    112. #c.LabApp.expose_app_in_browser = False
    113. ## Whether to load prebuilt extensions in dev mode. This may be useful to run and
    114. # test prebuilt extensions in development installs of JupyterLab. APIs in a
    115. # JupyterLab development install may be incompatible with published packages, so
    116. # prebuilt extensions compiled against published packages may not work
    117. # correctly.
    118. #c.LabApp.extensions_in_dev_mode = False
    119. ## The override url for static lab assets, typically a CDN.
    120. #c.LabApp.override_static_url = ''
    121. ## The override url for static lab theme assets, typically a CDN.
    122. #c.LabApp.override_theme_url = ''
    123. ## Splice source packages into app directory.
    124. #c.LabApp.splice_source = False
    125. ## The directory for user settings.
    126. #c.LabApp.user_settings_dir = '/root/.jupyter/lab/user-settings'
    127. ## Whether to serve the app in watch mode
    128. #c.LabApp.watch = False
    129. ## The directory for workspaces
    130. #c.LabApp.workspaces_dir = '/root/.jupyter/lab/workspaces'
    131. #------------------------------------------------------------------------------
    132. # ServerApp(JupyterApp) configuration
    133. #------------------------------------------------------------------------------
    134. ## Set the Access-Control-Allow-Credentials: true header
    135. #c.ServerApp.allow_credentials = False
    136. ## Set the Access-Control-Allow-Origin header
    137. #
    138. # Use '*' to allow any origin to access your server.
    139. #
    140. # Takes precedence over allow_origin_pat.
    141. #c.ServerApp.allow_origin = ''
    142. ## Use a regular expression for the Access-Control-Allow-Origin header
    143. #
    144. # Requests from an origin matching the expression will get replies with:
    145. #
    146. # Access-Control-Allow-Origin: origin
    147. #
    148. # where `origin` is the origin of the request.
    149. #
    150. # Ignored if allow_origin is set.
    151. #c.ServerApp.allow_origin_pat = ''
    152. ## Allow password to be changed at login for the Jupyter server.
    153. #
    154. # While logging in with a token, the Jupyter server UI will give the opportunity
    155. # to the user to enter a new password at the same time that will replace the
    156. # token login mechanism.
    157. #
    158. # This can be set to false to prevent changing password from the UI/API.
    159. #c.ServerApp.allow_password_change = True
    160. ## Allow requests where the Host header doesn't point to a local server
    161. #
    162. # By default, requests get a 403 forbidden response if the 'Host' header shows
    163. # that the browser thinks it's on a non-local domain. Setting this option to
    164. # True disables this check.
    165. #
    166. # This protects against 'DNS rebinding' attacks, where a remote web server
    167. # serves you a page and then changes its DNS to send later requests to a local
    168. # IP, bypassing same-origin checks.
    169. #
    170. # Local IP addresses (such as 127.0.0.1 and ::1) are allowed as local, along
    171. # with hostnames configured in local_hostnames.
    172. c.ServerApp.allow_remote_access = True
    173. ## Whether to allow the user to run the server as root.
    174. c.ServerApp.allow_root = True
    175. ## " Require authentication to access prometheus metrics.
    176. #c.ServerApp.authenticate_prometheus = True
    177. ## Reload the webapp when changes are made to any Python src files.
    178. #c.ServerApp.autoreload = False
    179. ## The base URL for the Jupyter server.
    180. #
    181. # Leading and trailing slashes can be omitted, and will automatically be added.
    182. #c.ServerApp.base_url = '/'
    183. ## Specify what command to use to invoke a web browser when starting the server.
    184. # If not specified, the default browser will be determined by the `webbrowser`
    185. # standard library module, which allows setting of the BROWSER environment
    186. # variable to override it.
    187. #c.ServerApp.browser = ''
    188. ## The full path to an SSL/TLS certificate file.
    189. #c.ServerApp.certfile = ''
    190. ## The full path to a certificate authority certificate for SSL/TLS client
    191. # authentication.
    192. #c.ServerApp.client_ca = ''
    193. ## The config manager class to use
    194. #c.ServerApp.config_manager_class = 'jupyter_server.services.config.manager.ConfigManager'
    195. ## The content manager class to use.
    196. #c.ServerApp.contents_manager_class = 'jupyter_server.services.contents.largefilemanager.LargeFileManager'
    197. ## Extra keyword arguments to pass to `set_secure_cookie`. See tornado's
    198. # set_secure_cookie docs for details.
    199. #c.ServerApp.cookie_options = {}
    200. ## The random bytes used to secure cookies. By default this is a new random
    201. # number every time you start the server. Set it to a value in a config file to
    202. # enable logins to persist across server sessions.
    203. #
    204. # Note: Cookie secrets should be kept private, do not share config files with
    205. # cookie_secret stored in plaintext (you can read the value from a file).
    206. #c.ServerApp.cookie_secret = b''
    207. ## The file where the cookie secret is stored.
    208. #c.ServerApp.cookie_secret_file = ''
    209. ## Override URL shown to users.
    210. #
    211. # Replace actual URL, including protocol, address, port and base URL, with the
    212. # given value when displaying URL to the users. Do not change the actual
    213. # connection URL. If authentication token is enabled, the token is added to the
    214. # custom URL automatically.
    215. #
    216. # This option is intended to be used when the URL to display to the user cannot
    217. # be determined reliably by the Jupyter server (proxified or containerized
    218. # setups for example).
    219. #c.ServerApp.custom_display_url = ''
    220. ## The default URL to redirect to from `/`
    221. #c.ServerApp.default_url = '/'
    222. ## Disable cross-site-request-forgery protection
    223. #
    224. # Jupyter notebook 4.3.1 introduces protection from cross-site request
    225. # forgeries, requiring API requests to either:
    226. #
    227. # - originate from pages served by this server (validated with XSRF cookie and
    228. # token), or - authenticate with a token
    229. #
    230. # Some anonymous compute resources still desire the ability to run code,
    231. # completely without authentication. These services can disable all
    232. # authentication and security checks, with the full knowledge of what that
    233. # implies.
    234. #c.ServerApp.disable_check_xsrf = False
    235. ## handlers that should be loaded at higher priority than the default services
    236. #c.ServerApp.extra_services = []
    237. ## Extra paths to search for serving static files.
    238. #
    239. # This allows adding javascript/css to be available from the Jupyter server
    240. # machine, or overriding individual files in the IPython
    241. #c.ServerApp.extra_static_paths = []
    242. ## Extra paths to search for serving jinja templates.
    243. #
    244. # Can be used to override templates from jupyter_server.templates.
    245. #c.ServerApp.extra_template_paths = []
    246. ## Open the named file when the application is launched.
    247. #c.ServerApp.file_to_run = ''
    248. ## The URL prefix where files are opened directly.
    249. #c.ServerApp.file_url_prefix = 'notebooks'
    250. ## Extra keyword arguments to pass to `get_secure_cookie`. See tornado's
    251. # get_secure_cookie docs for details.
    252. #c.ServerApp.get_secure_cookie_kwargs = {}
    253. ## (bytes/sec) Maximum rate at which stream output can be sent on iopub before
    254. # they are limited.
    255. #c.ServerApp.iopub_data_rate_limit = 1000000
    256. ## (msgs/sec) Maximum rate at which messages can be sent on iopub before they are
    257. # limited.
    258. #c.ServerApp.iopub_msg_rate_limit = 1000
    259. ## The IP address the Jupyter server will listen on.
    260. c.ServerApp.ip = '*'
    261. ## Supply extra arguments that will be passed to Jinja environment.
    262. #c.ServerApp.jinja_environment_options = {}
    263. ## Extra variables to supply to jinja templates when rendering.
    264. #c.ServerApp.jinja_template_vars = {}
    265. ## Dict of Python modules to load as Jupyter server extensions.Entry values can
    266. # be used to enable and disable the loading ofthe extensions. The extensions
    267. # will be loaded in alphabetical order.
    268. #c.ServerApp.jpserver_extensions = {}
    269. ## The kernel manager class to use.
    270. #c.ServerApp.kernel_manager_class = 'jupyter_server.services.kernels.kernelmanager.AsyncMappingKernelManager'
    271. ## The kernel spec manager class to use. Should be a subclass of
    272. # `jupyter_client.kernelspec.KernelSpecManager`.
    273. #
    274. # The Api of KernelSpecManager is provisional and might change without warning
    275. # between this version of Jupyter and the next stable one.
    276. #c.ServerApp.kernel_spec_manager_class = 'jupyter_client.kernelspec.KernelSpecManager'
    277. ## The full path to a private key file for usage with SSL/TLS.
    278. #c.ServerApp.keyfile = ''
    279. ## Hostnames to allow as local when allow_remote_access is False.
    280. #
    281. # Local IP addresses (such as 127.0.0.1 and ::1) are automatically accepted as
    282. # local as well.
    283. #c.ServerApp.local_hostnames = ['localhost']
    284. ## The login handler class to use.
    285. #c.ServerApp.login_handler_class = 'jupyter_server.auth.login.LoginHandler'
    286. ## The logout handler class to use.
    287. #c.ServerApp.logout_handler_class = 'jupyter_server.auth.logout.LogoutHandler'
    288. ## Sets the maximum allowed size of the client request body, specified in the
    289. # Content-Length request header field. If the size in a request exceeds the
    290. # configured value, a malformed HTTP message is returned to the client.
    291. #
    292. # Note: max_body_size is applied even in streaming mode.
    293. #c.ServerApp.max_body_size = 536870912
    294. ## Gets or sets the maximum amount of memory, in bytes, that is allocated for use
    295. # by the buffer manager.
    296. #c.ServerApp.max_buffer_size = 536870912
    297. ## Gets or sets a lower bound on the open file handles process resource limit.
    298. # This may need to be increased if you run into an OSError: [Errno 24] Too many
    299. # open files. This is not applicable when running on Windows.
    300. #c.ServerApp.min_open_files_limit = 0
    301. ## DEPRECATED, use root_dir.
    302. #c.ServerApp.notebook_dir = ''
    303. ## Whether to open in a browser after starting. The specific browser used is
    304. # platform dependent and determined by the python standard library `webbrowser`
    305. # module, unless it is overridden using the --browser (ServerApp.browser)
    306. # configuration option.
    307. #c.ServerApp.open_browser = False
    308. ## Hashed password to use for web authentication.
    309. #
    310. # To generate, type in a python/IPython shell:
    311. #
    312. # from jupyter_server.auth import passwd; passwd()
    313. #
    314. # The string should be of the form type:salt:hashed-password.
    315. # password = 1
    316. c.ServerApp.password = 'argon2:$argon2id$v=19$m=10240,t=10,p=8$3SVwOn5jZCsVPToRwHfo6A$/Q67MolIfT+ztoV26F6eeuE0NxfhFFsyzLV//9IV+J4'
    317. ## Forces users to use a password for the Jupyter server. This is useful in a
    318. # multi user environment, for instance when everybody in the LAN can access each
    319. # other's machine through ssh.
    320. #
    321. # In such a case, serving on localhost is not secure since any user can connect
    322. # to the Jupyter server via ssh.
    323. #c.ServerApp.password_required = False
    324. ## The port the server will listen on (env: JUPYTER_PORT).
    325. c.ServerApp.port = 8888
    326. ## The number of additional ports to try if the specified port is not available
    327. # (env: JUPYTER_PORT_RETRIES).
    328. #c.ServerApp.port_retries = 50
    329. ## Preferred starting directory to use for notebooks and kernels.
    330. #c.ServerApp.preferred_dir = ''
    331. ## DISABLED: use %pylab or %matplotlib in the notebook to enable matplotlib.
    332. #c.ServerApp.pylab = 'disabled'
    333. ## If True, display controls to shut down the Jupyter server, such as menu items
    334. # or buttons.
    335. #c.ServerApp.quit_button = True
    336. ## (sec) Time window used to check the message and data rate limits.
    337. #c.ServerApp.rate_limit_window = 3
    338. ## Reraise exceptions encountered loading server extensions?
    339. #c.ServerApp.reraise_server_extension_failures = False
    340. ## The directory to use for notebooks and kernels.
    341. c.ServerApp.root_dir = '/home/jupyterlab'
    342. ## The session manager class to use.
    343. #c.ServerApp.session_manager_class = 'jupyter_server.services.sessions.sessionmanager.SessionManager'
    344. ## Shut down the server after N seconds with no kernels or terminals running and
    345. # no activity. This can be used together with culling idle kernels
    346. # (MappingKernelManager.cull_idle_timeout) to shutdown the Jupyter server when
    347. # it's not in use. This is not precisely timed: it may shut down up to a minute
    348. # later. 0 (the default) disables this automatic shutdown.
    349. #c.ServerApp.shutdown_no_activity_timeout = 0
    350. ## The UNIX socket the Jupyter server will listen on.
    351. #c.ServerApp.sock = ''
    352. ## The permissions mode for UNIX socket creation (default: 0600).
    353. #c.ServerApp.sock_mode = '0600'
    354. ## Supply SSL options for the tornado HTTPServer. See the tornado docs for
    355. # details.
    356. #c.ServerApp.ssl_options = {}
    357. ## Supply overrides for terminado. Currently only supports "shell_command".
    358. #c.ServerApp.terminado_settings = {}
    359. ## Set to False to disable terminals.
    360. #
    361. # This does *not* make the server more secure by itself. Anything the user can
    362. # in a terminal, they can also do in a notebook.
    363. #
    364. # Terminals may also be automatically disabled if the terminado package is not
    365. # available.
    366. #c.ServerApp.terminals_enabled = True
    367. ## Token used for authenticating first-time connections to the server.
    368. #
    369. # The token can be read from the file referenced by JUPYTER_TOKEN_FILE or set
    370. # directly with the JUPYTER_TOKEN environment variable.
    371. #
    372. # When no password is enabled, the default is to generate a new, random token.
    373. #
    374. # Setting to an empty string disables authentication altogether, which is NOT
    375. # RECOMMENDED.
    376. #c.ServerApp.token = ''
    377. ## Supply overrides for the tornado.web.Application that the Jupyter server uses.
    378. #c.ServerApp.tornado_settings = {}
    379. ## Whether to trust or not X-Scheme/X-Forwarded-Proto and X-Real-Ip/X-Forwarded-
    380. # For headerssent by the upstream reverse proxy. Necessary if the proxy handles
    381. # SSL
    382. #c.ServerApp.trust_xheaders = False
    383. ## Disable launching browser by redirect file For versions of notebook > 5.7.2, a
    384. # security feature measure was added that prevented the authentication token
    385. # used to launch the browser from being visible. This feature makes it difficult
    386. # for other users on a multi-user system from running code in your Jupyter
    387. # session as you. However, some environments (like Windows Subsystem for Linux
    388. # (WSL) and Chromebooks), launching a browser using a redirect file can lead the
    389. # browser failing to load. This is because of the difference in file
    390. # structures/paths between the runtime and the browser.
    391. #
    392. # Disabling this setting to False will disable this behavior, allowing the
    393. # browser to launch by using a URL and visible token (as before).
    394. #c.ServerApp.use_redirect_file = True
    395. ## Specify where to open the server on startup. This is the `new` argument passed
    396. # to the standard library method `webbrowser.open`. The behaviour is not
    397. # guaranteed, but depends on browser support. Valid values are:
    398. #
    399. # - 2 opens a new tab,
    400. # - 1 opens a new window,
    401. # - 0 opens in an existing window.
    402. #
    403. # See the `webbrowser.open` documentation for details.
    404. #c.ServerApp.webbrowser_open_new = 2
    405. ## Set the tornado compression options for websocket connections.
    406. #
    407. # This value will be returned from
    408. # :meth:`WebSocketHandler.get_compression_options`. None (default) will disable
    409. # compression. A dict (even an empty one) will enable compression.
    410. #
    411. # See the tornado docs for WebSocketHandler.get_compression_options for details.
    412. #c.ServerApp.websocket_compression_options = None
    413. ## The base URL for websockets, if it differs from the HTTP server (hint: it
    414. # almost certainly doesn't).
    415. #
    416. # Should be in the form of an HTTP origin: ws[s]://hostname[:port]
    417. #c.ServerApp.websocket_url = ''

     3-jupyter-class.yaml

    1. apiVersion: storage.k8s.io/v1
    2. kind: StorageClass
    3. metadata:
    4. name: nfs-jupyterlab
    5. namespace: jupyterlab
    6. annotations:
    7. storageclass.kubernetes.io/is-default-class: "false" ## 是否设置为默认的storageclass
    8. provisioner: k8s-sigs.io/nfs-subdir-external-provisioner # or choose another name, must match deployment's env PROVISIONER_NAME'
    9. #provisioner: nfs-subdir-external-provisioner # or choose another name, must match deployment's env PROVISIONER_NAME'
    10. parameters:
    11. archiveOnDelete: "true"
    12. pathPattern: "${.PVC.namespace}/${.PVC.name}/${.PVC.annotations.nfs.io/storage-path}"
    13. # pathPattern: "${.PVC.namespace}/${.PVC.annotations.nfs.io/storage-path}"
    14. # pathPattern: "${.PVC.namespace}-${.PVC.name}"

    5-pvc.yaml

    1. ---
    2. apiVersion: v1
    3. kind: PersistentVolumeClaim
    4. metadata:
    5. name: nfs-jupyterlab
    6. namespace: jupyterlab
    7. annotations:
    8. volume.beta.kubernetes.io/storage-class: "nfs-jupyterlab"
    9. spec:
    10. accessModes:
    11. - ReadWriteMany
    12. resources:
    13. requests:
    14. storage: 50Mi

    6-jupyter-deployment.yaml

    1. apiVersion: apps/v1
    2. kind: Deployment
    3. metadata:
    4. name: jupyterlab-deployment
    5. namespace: jupyterlab
    6. labels:
    7. app1: jupyterlab
    8. app.kubernetes.io/name: jupyterlab
    9. spec:
    10. replicas: 1
    11. selector:
    12. matchLabels:
    13. app1: jupyterlab
    14. app.kubernetes.io/name: jupyterlab
    15. template:
    16. metadata:
    17. labels:
    18. app1: jupyterlab
    19. app.kubernetes.io/name: jupyterlab
    20. spec:
    21. affinity:
    22. nodeAffinity:
    23. requiredDuringSchedulingIgnoredDuringExecution:
    24. nodeSelectorTerms:
    25. - matchExpressions:
    26. - key: kubernetes.io/hostname
    27. operator: NotIn
    28. values:
    29. - master01
    30. - master02
    31. - master03
    32. hostNetwork: true
    33. containers:
    34. - name: jupyterlab
    35. image: reporsitory:5000/jupyterlab:1.1
    36. imagePullPolicy: Always
    37. ports:
    38. - name: jupyterlab
    39. containerPort: 8888
    40. command:
    41. - bash
    42. - "-c"
    43. - |
    44. set -ex
    45. /usr/local/bin/jupyter-lab
    46. resources:
    47. requests:
    48. cpu: 250m
    49. memory: 500Mi
    50. limits:
    51. cpu: 250m
    52. memory: 500Mi
    53. volumeMounts:
    54. - name: data
    55. mountPath: "/home/jupyterlab/data"
    56. - name: jupyter-config
    57. mountPath: /root/.jupyter/
    58. - name: jupyter
    59. mountPath: /home/jupyterlab
    60. volumes:
    61. - name: data
    62. persistentVolumeClaim:
    63. claimName: nfs-jupyter-mysql
    64. - name: jupyter
    65. persistentVolumeClaim:
    66. claimName: nfs-jupyterlab
    67. - name: jupyter-config
    68. configMap:
    69. name: jupyter-config

    7-services.yaml

    1. ---
    2. apiVersion: v1
    3. kind: Service
    4. metadata:
    5. name: jupyterlab-svc
    6. namespace: jupyterlab
    7. labels:
    8. app1: jupyterlab
    9. app.kubernetes.io/name: jupyterlab
    10. spec:
    11. ports:
    12. - name: jupyterlab
    13. port: 8888
    14. selector:
    15. app1: jupyterlab
    16. type: NodePort

     成功

    后端状况:

    网页访问:

    Jupyterlab服务的Pod提升

    部署kubectl + bash-completion

    在 Linux 系统中安装并设置 kubectl | Kubernetes

    使用 kubeconfig 文件组织集群访问 | Kubernetes

    更新数据库使用者权限

    1. grant all privileges on *.* to 'root'@'%' identified by '1' with grant option;
    2. flush privileges;

    参考文档

    https://developer.aliyun.com/article/857365
    https://www.jianshu.com/p/743ed2209a8c
    https://www.runoob.com/linux/linux-comm-nohup.html
    https://cloud.tencent.com/developer/article/1783227
    https://zhuanlan.zhihu.com/p/468585680

  • 相关阅读:
    新能源汽车行业资讯-2022-9-19
    设计模式之中介者模式
    基础讲解——ES6
    epiiAdmin框架注意事项
    List集合&UML图
    java子类向父类转型再转回子类
    老哥们平日是怎么排查线上问题的?
    No.1 - 职场关键角色通识宝典之课程内容先导
    一篇文章带你走进cookie,session,Token的世界
    java8 新特性
  • 原文地址:https://blog.csdn.net/m0_59267075/article/details/133981046