繁体   English   中英

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

[英]K8S: Error running load balancer syncing routine

试图让ThingsBoard在谷歌云上运行。

我现在看到以下错误:

同步期间出错:运行负载均衡器同步例程时出错:负载均衡器 thingsboard-tb-ingress--013d7ab9087175d7 不存在:CreateUrlMap:googleapi:错误 400:字段“资源”的值无效:'{“名称”:“k8s-um- thingsboard-tb-ingress--013d7ab9087175d7", "hostRule": [{ "host": ["*"], "...'。路径模式无效,无效

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 负载均衡器并使用错误的路径表达式时会出现错误。 来自文档: 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

暂无
暂无

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

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