您好,登錄后才能下訂單哦!
需求如下:
域名 service
www.baidu.com/authorize saas-jcpt-saas-uc-authorize-core-tomcat-online
分析:
1.要到ingress,所以前面不能去掉authorize
2.需要在ingress上配置rewrite
配置
www.baidu.com和saas-jcpt-saas-uc-authorize-core-tomcat-online這兩個在不同的命名空間,所以需要在saas-jcpt-tomcat-online下創建一個新的ingress,配置如下:
apiVersion: extensions/v1beta1 kind: Ingress metadata: name: public-fe-n-saas-uc-node-online-ingress namespace: saas-jcpt-tomcat-online annotations: traefik.ingress.kubernetes.io/rewrite-target: / spec: rules: - host: www.baidu.com http: paths: - backend: serviceName: saas-jcpt-saas-uc-authorize-core-tomcat-online servicePort: 8080 path: /authorize status: loadBalancer: {}
注意一個小坑:
如下需求:
域名 service
www.abc.com/aaa/ saas-jcpt-saas-uc-authorize-core-tomcat-online/bbb/
我們習慣的寫法可能如下:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: public-fe-n-saas-uc-node-online-ingress
namespace: saas-jcpt-tomcat-online
annotations:
traefik.ingress.kubernetes.io/rewrite-target: /bbb/
spec:
rules:
- host: www.abc.com
http:
paths:
- backend:
serviceName: saas-jcpt-saas-uc-authorize-core-tomcat-online
servicePort: 8080
path: /aaa/
status:
loadBalancer: {}
這個時候我們訪問http://www.abc.com/aaa/xxx,我們發會現404,容器上抓包發現實際調用的URL為:saas-jcpt-saas-uc-authorize-core-tomcat-online/bbbxxx,中間的/沒有了。
同時把path及traefik.ingress.kubernetes.io/rewrite-target最后的/去掉,問題可解決:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: public-fe-n-saas-uc-node-online-ingress
namespace: saas-jcpt-tomcat-online
annotations:
traefik.ingress.kubernetes.io/rewrite-target: /bbb
spec:
rules:
- host: www.abc.com
http:
paths:
- backend:
serviceName: saas-jcpt-saas-uc-authorize-core-tomcat-online
servicePort: 8080
path: /aaa
status:
loadBalancer: {}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。