Kubernetes:为什么我的 NodePort 无法获取外部 ip?

iha*_*des 2 docker kubernetes jupyterhub

环境信息:

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
Run Code Online (Sandbox Code Playgroud)

最近,我尝试在 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
Run Code Online (Sandbox Code Playgroud)

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

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

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
Run Code Online (Sandbox Code Playgroud)

和它的服务是这样的:

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
Run Code Online (Sandbox Code Playgroud)

似乎工作得很好,对吧?(我猜的。)但事实是我无法使用 ip10.10.97.11访问 jupyter 主页,而且我也没有获得任何外部 ip。

所以,我的问题是:

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

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

Arg*_*dhu 5

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