# 错误：启动容器失败：创建containerd任务失败：挂载 /var/lib/kubelet/pods/.../volumes/...：操作不允许

- **ID:** `kubernetes/volume-mount-readonly-filesystem`
- **领域:** kubernetes
- **类别:** system_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

容器运行时（containerd）无法挂载卷，因为底层文件系统是只读的或挂载点无效，通常由于SELinux强制或AppArmor配置文件。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Kubernetes 1.28 | active | — | — |
| Kubernetes 1.29 | active | — | — |
| containerd 1.7.0 | active | — | — |
| Ubuntu 22.04 | active | — | — |

## 解决方案

1. ```
   检查SELinux状态：`getenforce`。如果是强制模式，临时设置为宽松模式：`setenforce 0`。然后验证挂载是否成功。持久修复：调整SELinux策略：`semanage fcontext -a -t container_file_t '/var/lib/kubelet/pods/.*/volumes/.*(/.*)?'`。
   ```
2. ```
   检查AppArmor状态：`aa-status`。如果有配置文件阻止，卸载它：`aa-remove-unknown`或创建允许挂载操作的自定义配置文件。
   ```

## 无效尝试

- **** — Restarting kubelet or containerd doesn't fix the underlying filesystem or SELinux issue; mounts will still fail. (70% 失败率)
- **** — Re-creating the pod without fixing SELinux context or AppArmor profile results in the same mount error. (80% 失败率)
