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

时间:2019-04-26 07:59:52

标签: kubernetes google-cloud-platform thingsboard

试图让ThingsBoard在Google云上运行。

我现在看到以下错误:

  

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

kubectl描述入口给了我以下内容:

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

我在这里想念什么?

3 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

根据入口规范,主机部分只能包含FQDN。通配符不是FQDN,因此会引起问题。

"hostRule": [{    "host": ["*"],    "...'. Invalid path pattern, invalid

答案 2 :(得分:0)

使用默认的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 Maps文档。

您本身无需设置主机条目,此错误实际上非常令人困惑且不清楚。

在同一页面上,这是有效的配置:

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