【问题标题】:K8s: Multiple nginx-ingress-controller ingress rules in GKEK8s:GKE 中的多个 nginx-ingress-controller 入口规则
【发布时间】:2019-04-03 12:03:56
【问题描述】:

我有一个适用于域 *.foo.com 的全部入口规则,然后我有一个适用于域 a.foo.com 的特定规则。根据文档,a.foo.com 的入口规则必须优先于带有通配符的规则(因为它比通配符更好匹配)。然而,这并没有发生。如何明确设置优先级?我做错了什么?

这是我的通用入口规则:

$ kubectl describe ing foo
Name:             foo
Namespace:        foo
Address:          x.x.x.x
Default backend:  default-http-backend:80 (x.x.x.x:8080)
TLS:
  foo.com terminates *.foo.com
Rules:
  Host             Path  Backends
  ----             ----  --------
  *.foo.com
                   /   foo:8888 (<none>)

这是特定于域的规则:

$ kubectl describe ing foo-a
Name:             foo-a
Namespace:        foo
Address:          x.x.x.x
Default backend:  default-http-backend:80 (x.x.x.x:8080)
TLS:
  foo.com terminates a.foo.com
Rules:
  Host                                Path  Backends
  ----                                ----  --------
  a.foo.com
                                      /hello   foo-a:8080 (<none>)

【问题讨论】:

    标签: nginx kubernetes nginx-ingress


    【解决方案1】:

    您需要将每个 nginx-ingress 控制器配置为具有不同的 ingress-class 名称。然后在你的入口定义中,你应该指定kubernetes.io/ingress.class: "my-ingress" 指向你想要用于那个特定入口的入口控制器。

    [nginx-ingress 文档]中包含设置详细信息。(https://kubernetes.github.io/ingress-nginx/user-guide/multiple-ingress/)

    希望这会有所帮助!

    【讨论】:

    • 是的,我知道这一点。但是,这会浪费资源。我目前对此的解决方案是使用 *.foo.com 作为默认 TLS 证书,而不是为 a.foo.com 指定任何 TLS 证书名称。
    猜你喜欢
    • 2020-08-05
    • 2019-01-15
    • 2020-01-15
    • 1970-01-01
    • 2019-02-24
    • 2019-04-30
    • 2019-07-29
    • 2019-09-30
    • 2020-10-16
    相关资源
    最近更新 更多