[英]Nginx Ingress Looking for Service in all Custom Namespaces
I have three namespaces dev, test and staging. 我有三个名称空间dev,test和staging。 test and staging have no pods in them.
测试和暂存中没有豆荚。 In dev I have nginx, ingress and a frontend service.
在开发人员中,我有nginx,入口和前端服务。 For all requests to the nginx it's forwarded to the frontend service.
对于所有对nginx的请求,它都转发到前端服务。
But the issue is nginx in dev trying to find frontend service in test and staging namespaces also. 但是问题出在开发人员试图在测试和暂存名称空间中找到前端服务的nginx中。 It's doing round robin between the 3 namespaces.
它在3个名称空间之间进行循环。 So sometimes the page is loading and sometimes it's 503 error.
因此,有时页面正在加载,有时是503错误。
Here is the ingress: 这是入口:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: frontend-ingress
namespace: dev
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
ingress.kubernetes.io/ssl-redirect: "false"
spec:
rules:
- http:
paths:
- path: /
backend:
serviceName: frontend
servicePort: 80
And here is the log of nginx: 这是nginx的日志:
I0327 07:54:50.867120 1 command.go:76] change in configuration detected. Reloading...
W0327 07:54:50.867339 1 controller.go:841] service test/frontend does not have any active endpoints
W0327 07:54:50.867370 1 controller.go:841] service staging/frontend does not have any active endpoints
W0327 07:54:50.868198 1 controller.go:777] upstream test-frontend-80 does not have any active endpoints. Using default backend
W0327 07:54:50.868219 1 controller.go:777] upstream staging-frontend-80 does not have any active endpoints. Using default backend
Specify --force-namespace-isolation=true
argument when deploying nginx pod. 在部署Nginx Pod时指定
--force-namespace-isolation=true
参数。 And update image to quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.12.0
并将图像更新到
quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.12.0
I'd like to elaborate on @Narayan-Prusty's answer. 我想详细说明@ Narayan-Prusty的答案。
I had to add --force-namespace-isolation=true
and set image to quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.12.0
but also had to add --watch-namespace=$(POD_NAMESPACE)
. 我必须添加
--force-namespace-isolation=true
并将图像设置为quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.12.0
,还必须添加--watch-namespace=$(POD_NAMESPACE)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.