Mình đã gặp lỗi biên dưới khi apply ingress nginx configuration.
admission webhook "validate.nginx.ingress.kubernetes.io" denied the request: nginx.ingress.kubernetes.io/configuration-snippet annotation cannot be used. Snippet directives are disabled by the Ingress administrator
Ingress có config như sau:
và lỗi có liên quan đến nginx.ingress.kubernetes.io/configuration-snippet
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotations: cert-manager.io/issuer: hubble cert-manager.io/issuer-kind: Issuer nginx.ingress.kubernetes.io/auth-signin: https://$host/oauth2/start?rd=$escaped_request_uri nginx.ingress.kubernetes.io/auth-url: https://$host/oauth2/auth nginx.ingress.kubernetes.io/configuration-snippet: | proxy_set_header Origin ""; proxy_hide_header l5d-remote-ip; proxy_hide_header l5d-server-id; nginx.ingress.kubernetes.io/proxy-buffer-size: 8k nginx.ingress.kubernetes.io/proxy-buffering: "on" #nginx.ingress.kubernetes.io/upstream-vhost: $service_name.$namespace.svc.cluster.local:80 managedFields: name: ingress-hubble namespace: kube-system spec: ingressClassName: nginx rules: - host: hubble.nimtechnology.com http: paths: - backend: service: name: hubble-ui port: number: 80 path: / pathType: Prefix tls: - hosts: - hubble.nimtechnology.com secretName: tls-hubble-ingress
Vậy nginx.ingress.kubernetes.io/configuration-snippet dùng để làm gì:
is an annotation used in Kubernetes Ingress objects, particularly with the NGINX Ingress Controller. This annotation allows you to inject additional NGINX configuration into the server or location block generated for the Ingress. This can be used to customize the behavior of NGINX in handling requests for the service defined in the Ingress.
This snippet has the following effects:
proxy_set_header Origin "";
: This line sets theOrigin
header to an empty string. In a typical proxy setting, theOrigin
header indicates the origin of the request. By setting it to an empty string, this can modify cross-origin resource sharing (CORS) behavior, potentially bypassing checks that rely on theOrigin
header.proxy_hide_header l5d-remote-ip;
: This line instructs NGINX to remove thel5d-remote-ip
header from the response before sending it to the client. This header is typically set by Linkerd, a service mesh, to indicate the original IP address of the client. Hiding this header can be used for privacy reasons or to prevent the downstream client from seeing internal network details.proxy_hide_header l5d-server-id;
: Similar to the previous line, this instruction removes thel5d-server-id
header from the response. This header usually contains the identity of the Linkerd instance handling the request, and hiding it can again be for privacy or security reasons, preventing external users from gaining information about the internal service architecture.
Enable Snippet Configuration on Ingress Nginx.
Nếu bạn bắt buộc phải sài cái : nginx.ingress.kubernetes.io/configuration-snippet thì làm sao đây
Mình có tìm được 1 issue liên quan đến disable snippet là default:
https://github.com/kubernetes/ingress-nginx/issues/10543#issuecomment-1773483812

Đây là pull request về việc họ đã –> allow-snippet-annotations
– should be disabled by default – Disable user snippets per default #10393
Nếu bạn muốn enable thì bạn có thể thêm trong helm value: controller.allowSnippetAnnotations: true