根入口与路径入口冲突
Ingress on root colliding with ingress on path
我有两个容器 - 一个是 nginx 中的静态页面,第二个是 React 应用程序。
我想在 /
上提供静态页面并在 /app
上提供 React 应用程序
目前的问题是,当我输入 /
时,我在 /app
上进行了重定向
静态页面的 helm 摘录:
ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/app-root: /
paths:
- /
react 应用程序的 helm 摘录:
ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/app-root: app/
paths:
- /app
kubectl describe ingress
:
Name: app
Namespace: prod
Address:
Default backend: default-http-backend:80 (<none>)
Rules:
Host Path Backends
---- ---- --------
example.com
/app app:http (10.244.2.52:80)
Annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/app-root: app/
Name: static-page
Namespace: prod
Address:
Default backend: default-http-backend:80 (<none>)
Rules:
Host Path Backends
---- ---- --------
example.com
/ static-page:80 (10.244.2.40:80)
Annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/app-root: /
您可以尝试在没有 nginx.ingress.kubernetes.io/app-root:
注释的一个入口对象中使用多路径配置,它在类似情况下对我有用:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
name: example
spec:
rules:
- http:
paths:
- backend:
serviceName: static-page
servicePort: 80
path: /
- backend:
serviceName: app
servicePort: 80
path: /app
我有两个容器 - 一个是 nginx 中的静态页面,第二个是 React 应用程序。
我想在 /
上提供静态页面并在 /app
目前的问题是,当我输入 /
时,我在 /app
静态页面的 helm 摘录:
ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/app-root: /
paths:
- /
react 应用程序的 helm 摘录:
ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/app-root: app/
paths:
- /app
kubectl describe ingress
:
Name: app
Namespace: prod
Address:
Default backend: default-http-backend:80 (<none>)
Rules:
Host Path Backends
---- ---- --------
example.com
/app app:http (10.244.2.52:80)
Annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/app-root: app/
Name: static-page
Namespace: prod
Address:
Default backend: default-http-backend:80 (<none>)
Rules:
Host Path Backends
---- ---- --------
example.com
/ static-page:80 (10.244.2.40:80)
Annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/app-root: /
您可以尝试在没有 nginx.ingress.kubernetes.io/app-root:
注释的一个入口对象中使用多路径配置,它在类似情况下对我有用:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
name: example
spec:
rules:
- http:
paths:
- backend:
serviceName: static-page
servicePort: 80
path: /
- backend:
serviceName: app
servicePort: 80
path: /app