For testing purposes, I deploy two versions of my application on the same machine. On production, only one application instance runs in one cloud Kubernetes cluster and uses the ingress-nginx controller to expose its API.
I use kind to run a Kubernetes cluster locally and deploy the application versions into two different namespaces. I configure the ingress controller according to the kind and ingress-nginx Multiple controllers documentation. The first instance of my app works as expected, but when I deploy the second one, the controller pod fails to start with the following message:
0/6 nodes are available: 1 node(s) didn't have free ports for the requested pod ports, 5 node(s) didn't match Pod's node affinity/selector
As far as I understand, two ingress controller pods are scheduled on the same node and cannot share the same port. Please advise how to proceed further. Should the second controller pod be scheduled to a different node? As kind maps node ports to the host machine, is it possible to map the same ports of multiple nodes to the host machine?
2
Answers
Not sure if this will satisfy your use-case, but you can scope the nginx ingress controller to a namespace:
https://github.com/kubernetes/ingress-nginx/blob/main/charts/ingress-nginx/values.yaml#L150
This way you could have multiple nginx controllers in different namespaces and they wouldn’t conflict. Looks like you can also have them watch specific namespaces via selectors not just their own.
I was facing the same issue with installing ingress with my kind cluster. adding a label to my control plane node soled this issue.
You may try:
kubectl label nodes <name of your control plane node> ingress-ready=true