hostNetwork 设置为 false 不允许复制到 hostPath

问题描述

理论上我已经了解了 Kubernetes 提供的 hostNetwork 定义。对于以下 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 的信息。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)