I have a problem with ingress, where I have multiple environments in my single kubernetes clustering... Now the problem is that if I have a single environment it works perfectly fine with below configuration, As soon as I deploy second envioronment and hit the ip of second environment, it is started pointing to first environment even though service names are different
my first ingress
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress
namespace: default
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/add-base-url: "true"
spec:
rules:
- host: test.com
http:
paths:
- path: "/"
backend:
serviceName: servicetest-1
servicePort: 1000
- path: "/test"
backend:
serviceName: servicetest-1
servicePort: 2000
my second ingress-resources:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress
namespace: default
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/add-base-url: "true"
spec:
rules:
- host: test.com
http:
paths:
- path: "/"
backend:
serviceName: servicetest-2
servicePort: 1000
- path: "/test"
backend:
serviceName: servicetest-2
servicePort: 2000
The catch is if I delete my ingress resources in first environment, second environment starts working fine.
Another point both of my ingress resources are deployed in the same namespace
is that something I need to do in annotations or re-directions
Any help is appreciated
Both Ingress
have the same name
and are in the same namespace
. As the only difference between both ingress are spec.rules.http.paths.backend.serviceName
and Name and Namespace stayed the same, Kubernetes overwritte previous config instead of create new resource.
ingress.extensions/test-ingress configured
You should change name of ingress
resource.