# Pod "my-pod" 因资源配额被驱逐：Pod 已被驱逐，因为其资源使用量超过了命名空间的配额

- **ID:** `policy/kubernetes-pod-eviction-resource-quota`
- **领域:** policy
- **类别:** resource_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

Kubernetes ResourceQuota 对每个命名空间的总 CPU/内存实施限制；当累计使用量达到配额时，超过其请求/限制的 Pod 会触发驱逐。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Kubernetes v1.28 | active | — | — |
| Kubernetes v1.29 | active | — | — |
| kubelet v1.28.3 | active | — | — |

## 解决方案

1. ```
   检查当前命名空间配额使用情况：kubectl describe quota -n <namespace>。然后减少 Pod 资源请求/限制以适配可用配额，例如在部署 YAML 中设置 resources.requests.cpu: "250m" 和 resources.requests.memory: "256Mi"。
   ```
2. ```
   通过编辑增加命名空间 ResourceQuota：kubectl edit quota <quota-name> -n <namespace> 并提高 spec.hard.cpu 或 spec.hard.memory。
   ```
3. ```
   使用集群自动缩放或节点缩放添加更多资源，然后相应调整配额。
   ```

## 无效尝试

- **** — Simply restarting the pod without adjusting resource limits causes immediate re-eviction. (90% 失败率)
- **** — Increasing the pod's resource requests without checking namespace quota may still fail if the quota is already maxed out. (70% 失败率)
- **** — Deleting the ResourceQuota object to bypass limits can lead to resource starvation for other pods. (80% 失败率)
