我无法正确指定Ingress
资源,因此应用程序的Location
标头将被重写为在前面包含原始URL路径。
使用配置:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-fanout-namespace-xyz
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
namespace: namespace-xyz
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /analytics/spark/master(/|$)(.*)
pathType: Prefix
backend:
service:
name: spark-master-svc
port:
number: 80
- path: /analytics/jupyter/lab(/|$)(.*)
pathType: Prefix
backend:
service:
name: jupyter-proxy-public
port:
number: 80
请求URL:https://xx-xx.yyy.elb.amazonaws.com/analytics/jupyter/lab/
响应标头:location: /hub/
重定向到https://xx-xx.yyy.elb.amazonaws.com/hub/,404秒。
这应该为location: /analytics/jupyter/lab/
发送重定向
这似乎就是add-base-url
的用途,现在已被弃用什么是合适的替代品?如何有效地使Location
变成/analytics/jupyter/lab/hub/
如果我完全删除rewrite-target
,那么http://xx-xx.yyy.elb.amazonaws.com/analytics/jupyter/lab/根本不重定向,它只有404。
信息:
NGINX入口控制器版本:
-------------------------------------------------------------------------------
NGINX Ingress controller
Release: v1.0.5
Build: 7ce96cbcf668f94a0d1ee0a674e96002948bff6f
Repository: https://github.com/kubernetes/ingress-nginx
nginx version: nginx/1.19.9
-------------------------------------------------------------------------------
Kubernetes版本(使用kubectl version
(:
Client Version: version.Info{Major:"1", Minor:"21+", GitVersion:"v1.21.2-13+d2965f0db10712", GitCommit:"d2965f0db1071203c6f5bc662c2827c71fc8b20d", GitTreeState:"clean", BuildDate:"2021-06-26T01:02:11Z", GoVersion:"go1.16.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"21+", GitVersion:"v1.21.2-eks-0389ca3", GitCommit:"8a4e27b9d88142bbdd21b997b532eb6d493df6d2", GitTreeState:"clean", BuildDate:"2021-07-31T01:34:46Z", GoVersion:"go1.16.5", Compiler:"gc", Platform:"linux/amd64"}
环境:
- AWS EKS
- 亚马逊Linux 2
ingress nginx控制器是通过ArgoCD/Helm安装的,版本信息如上所示,没有覆盖任何值。
$ kubectl describe ingressclasses
Name: nginx
Labels: app.kubernetes.io/component=controller
app.kubernetes.io/instance=ingress-controller
app.kubernetes.io/managed-by=Helm
app.kubernetes.io/name=ingress-nginx
app.kubernetes.io/version=1.0.5
helm.sh/chart=ingress-nginx-4.0.9
Annotations: <none>
Controller: k8s.io/ingress-nginx
Events: <none>
jupyter-proxy
需要为该服务背后的工作负载设置其base_url。现在,它不知道它是从子路径提供服务的,所以当它发送重定向时,它会像从根url提供服务一样发送。
快速测试表明
helm install my-jupyterhub jupyterhub/jupyterhub -n jupyterhub
--create-namespace
--set hub.baseUrl="/analytics/jupyter/lab"
--set ingress.enabled=true
--set ingress.pathType="ImplementationSpecific"
--set proxy.service.type=NodePort
--set ingress.annotations.'kubernetes.io/ingress.class'=nginx
用Ingress
为我部署了jupyter hub
,我可以通过<X.X.X.X>/analytics/jupyter/lab/
访问它