ernetes的入口通过以太网对JupyterHub进行远程访问

ernetes的入口通过以太网对JupyterHub进行远程访问

本文介绍了通过Kubernetes的入口通过以太网对JupyterHub进行远程访问零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上下文

我在裸机服务器(4个节点)上安装了 Kubernetes ,并将 Zero部署到JupyterHub .这很好用;我可以从主节点正确访问集线器.

I installed Kubernetes on a bare-metal server (4 nodes) and deployed Zero to JupyterHub to it.This works fine; I can correctly access the hub from the master-node.

现在,我想通过以太网从外部计算机访问服务器上的集线器.因此,我遵循了官方说明并安装了 MetalLB 以便为我的 proxy-public 服务提供外部IP(该IP正确设置).
此外,为了能够进行入侵,我安装了 nginx-ingress-controller ,也可以成功获取外部IP(小提示:使用 Helm 图表;应用其他推荐步骤时,我无法使服务运行).

Now I want to access the Hub on the server from an external computer via Ethernet. Therefore, I followed the official instructions and installed MetalLB in order to provide an external IP for my proxy-public-service (which correctly sets).
Additionally, I installed the nginx-ingress-controller in order to be able to do an ingress, which also successfully gets an external IP (little hint: Use the Helm-chart; I couldn't get the service running when applying the other recommended steps).

由于我在弄清楚如何进行此入口方面遇到了一些麻烦,因此下面是一个示例:

Since I had a little trouble figuring out how to do this ingress, here is an example:

kubectl apply -f ingress.yaml --namespace jhub

#ingress.yaml:
#apiVersion: networking.k8s.io/v1beta1
#kind: Ingress
#metadata:
#  name: jupyterhub-ingress
#  annotations:
#    nginx.ingress.kubernetes.io/rewrite-target: /$1
#spec:
#  rules:
#  - host: jupyterhub.cluster
#    http:
#      paths:
#      - path: /
#        backend:
#          serviceName: proxy-public
#          servicePort: 80

无论如何,我无法打开 proxy-public 提供的外部IP(这意味着我在浏览器中插入了外部IP).

Anyhow, I cannot open the external IP proxy-public provides (meaning I'm inserting the external IP in my browser).


问题

如何通过外部IP远程访问JupyterHub?我想念什么?

How can I remotely access my JupyterHub over the external IP; what am I missing?

推荐答案

我想念这可以通过与 Kubernetes-Dashboard 相同的方法来实现:您必须建立一个开放的ssh-从外部计算机进行连接(因此,打开隧道-> 隧道).
当然,这不是我想到的外部"访问方式,而是针对我的测试环境(也许是您的环境)的一种有效且快速的解决方案.


如何建立此ssh-connect

I missed that this can be achieved in the same way as with the Kubernetes-Dashboard: You have to establish an open ssh-connection (hence, open a tunnel -> tunneling) from the external computer.
Of course this is not the "exernal" access I had in mind, but a working and fast solution for my test-environment (and maybe yours).


How to establish this ssh-connect

首先,获取您的 proxy-public 的外部IP地址:

First, get the external IP-address of your proxy-public:

$: kubectl get services --namespace jhub
NAME           TYPE           CLUSTER-IP       EXTERNAL-IP     PORT(S)                      AGE
hub            ClusterIP      10.99.241.72     <none>          8081/TCP                     95m
proxy-api      ClusterIP      10.107.175.27    <none>          8001/TCP                     95m
proxy-public   LoadBalancer   10.102.171.162   192.168.1.240   80:31976/TCP,443:32568/TCP   95m

注意:外部IP的范围是在我的 MetalLB -config中的 layer2 中定义的.

Note: The range of the external IP was defined in my layer2 in my MetalLB-config.

使用此信息(并假设您使用的是Linux),打开终端并使用以下命令:

Using this information (and assuming you're on Linux), open a terminal and use the following command:

$ ssh [email protected] -L 8000:192.168.1.240:80
# -L opens a localhost-connection
# [email protected] logs me into my second node with user pi

注意1 :将 localhost:8000 配置为具有 http proxy-public 的targetPort可以是在描述服务并分别查看规格时看到的端口(您也可以在此处获得https的设置):

Note1: That localhost:8000 is configured as targetPort for proxy-public with http can also be seen when you describe the service and take a look at the specs respectively ports (you can also get the settings for https there):

kind: Service
apiVersion: v1
metadata:
  name: proxy-public
  namespace: jhub
  ...
spec:
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 8000
      nodePort: 31976
    - name: https
...

最后,在浏览器中输入 http://localhost:8000/-等,您将进入JupyterHub登录页面!

Finally, type http://localhost:8000/ into your browser - et voila, you get to your JupyterHub login-page!

这篇关于通过Kubernetes的入口通过以太网对JupyterHub进行远程访问零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 22:05