nginx访问jupyter
现在jupyter已通过k8s安装完成,并通过nodeport暴露出来。
如果不能直接访问这个nodeport(像我在的公司)或是希望能组织好jupyter实例,
那应该如何调通呢?
这里包括两个技术点:
一,jupyter本身需要允许指定ip的访问。
红色部分,继承了docker镜像的cmd,并新增了--NotebookApp.allow_origin='*'参数,不然,nginx跳过去,jypyter不接受。
apiVersion: apps/v1
kind: Deployment
metadata:
name: ai-jupyter
spec:
replicas: 1
selector:
matchLabels:
name: ai-jupyter
template:
metadata:
labels:
name: ai-jupyter
spec:
imagePullSecrets:
- name: xxxx
nodeSelector:
accelerator: nvidia-tesla-k80
containers:
- name: sis-ai-jupyter
image: harbor.xxxx.com.cn/3rd_part/tensorflow:1.14.0-gpu-py3-jupyter
imagePullPolicy: IfNotPresent
command: ["bash", "-c", "source /etc/bash.bashrc && jupyter notebook --notebook-dir=/tf --ip 0.0.0.0 --no-browser --allow-root --NotebookApp.allow_origin='*'"]
resources:
limits:
nvidia.com/gpu: 2
---
apiVersion: v1
kind: Service
metadata:
name: ai-jupyter
spec:
type: NodePort
ports:
- port: 8888
targetPort: 8888
nodePort: 30302
selector:
name: ai-jupyter
二,nginx需要有websocket的升级处理。
红色部分,对kernels和terminals两个目录的连接,作了ws升级处理。
upstream ai_jupyter {
ip_hash;
server 1.2.3.4:30302;
}
server {
listen 8080;
server_name localhost;
location / {
proxy_set_header Host $host;
proxy_set_header X-FORWARDED-FOR $remote_addr;
proxy_pass http://ai_jupyter;
}
location ~ /api/kernels/ {
proxy_pass http://ai_jupyter;
proxy_set_header Host $host;
# websocket support
proxy_http_version 1.1;
proxy_set_header Upgrade "websocket";
proxy_set_header Connection "Upgrade";
proxy_read_timeout 86400;
}
location ~ /terminals/ {
proxy_pass http://ai_jupyter;
proxy_set_header Host $host;
# websocket support
proxy_http_version 1.1;
proxy_set_header Upgrade "websocket";
proxy_set_header Connection "Upgrade";
proxy_read_timeout 86400;
}
}
nginx访问jupyter的更多相关文章
- Nginx 访问日志轮询切割
Nginx 访问日志轮询切割脚本 #!/bin/sh Dateformat=`date +%Y%m%d` Basedir="/application/nginx" Nginxlog ...
- 按日期切割nginx访问日志--及性能优化
先谈下我们需求,一个比较大的nginx访问日志,根据访问日期切割日志,保存在/tmp目录下. 测试机器为腾讯云机子,单核1G内存.测试日志大小80M. 不使用多线程版: #!/usr/bin/env ...
- 一、基于hadoop的nginx访问日志分析---解析日志篇
前一阵子,搭建了ELK日志分析平台,用着挺爽的,再也不用给开发拉各种日志,节省了很多时间. 这篇博文是介绍用python代码实现日志分析的,用MRJob实现hadoop上的mapreduce,可以直接 ...
- Python正则表达式,统计分析nginx访问日志
目标: 1.正则表达式 2.oop编程,统计nginx访问日志中不同IP地址出现的次数并排序 1.正则表达式 #!/usr/bin/env python # -*- coding: utf-8 -*- ...
- linux端安装Anaconda,方便远端访问jupyter
ipython notebook是一个基于浏览器的python数据分析工具,使用起来非常方便,具有极强的交互方式和富文本的展示效果.jupyter是它的升级版,它的安装也非常方便,一般Anaconda ...
- Nginx访问控制模块
一.Nginx访问控制模块 Nginx默认安装的模块http_access_module,可以基于来源IP进行访问控制. 1.模块安装 nginx中内置ngx_http_access_module,除 ...
- logstash收集nginx访问日志
logstash收集nginx访问日志 安装nginx #直接yum安装: [root@elk-node1 ~]# yum install nginx -y 官方文档:http://nginx.org ...
- 使用python找出nginx访问日志中访问次数最多的10个ip排序生成网页
使用python找出nginx访问日志中访问次数最多的10个ip排序生成网页 方法1:linux下使用awk命令 # cat access1.log | awk '{print $1" &q ...
- nginx访问不到
nginx访问不到 今天,一朋友的一台linux服务器上部署了nginx,但是外部(公网)就是不能访问,于是协助其排查.整体思路如下: 1.确认nginx配置是否ok. 2.确认网络是否可达. 3.是 ...
随机推荐
- linux翻页及字符串搜索操作
向下翻动一屏幕: space, ctrl + f, ctrl + v, ctrl + F 向下翻动半屏: d, ctrl + D 向下翻动一行: 回车, e, j 向上翻动一屏幕: b, ctrl + ...
- [LeetCode] 899. Orderly Queue 有序队列
A string S of lowercase letters is given. Then, we may make any number of moves. In each move, we c ...
- [LeetCode] 301. Remove Invalid Parentheses 移除非法括号
Remove the minimum number of invalid parentheses in order to make the input string valid. Return all ...
- [LeetCode] 69. Sqrt(x) 求平方根
Implement int sqrt(int x). Compute and return the square root of x, where x is guaranteed to be a no ...
- eclipse 设置所有文件编码为UTF-8(最全)
如何修改eclipse工作空间的字符集以及项目的字符集? 第一种方式:修改eclipse的配置文件 打开{ECLIPSE_HOME}/eclipse.ini文件 在最后一行加上属性: -Dfile ...
- Navicat的安装和pymysql模块的使用
内容回顾 select distinct 字段1,字段2,... from 表名 where 分组之前的过滤条件 group by 分组条件 having 分组之后过滤条件 order by 排序字段 ...
- ApartmentState.STA
需要设置子线程 ApartmentState 为 STA 模式,但 Task 又不能直接设置 ApartmentState,因此需要用 Thread 来封装一下. using System.Threa ...
- intellij idea 解决2019年4月到期延期问题
56ZS5PQ1RF-eyJsaWNlbnNlSWQiOiI1NlpTNVBRMVJGIiwibGljZW5zZWVOYW1lIjoi5q2j54mI5o6I5p2DIC4iLCJhc3NpZ25lZ ...
- vm ------ 安装
虚拟机(英语:virtual machine),在计算机科学中的体系结构里,是指一种特殊的软件,可以在计算机平台和终端用户之间创建一种环境,而终端用户则是基于这个软件所创建的环境来操作软件. 虚拟机最 ...
- 【转】用VMware 8安装Ubuntu 12.04详细过程(图解)
图解演示环境版本: 本机系统: WIN7 虚拟机:VMware Workstation 8 (英文版) 安装目标:Ubuntu Desktop 12.04 LTS (请点击这里)先下载好iso镜像文 ...