代码之家  ›  专栏  ›  技术社区  ›  kentor

为什么谷歌云在使用clusterip时显示错误?

  •  12
  • kentor  · 技术社区  · 8 年前

    在我的gCloud控制台中,对于我定义的入口,它显示以下错误:

    < Buff行情>

    同步过程中出错:评估入口规范服务时出错 “monitoring/kube prometheus”是“clusterip”类型,应为“nodeport” 或“负载平衡器”

    < /块引用>

    我使用traefik作为反向代理(而不是nginx),因此我使用clusterip定义一个入口。据我所知,所有流量都是通过Traefik服务代理的(它定义了一个负载均衡器入口),因此我的所有其他入口实际上都应该有一个clusterip而不是nodeport或loadballancer?

    问题:

    那么,为什么google cloud会警告我它需要一个nodeport或loadbalancer呢?

    .

    我使用traefik作为反向代理(而不是nginx),因此我使用clusterip定义一个入口。据我所知,所有流量都是通过Traefik服务代理的(它定义了一个负载均衡器入口),因此我的所有其他入口实际上都应该有一个clusterip而不是nodeport或loadballancer?

    问题:

    那么,为什么google cloud会警告我它需要一个nodeport或loadbalancer呢?

    2 回复  |  直到 7 年前
        1
  •  6
  •   aayore    8 年前

    我不知道为什么会发生这个错误,因为(在我看来)它是一个有效的配置。但要清除错误,可以将服务切换到一个命名的节点报表。然后切换您的入口以使用端口名而不是数字。例如:

    服务:

    apiVersion: v1
    kind: Service
    metadata:
      name: testapp
    spec:
      ports:
      - name: testapp-http # ADD THIS
        port: 80
        protocol: TCP
        targetPort: 80
      selector:
        app: testapp
      type: NodePort
    

    进入:

    apiVersion: extensions/v1beta1
    kind: Ingress
    metadata:
      name: testapp
    spec:
      rules:
      - host: hostname.goes.here
        http:
          paths:
          - backend:
              serviceName: testapp
              # USE THE PORT NAME FROM THE SERVICE INSTEAD OF THE PORT NUMBER
              servicePort: testapp-http
            path: /
    

    更新:

    这是我从谷歌收到的解释。

    因为服务在默认情况下是clusterip[1],所以这类服务应该可以从集群内部访问。当使用kube代理时,可以从外部访问它,而不是通过入口直接访问它。

    作为建议,我个人认为本文[2]有助于理解这些服务类型之间的差异。

    〔1〕 https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types

    〔2〕 https://medium.com/google-cloud/kubernetes-nodeport-vs-loadbalancer-vs-ingress-when-should-i-use-what-922f010849e0

        2
  •  2
  •   petrus-jvrensburg    7 年前

    谢谢@aayore。在我的例子中,我必须显式地指定一个入口类,这样谷歌云就不会干扰。nginx入口似乎很满意 ClusterIp 服务。

    metadata:
      name: foo
      annotations:
        kubernetes.io/ingress.class: "nginx"