簡體   English   中英

kubernetes 上的 nginx 入口 url 路由到主機

[英]nginx ingress on kubernetes url routing to host

我的規則應該如何:如果要支持到服務的動態 url 映射

/a should map to service service-a
/b should map to service service-b
/cccc should map to service service-cccc

注意:服務可以動態添加

因此在說 10 分鍾之后。 我們現在有

/dddd should map to service service-dddd

基本上,您不斷將新路徑附加到 $.spec.rules[x].http.paths,其中 x 是您打算在其上添加路徑的主機的索引。

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: my-ingress
  namespace: my-namespace
  annotations:
    kubernetes.io/ingress.class: "nginx"
    # and other annotations you need..
  #labels:
     # if you need labels
spec:
  rules:
  - host: "your.hostname"
    http:
      paths:
      - path: /a
        backend:
          serviceName: service-a
          servicePort: 443 # say your service runs on 443
      - path: /b
        backend:
          serviceName: service-b
          servicePort: 443 # say your service runs on 443
      - path: /cccc
        backend:
          serviceName: service-cccc
          servicePort: 443 # say your service runs on 443

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM