我有两个容器-一个是nginx中的静态页面,另一个是react应用程序。
我想在/
上投放静态页面,并在/app
上投放应用
当前的问题是,当我输入/
时,我已重定向到/app
静态页面摘录:
ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/app-root: /
paths:
- /
React应用程序的摘录:
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: /
答案 0 :(得分:1)
您可以尝试在一个没有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