在多命名空间集群 AKS 中使用入口

Using ingress in multi namespace cluster AKS

我有一个集群,我为不同的团队创建了命名空间。然后,我尝试使用此命令 kubectl apply -f ing2_dev_plat.yaml -n namespace_name.

将入口应用到一个命名空间

之后,抛出了这个错误。如何在多个命名空间中正确配置入口控制器的工作?

Nginx 入口控制器服务在默认命名空间中。

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

正如我在问题下的评论中所说:

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

可能表示您对同一位置定义了两次。

如果您有任何其他 Ingress 资源 path: /,您必须相应地编辑它们。

您可以通过

获取所有 Ingress 资源及其路径
kubectl get ingress -A -o=jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.rules[*].http.paths[*].path}{"\n"}{end}'