简体   繁体   English

Ingress 是否与 ClusterIP 服务一起使用?

[英]Is Ingress working with ClusterIP services?

I've setup some services and ingresses to try out the SSL termination.我已经设置了一些服务和入口来尝试 SSL 终止。 I had no problem at all with LoadBalancer and NodePort services as backend but it's not working at all with ClusterIP service.我对LoadBalancerNodePort服务作为后端完全没有问题,但它根本不适用于ClusterIP服务。

Although the Ingress' backend is described as healthy, I get an HTTP error that do not come from my application.尽管 Ingress 的后端被描述为健康,但我收到了一个并非来自我的应用程序的 HTTP 错误。

$ kubectl describe ing nginx-cluster-ssl-ingress
Name:           nginx-cluster-ssl-ingress
Namespace:      default
Address:        X.X.X.X
Default backend:    nginx-cluster-svc:80 (...)
TLS:
  ssl-certificate terminates
Rules:
  Host  Path    Backends
  ----  ----    --------
Annotations:
  https-target-proxy:       k8s-tps-default-nginx-cluster-ssl-ingress
  static-ip:            k8s-fw-default-nginx-cluster-ssl-ingress
  target-proxy:         k8s-tp-default-nginx-cluster-ssl-ingress
  url-map:          k8s-um-default-nginx-cluster-ssl-ingress
  backends:         {"k8s-be-30825":"HEALTHY"}
  forwarding-rule:      k8s-fw-default-nginx-cluster-ssl-ingress
  https-forwarding-rule:    k8s-fws-default-nginx-cluster-ssl-ingress
Events:
  FirstSeen LastSeen    Count   From                SubobjectPath   Type        Reason  Message
  --------- --------    -----   ----                -------------   --------    ------  -------
  28m       28m     1   {loadbalancer-controller }          Normal      ADD default/nginx-cluster-ssl-ingress
  27m       27m     1   {loadbalancer-controller }          Normal      CREATE  ip: X.X.X.X

The HTTP error is the following: HTTP 错误如下:

$ curl http://X.X.X.X/
default backend - 404%

My question is quite simple: is it supposed to work with ClusterIP services?我的问题很简单:它是否应该与 ClusterIP 服务一起使用? If it is supposed to as more or less written in the documentation, where should I have a look to resolve that issue?如果应该或多或少地写在文档中,我应该在哪里查看解决该问题?

Thank you!谢谢!

The native GKE Ingress controller do not support ClusterIP , only NodePort is working. 本机 GKE Ingress 控制器不支持ClusterIP ,只有NodePort正在工作。

Non-native Ingress controllers such as the nginx one do work with ClusterIP services.非本地 Ingress 控制器(例如 nginx)与ClusterIP服务一起工作。

Nginx ingress controller on GKE works with ClusterIp. GKE 上的Nginx 入口控制器与 ClusterIp 配合使用。 But the native GKE ingress controller does not as mentioned by @samuel-roze但是原生 GKE 入口控制器不像@samuel-roze 提到的那样

kubernetes.io/ingress.class: nginx kubernetes.io/ingress.class: nginx

If you are using GKE cluster and you use container-native load balancing (which is enabled by adding the cloud.google.com/neg: '{"ingress": true}' annotation in your ClusterIP services), then your GKE/GCE ingress can talk directly to the ClusterIP service, without needing it to be NodePort service.如果您使用GKE集群并且使用容器原生负载平衡(通过在 ClusterIP 服务中添加cloud.google.com/neg: '{"ingress": true}'注释启用),那么您的 GKE/GCE ingress 可以直接与ClusterIP服务对话,而不需要它是NodePort服务。

Reference: https://cloud.google.com/kubernetes-engine/docs/concepts/ingress#:~:text=unless%20you%27re%20using%20container%20native%20load%20balancing参考: https : //cloud.google.com/kubernetes-engine/docs/concepts/ingress# :~: text=unless%20you%27re%20using%20container%20native%20load%20balancing


GKE auto-adds the cloud.google.com/neg: '{"ingress": true}' annotation if a set of conditions are true.如果一组条件为真,GKE 会自动添加cloud.google.com/neg: '{"ingress": true}'注释。 Then you don't need to add this annotation manually to get container-native load balancing.那么你就不需要手动添加这个注解来获得容器原生的负载均衡了。 Otherwise, you will need to add this annotation to get container-native load-balancing;否则,您将需要添加此注释以获得容器原生负载均衡; which then enables your ingress to talk directly to the ClusterIP service.然后使您的入口能够直接与 ClusterIP 服务对话。

Reference: https://cloud.google.com/kubernetes-engine/docs/concepts/ingress#:~:text=In%20these%20conditions%2C%20Services%20will%20be%20annotated%20automatically参考: https : //cloud.google.com/kubernetes-engine/docs/concepts/ingress# :~: text=In%20these%20conditions%2C%20Services%20will%20be%20annotated%20automatically

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM