0

理论上我已经通过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 的信息。

4

0 回答 0