# 0/4 个节点可用：4 个节点不匹配 Pod 的节点亲和性/选择器。抢占：0/4 个节点可用：4 个未找到可抢占的受害者。

- **ID:** `kubernetes/insufficient-node-selector`
- **领域:** kubernetes
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

Pod 的节点亲和性规则或节点选择器与任何可用节点的标签都不匹配，并且抢占无法找到受害者，因为 Pod 的优先级太低或不存在更低优先级的 Pod。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Kubernetes 1.24 | active | — | — |
| Kubernetes 1.27 | active | — | — |

## 解决方案

1. ```
   Check the pod's node affinity/selector: `kubectl get pod <pod-name> -o yaml | grep -A 10 nodeAffinity`. Then verify node labels: `kubectl get nodes --show-labels`. Adjust the pod spec or node labels to match.
   ```
2. ```
   If the pod uses nodeSelector, add the required label to a node: `kubectl label node <node-name> <key>=<value>`. For example, if nodeSelector has `disktype: ssd`, run `kubectl label node worker1 disktype=ssd`.
   ```
3. ```
   Remove or relax the node affinity rules by editing the pod/deployment spec: `kubectl edit deployment <deployment-name>` and remove the `nodeSelector` or `nodeAffinity` fields.
   ```

## 无效尝试

- **** — Increasing the pod's priority class does not help if no nodes match the affinity rules; it only affects preemption. (70% 失败率)
- **** — Adding more nodes without correct labels will not match the pod's selectors. (80% 失败率)
