kubernetes - 如何使用“kubectl”CLI 在 pod 内挂载卷
问题描述
我想使用kubectl
CLI 创建一个 pod,它将/etc/os-release
在 pod 容器内安装 hostpath 并显示/etc/os-release
文件内容。是否可以使用单行kubectl
命令来做到这一点?
解决方案
kubectl run -i --rm busybox --image=busybox --overrides='{
"apiVersion": "v1",
"spec": {
"containers": [
{
"image": "busybox",
"name": "busybox",
"command": ["cat", "/etc/os-release"],
"resources": {},
"volumeMounts": [
{
"mountPath": "/etc/os-release",
"name": "release"
}
]
}
],
"volumes": [
{
"name": "release",
"hostPath": {
"path": "/etc/os-release",
"type": "File"
}
}
],
"dnsPolicy": "ClusterFirst",
"restartPolicy": "Never"
},
"status": {}
}'
NAME=Buildroot
VERSION=2019.02.10
ID=buildroot
VERSION_ID=2019.02.10
PRETTY_NAME="Buildroot 2019.02.10"
pod "busybox" deleted
推荐阅读
- django - 如何检测 HttpResponse(content_type='text/csv') 何时在 Django 模板中开始?
- asp.net - 用户 IIS 的 SQL 登录失败
- c# - SqlException:列名“EmployeeID1”无效
- ios - 类型 '()' 不能符合 'View';只有结构/枚举/类类型可以符合协议;使用 SwiftUI 调用函数
- java - 发送键盘输出
- json - Newtonsoft Json 反序列化忽略 NullValueHandling.Ignore
- css - 移动屏幕上的 Angular ngx-boostrap datepicker 位置问题
- pascal - 尝试验证文本文件中的字符时陷入循环
- python - NS-3 ImportError:没有名为 cflags 的模块
- java - 无法在嵌套 if 条件下访问扫描仪