Kubernetes 正在提供垃圾外部 ip

Kubernetes is giving junk external ip

Kubernetes 正在提供垃圾外部 ip,检查以下命令的输出:

$ kubectl get svc frontend -n web-console

NAME       TYPE           CLUSTER-IP     EXTERNAL-IP        PORT(S)        AGE
frontend   LoadBalancer   100.68.90.01   a55ea503bbuddd...   80:31161/TCP   5d

请帮我理解这个外部 IP 是什么意思

根据这个:https://kubernetes.io/docs/concepts/services-networking/service/#external-ips

Traffic that ingresses into the cluster with the external IP (as destination IP), on the Service port, will be routed to one of the Service endpoints. externalIPs are not managed by Kubernetes and are the responsibility of the cluster administrator.

您似乎选择了 LoadBalancer 类型,您的云提供商为您提供了一个负载均衡器,而 externalip 是该负载均衡器的 dns 名称。

允许您公开应用程序以从集群外部访问的选项是:

  • LoadBalancer 类型的 Kubernetes 服务
  • “NodePort”类型的 Kubernetes 服务 + Ingress

Kubernetes 中的服务是定义一组逻辑集 Pods 和访问策略的抽象,它可以通过在服务规范中指定类型(ClusterIP、NodePort、LoadBalancer)以不同方式公开。 LoadBalancer 类型是最简单的方法。

创建服务后,它有一个外部 IP 地址,如您的输出所示:

$ kubectl get svc frontend -n web-console

NAME       TYPE           CLUSTER-IP     EXTERNAL-IP        PORT(S)        AGE
frontend   LoadBalancer   100.68.90.01   a55ea503bbuddd...   80:31161/TCP   5d

现在,可以从集群外部访问服务 'frontend',而无需像 Ingress 这样的额外组件。

要测试外部 IP 运行 从您的计算机执行此 curl 命令:

$ curl http://<external-ip>:<port>

其中 是您服务的外部 IP 地址,是您服务描述中端口的值。

ExternalIP 提供了从集群外部访问服务的可能性(ExternalIP 是一个端点)。仍然可以使用其 service.namespace DNS 名称在集群内部访问具有外部 IP 的 ClusterIP 类型服务,但现在也可以从其外部端点访问它。