Search code examples
kuberneteskubernetes-ingressazure-aksnginx-ingress

Using ingress in multi namespace cluster AKS


I have a cluster, I created namespaces for different teams. Then, I tried to apply an ingress to one namespace with this command kubectl apply -f ing2_dev_plat.yaml -n namespace_name.

After, this error was thrown. How can I properly configure the work of ingress controller in several namespaces?

Nginx ingress contoller service is in default namespace.

Error from server (BadRequest): error when creating "ing2_dev_plat.yaml": admission webhook "validate.nginx.ingress.kubernetes.io" denied the request:
-------------------------------------------------------------------------------
Error: exit status 1
2022/02/11 09:17:49 [warn] 3250#3250: the "http2_max_field_size" directive is obsolete, use the "large_client_header_buffers" directive instead in /tmp/nginx-cfg1414424955:143
nginx: [warn] the "http2_max_field_size" directive is obsolete, use the "large_client_header_buffers" directive instead in /tmp/nginx-cfg1414424955:143
2022/02/11 09:17:49 [warn] 3250#3250: the "http2_max_header_size" directive is obsolete, use the "large_client_header_buffers" directive instead in /tmp/nginx-cfg1414424955:144
nginx: [warn] the "http2_max_header_size" directive is obsolete, use the "large_client_header_buffers" directive instead in /tmp/nginx-cfg1414424955:144
2022/02/11 09:17:49 [warn] 3250#3250: the "http2_max_requests" directive is obsolete, use the "keepalive_requests" directive instead in /tmp/nginx-cfg1414424955:145
nginx: [warn] the "http2_max_requests" directive is obsolete, use the "keepalive_requests" directive instead in /tmp/nginx-cfg1414424955:145
2022/02/11 09:17:49 [emerg] 3250#3250: duplicate location "/" in /tmp/nginx-cfg1414424955:1045
nginx: [emerg] duplicate location "/" in /tmp/nginx-cfg1414424955:1045
nginx: configuration file /tmp/nginx-cfg1414424955 test failed

enter image description here


Solution

  • As I said in my comment under the question:

    nginx: [emerg] duplicate location "/" in /tmp/nginx-cfg1414424955:1045
    

    may indicate you have the same location defined twice.

    If you have any other Ingress resources with path: /, you have to edit those accordingly.

    You can get all Ingress resources with their paths with

    kubectl get ingress -A -o=jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.rules[*].http.paths[*].path}{"\n"}{end}'