簡體   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