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

- **ID:** `kubernetes/ingress-annotation-invalid`
- **领域:** kubernetes
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

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

## 版本兼容性

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

## 解决方案

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`。
   ```

## 无效尝试

- **** — Additional invalid annotations will only cause more validation errors, not fix the original one. (95% 失败率)
- **** — The annotation is validated at resource creation time by the API server, not by the controller at runtime. (90% 失败率)
- **** — Guessing annotation names often leads to typos or unsupported keys, causing the same error. (70% 失败率)
