| 注入方式 | Secret 挂载文件、CSI 驱动对接 KMS、按需拉取 |
|---|---|
| 优先级 | 文件挂载优于环境变量(环境变量易被继承与打印) |
| 检查点 | 镜像历史与 CI 日志中不得出现密钥材料 |
只读挂载与 Kubernetes Secret 读取示例
只读挂载与 Kubernetes Secret 读取示例
docker run --read-only \
--mount type=bind,src=/run/secrets/tls,dst=/etc/tls,readonly nginx:stable
kubectl get secret tls-secret -o jsonpath='{.data.tls\.crt}' | base64 -d检查镜像历史(docker history)确认构建阶段未把密钥写入层;删除文件也不能从镜像层中移除内容。