【问题标题】:Kubernetes: Why my NodePort can not get an external ip?Kubernetes:为什么我的 NodePort 无法获取外部 ip?
【发布时间】:2020-07-03 13:18:39
【问题描述】:

环境信息:

Computer detail: One master node and four slave nodes. All are CentOS Linux release 7.8.2003 (Core).
Kubernetes version: v1.18.0.
Zero to JupyterHub version: 0.9.0.
Helm version: v2.11.0

最近,我尝试在 kubernetes 上部署“Zero to Jupyterhub”。我的 jupyterhub 配置文件如下:

config.yaml

proxy:
  secretToken: "2fdeb3679d666277bdb1c93102a08f5b894774ba796e60af7957cb5677f40706"
  service:
    type: NodePort
    nodePorts:
      http: 30080
      https: 30443
singleuser:
  storage:
    dynamic:
      storageClass: local-storage
    capacity: 10Gi

注意:我将服务类型设置为NodePort,因为我没有任何云提供商(部署在我的实验室服务器集群上),我尝试使用nginx-ingress也失败了,这就是我不使用LoadBalance的原因。

但是当我使用这个配置文件通过Helm 安装jupyterhub 时,我无法从浏览器访问jupyterhub,即使所有Pods 正在运行。这些 pod 的详细信息如下:

kubectl get pod --namespace jhub

NAME                              READY   STATUS    RESTARTS   AGE
continuous-image-puller-8gxxk     1/1     Running   0          27m
continuous-image-puller-8tmdh     1/1     Running   0          27m
continuous-image-puller-lwdcx     1/1     Running   0          27m
continuous-image-puller-pszsr     1/1     Running   0          27m
hub-7b9cbbcf59-fbppq              1/1     Running   0          27m
proxy-6b699b54c8-2pxmb            1/1     Running   0          27m
user-scheduler-65f4cbb9b7-9vmfr   1/1     Running   0          27m
user-scheduler-65f4cbb9b7-lqfrh   1/1     Running   0          27m

它的服务是这样的:

kubectl get service --namespace jhub

NAME           TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)                      AGE
hub            ClusterIP   10.10.55.78    <none>        8081/TCP                     28m
proxy-api      ClusterIP   10.10.27.133   <none>        8001/TCP                     28m
proxy-public   NodePort    10.10.97.11    <none>        443:30443/TCP,80:30080/TCP   28m

似乎运作良好,对吧? (我猜到了。)但事实是我无法使用 ip 10.10.97.11 访问 jupyter 主页,而且我也没有获得任何外部 ip。

所以,我的问题是:

  1. 我的配置有问题吗?
  2. 如何获取外部ip?

最后,非常感谢您拯救了我的一天!

【问题讨论】:

    标签: docker kubernetes jupyterhub


    【解决方案1】:

    对于NodePort 服务,您不会得到EXTERNAL-IP。您不能使用 CLUSTER-IP 从 kubernetes 集群外部访问它,因为 CLUSTER-IP 用于从 kubernetes 集群内部访问它,通常是从另一个 pod。对于从 kubernetes 集群外部访问,您需要使用 NodeIP:NodePort where @ 987654326@ 是您的 Kubernetes 节点 IP 地址。

    【讨论】:

      猜你喜欢
      • 2020-09-18
      • 1970-01-01
      • 1970-01-01
      • 2020-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-19
      相关资源
      最近更新 更多