kubernetes - hostNetwork 设置为 false 不允许复制到 hostPath
问题描述
理论上我已经通过hostNetwork
了 Kubernetes 提供的定义。对于以下 pod 规格
cat hostpod.yaml
apiVersion: v1
kind: Pod
metadata:
name: test-pd
spec:
#hostNetwork: true
containers:
- image: ubuntu
name: test-container
command: [ "/bin/bash", "-c", "--" ]
args: [ "while true; do sleep 30; done;" ]
volumeMounts:
- mountPath: /test-pd
name: test-volume
securityContext:
privileged: false
runAsNonRoot: false
runAsUser: 0
volumes:
- name: test-volume
hostPath:
# directory location on host
path: /usr/local
# this field is optional
并尝试写入文件
root@test-pd:/test-pd# touch newthree.txt
touch: cannot touch 'newthree.txt': Permission denied
但这在我设置时有效hostNetwork:true
。
我能得到一些关于这实际上是如何工作的以及为什么需要 hostNetwork 的信息。
解决方案
推荐阅读
- php - 在 laravel 中使用 postgres bytea blob 字段上传图片
- android - 360度图像查看器在Android中具有运动和触摸功能
- reactjs - 当我单击 Material Ui 中的按钮时如何转到另一个组件
- java - 在 Piechart Android 中显示单个值
- sql - 两年之间无法获取数据
- wpf - 设置 AllowTransparency="False" 时 Telerik Radwindow 渲染不完整
- python - 在不使用 Matplotlib 的情况下测试点是否在椭圆内?
- pywinauto - pywinauto/examples/uninstall_7zip.py 在 Windows 10 上不起作用
- javascript - li 元素溢出 Card 容器并增加父容器以适应自身
- pyspark - 如何在 PySpark UDF 中进行模糊匹配?