K8S:错误 运行 负载均衡器同步例程

K8S: Error running load balancer syncing routine

正在尝试在 google 云上获取 ThingsBoard 运行。

我现在看到以下错误:

Error during sync: error running load balancer syncing routine: loadbalancer thingsboard-tb-ingress--013d7ab9087175d7 does not exist: CreateUrlMap: googleapi: Error 400: Invalid value for field 'resource': '{ "name": "k8s-um-thingsboard-tb-ingress--013d7ab9087175d7", "hostRule": [{ "host": ["*"], "...'. Invalid path pattern, invalid

kubectl describe ingress 给我以下信息:

Name:             tb-ingress
Namespace:        thingsboard
Address:
Default backend:  default-http-backend:80 (10.52.0.5:8080)
Rules:
  Host  Path  Backends
  ----  ----  --------
  *
        /api/v1/.*            tb-http-transport:http (<none>)
        /static/rulenode/.*   tb-node:http (<none>)
        /static/.*            tb-web-ui:http (<none>)
        /index.html.*         tb-web-ui:http (<none>)
        /                     tb-web-ui:http (<none>)
        /.*                   tb-node:http (<none>)
Annotations:
  kubectl.kubernetes.io/last-applied-configuration:  {"apiVersion":"extensions/v1beta1","kind":"Ingress","metadata":{"annotations":{"nginx.ingress.kubernetes.io/proxy-read-timeout":"3600","nginx.ingress.kubernetes.io/ssl-redirect":"false","nginx.ingress.kubernetes.io/use-regex":"true"},"name":"tb-ingress","namespace":"thingsboard"},"spec":{"rules":[{"http":{"paths":[{"backend":{"serviceName":"tb-http-transport","servicePort":"http"},"path":"/api/v1/.*"},{"backend":{"serviceName":"tb-node","servicePort":"http"},"path":"/static/rulenode/.*"},{"backend":{"serviceName":"tb-web-ui","servicePort":"http"},"path":"/static/.*"},{"backend":{"serviceName":"tb-web-ui","servicePort":"http"},"path":"/index.html.*"},{"backend":{"serviceName":"tb-web-ui","servicePort":"http"},"path":"/"},{"backend":{"serviceName":"tb-node","servicePort":"http"},"path":"/.*"}]}}]}}

  nginx.ingress.kubernetes.io/proxy-read-timeout:  3600
  nginx.ingress.kubernetes.io/ssl-redirect:        false
  nginx.ingress.kubernetes.io/use-regex:           true
Events:
  Type     Reason  Age               From                     Message
  ----     ------  ----              ----                     -------
  Warning  Sync    3m (x28 over 1h)  loadbalancer-controller  Error during sync: error running load balancer syncing routine: loadbalancer thingsboard-tb-ingress--013d7ab9087175d7 does not exist: CreateUrlMap: googleapi: Error 400: Invalid value for field 'resource': '{  "name": "k8s-um-thingsboard-tb-ingress--013d7ab9087175d7",  "hostRule": [{    "host": ["*"],    "...'. Invalid path pattern, invalid

我在这里错过了什么?

我忘记指定 kubernetes.io/ingress.class: "nginx" 注释。如果您未指定任何 kubernetes。io/ingress.class - GKE 将考虑使用其自己的入口,该入口不支持正则表达式并给出上述错误。

使用默认的gke loadbalancer和使用错误的路径表达式时出现错误。 从文档中: https://cloud.google.com/kubernetes-engine/docs/how-to/load-balance-ingress

  • Ingress 的路径字段唯一支持的通配符是 * 字符。 * 字符必须跟在正斜杠 (/) 之后,并且必须是模式中的最后一个字符。例如,/、/foo/ 和 /foo/bar/* 是有效模式,但是 、/foo/bar 和/foo/*/bar 不是。
  • 更具体的模式优先于不太具体的模式。如果你同时拥有 /foo/* 和 /foo/bar/,那么 /foo/bar/bat 被用来匹配 /foo/bar/。有关路径限制和模式匹配的详细信息,请参阅 URL 地图文档。

您本身不需要设置主机条目,这个错误实际上非常混乱和不清楚。

来自同一页面,这是一个有效的配置:

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: my-ingress
  annotations:
    # If the class annotation is not specified it defaults to "gce".
    kubernetes.io/ingress.class: "gce"
spec:
  rules:
  - http:
      paths:
      - path: /*
        backend:
          serviceName: hello-world
          servicePort: 60000
      - path: /kube
        backend:
          serviceName: hello-kubernetes
          servicePort: 80

要使用正则表达式,您需要使用另一个入口控制器,例如 nginx 或 haproxy:

https://kubernetes.github.io/ingress-nginx/deploy/#gce-gke

https://github.com/haproxytech/kubernetes-ingress#readme