Hello Reed Wei,
Welcome to the Microsoft Q&A and thank you for posting your questions here and for detail information.
Problem
I understand that you are having issues with your Ingress not applied to expected controller.
Solution
Regarding your question to explain why it happen, after careful analysis I found out that the ingressClassName
is NOT correctly configured and the ingress controller associated with LB(A) is NOT properly set up to handle nginx-custom
, to route traffic to the intended load balancer.
To solve this issue, ensure to follow this procedures:
- Ensure that the ingress controller for LB(A) is correctly set up with the
ingressClassName: nginx-custom
.- LB(A) should be configured with the correct
--ingress-class=nginx-custom
argument. Using bash:kubectl describe deployment ingress-nginx-controller -n default
- Look for the arguments section and ensure it includes: args:
- /nginx-ingress-controller
- --ingress-class=nginx-custom
- Verify that the ingress controller for LB(A) is running and recognizing the
nginx-custom
class using bash:kubectl logs <nginx-ingress-controller-pod-name> -n default
- LB(A) should be configured with the correct
- Verify that the
IngressClass
resource is correctly defined and points to the appropriate controller.- Create an IngressClass resource if it doesn’t exist in YAML:
apiVersion: networking.k8s.io/v1 kind: IngressClass metadata: name: nginx-custom spec: controller: k8s.io/ingress-nginx
- Apply the resource using Bash:
kubectl apply -f ingressclass.yaml
- Check the details of the existing
IngressClass
to ensure it is correct using Bash.kubectl get ingressclass
kubectl describe ingressclass nginx-custom
- Create an IngressClass resource if it doesn’t exist in YAML:
- Ensure that the deployments for both ingress controllers are correctly configured with the appropriate ingress class names.
- Ensure that the ingress controller for LB(A) has the correct annotations and is linked to the
nginx-custom
ingress class using Bash:kubectl describe deployment ingress-nginx-controller -n default
- Verify that the ingress controller for LB(B) has a different ingress class name and does not interfere with LB(A):
kubectl describe deployment addon-http-application-routing-nginx-ingress -n kube-system
Ensure it has the following or similar in YAML:args:
- /nginx-ingress-controller
- --ingress-class=addon-http-application-routing
- Ensure that the ingress controller for LB(A) has the correct annotations and is linked to the
- Apply and test your configuration:
- Ensure the ingress resource is correctly configured with
ingressClassName: nginx-custom
.apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: default-ingress annotations: kubernetes.io/ingress.class: nginx-custom spec: ingressClassName: nginx-custom rules: - http: paths: - path: /xxx pathType: Prefix backend: service: name: xxx-service port: number: 8080
- Apply the ingress resource:
kubectl apply -f ingress-resource.yaml
- Verify that the service is accessible via LB(A).
curl http://172.179.18.172/xxx
- Ensure the ingress resource is correctly configured with
References
For more reading and detail steps kindly read use the following links:
Source: NGINX Ingress Controller Arguments. Accessed, 7/1/2024.
Source: IngressClass API. Accessed, 7/1/2024.
Source: Kubernetes Deployment. Accessed, 7/1/2024.
Source: Using Ingress. Accessed, 7/1/2024.
Accept Answer
I hope this is helpful! Do not hesitate to let me know if you have any other questions.
** Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful ** so that others in the community facing similar issues can easily find the solution.
Best Regards,
Sina Salam