我是Ingress
的新手。我遵循offical site来构建Ingress
的简单扇出,并为同一自定义主机提供了多个路径。但是,它返回404。我无法弄清楚我的配置有什么问题。
我已在minikube中启用了入口并将<minikube ip> localhost-log.com
添加到/etc/hosts
这是我的一些配置YAML:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: kibana
spec:
selector:
matchLabels:
run: kibana
template:
metadata:
labels:
run: kibana
spec:
containers:
- name: kibana
image: docker.elastic.co/kibana/kibana:6.5.4
env:
- name: ELASTICSEARCH_URL
value: http://elasticsearch:9200
- name: XPACK_SECURITY_ENABLED
value: "true"
ports:
- containerPort: 5601
name: http
protocol: TCP
apiVersion: v1
kind: Service
metadata:
name: kibana
labels:
service: kibana
spec:
type: NodePort
selector:
run: kibana
ports:
- port: 80
targetPort: 5601
nodePort: 32561
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-test
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: localhost-log.com
http:
paths:
- path: /logger
backend:
serviceName: logger-svc
servicePort: 80
- path: /kibana
backend:
serviceName: kibana
servicePort: 80
如果使用kibana
查询kubectl port-forward
服务,则可以访问kibana网站。
port forward -> <minikube ip>:nodePort -> success
但是,如果我使用入口http://localhost-log.com/kibana
,而不是直接查询服务,它将失败并返回默认后端404。
入口的详细输出:kubectl describe ingress ingress-test -n=logging
Name: ingress-test
Namespace: logging
Address: 10.0.2.15
Default backend: default-http-backend:80 (172.17.0.9:8080)
Rules:
Host Path Backends
---- ---- --------
localhost-log.com
/logger logger-svc:80 (172.17.0.4:30080)
/kibana kibana:80 (172.17.0.7:5601)
Annotations:
kubectl.kubernetes.io/last-applied-configuration: {
"apiVersion": "extensions/v1beta1",
"kind": "Ingress",
"metadata": {
"annotations": {
"nginx.ingress.kubernetes.io/rewrite-target": "/"
},
"name": "ingress-test",
"namespace": "logging"
},
"spec": {
"rules": [
{
"host": "localhost-log.com",
"http": {
"paths": [
{
"backend": {
"serviceName": "logger-svc",
"servicePort": 80
},
"path": "/logger"
},
{
"backend": {
"serviceName": "kibana",
"servicePort": 80
},
"path": "/kibana"
}
]
}
}
]
}
}
我想要的或根据我的理解,我想要http://localhost-log.com/kibana
=> <kibana>:80
,但这似乎是不正确的。
它重定向到http://localhost-log.com/app/kibana
,得到404。
还是我误解了重写规则的概念,我需要帮助。
如果我将servicePort更改为80,则/logger
的路径有效,但是/kibana
仍返回default backend - 404