Reputation: 972
I try to create a second ingress for my azure Kubernetes cluster (AKS). One for company internal use and one for customers.
The first controller is built by the following script:
https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.27.0/deploy/static/mandatory.yaml
And the service:
The official tutorial from Nginx (https://kubernetes.github.io/ingress-nginx/user-guide/multiple-ingress/) says that I need to use the --ingress-class flag to separate the two controllers. And when both controllers are created, I need to reference each resource which controller is used by ingress.class annotation.
That makes sense because I can create two different ingresses with routing specifications. But do I also need to reference the controller in the Nginx-service?
I edit the mandatory.yaml on my machine and applied it by a local YAML file. So I passed the --ingress-class flag to the arguments of the controller (started on mandatory.yaml line 218):
containers:
- name: nginx-ingress-controller
image: quay.io/kubernetes-ingress-controller/nginx-ingress-controller:master
args:
- /nginx-ingress-controller
- --configmap=$(POD_NAMESPACE)/nginx-configuration
- --tcp-services-configmap=$(POD_NAMESPACE)/tcp-services
- --udp-services-configmap=$(POD_NAMESPACE)/udp-services
- --publish-service=$(POD_NAMESPACE)/ingress-nginx
- --annotations-prefix=nginx.ingress.kubernetes.io
- --ingress-class=nginx-external
When I redeploy it the mandatory.yaml with --ingress-class=nginx-internal, the existing controller will be reconfigured, but no second controller will be deployed. What I'm doing wrong?
Upvotes: 1
Views: 1850
Reputation: 44549
For the nginx service you need to provide selector and labels such that it selects your second nginx ingress controller pods.
You just changed existing deployment with name nginx-ingress-controller
of the existing ingress controller. That's the reason why it reconfigured your existing ingress controller.You need to create new deployment yaml with a different name and add --ingress-class
flag in the new deployment.
I would suggest to create two different namespaces and two different set of yamls for ingress controller 1 and ingress controller 2 and change the name, namespace, labels and selectors in those yamls.
Upvotes: 1