Member-only story
Deploying Multiple Ingress Controllers in a Kubernetes Cluster
If you’re running multiple ingress controllers in a single Kubernetes cluster, you need to specify the annotation kubernetes.io/ingress.class: "controller-name"
in all ingresses that you would like the ingress-nginx controller to claim.
If you only need to accessing service 1 from a particular Nginx Controller, you can define that when deploying the ingress resource specify to service 1.
To achieve above, configuration changes would be as follows,
Ingress- resource :
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: hello-world
annotations:
kubernetes.io/ingress.class: "nginx-internal"
spec:
tls:
- secretName: tls-secret
rules:
- http:
paths:
- backend:
serviceName: hello-world-svc
servicePort: 8080
on the above, you can see the ingress class is defined as “nginx-internal”. So you need to define one of your Nginx controllers to have the class name as “nginx-internal” to route the traffic.
Ingress-controller:
spec:
template:
spec:
containers:
- name: nginx-ingress-internal-controller
args:
- /nginx-ingress-controller
- '--election-id=ingress-controller-leader-internal'
- '--ingress-class=nginx-internal'
- '--configmap=ingress/nginx-ingress-internal-controller'
Here you need to set the ‘ingress-class’ argument name as the same as in ingress-resource. In my case, it is “nginx-internal”.
This way you can even have an ingress controller per namespace as well.
Hope this helps !!!