kubernetes config_error ai_generated true

错误:Ingress.networking.k8s.io "my-ingress" 无效:metadata.annotations:无效值:"nginx.ingress.kubernetes.io/rewrite-target":必须是 Ingress 控制器的有效注解

Error: Ingress.networking.k8s.io "my-ingress" is invalid: metadata.annotations: Invalid value: "nginx.ingress.kubernetes.io/rewrite-target": must be a valid annotation for the ingress controller

ID: kubernetes/ingress-annotation-invalid

其他格式: JSON · Markdown 中文 · English
90%修复率
86%置信度
1证据数
2024-02-14首次发现

版本兼容性

版本状态引入弃用备注
kubernetes 1.27 active
nginx-ingress 1.8 active
nginx-ingress 1.9 active

根因分析

Ingress 资源中使用的注解不被配置的 Ingress 控制器(例如 Nginx Ingress Controller)识别或支持。

English

An annotation used in the Ingress resource is not recognized or supported by the configured ingress controller (e.g., Nginx Ingress Controller).

generic

官方文档

https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/

解决方案

  1. 在 https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/ 查看 Nginx Ingress Controller 的官方注解列表。例如,将 `nginx.ingress.kubernetes.io/rewrite-target` 更正为正确的拼写,或使用支持的注解如 `nginx.ingress.kubernetes.io/ssl-redirect: "true"`。
  2. 编辑 Ingress YAML 并删除无效的注解行。然后重新应用:`kubectl apply -f ingress.yaml`。

无效尝试

常见但无效的做法:

  1. 95% 失败

    Additional invalid annotations will only cause more validation errors, not fix the original one.

  2. 90% 失败

    The annotation is validated at resource creation time by the API server, not by the controller at runtime.

  3. 70% 失败

    Guessing annotation names often leads to typos or unsupported keys, causing the same error.