I have theoretically gone through hostNetwork
definition provided by Kubernetes. For the below pod spec
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
And trying to write to a file
root@test-pd:/test-pd# touch newthree.txt
touch: cannot touch 'newthree.txt': Permission denied
But this works when I set hostNetwork:true
.
could I get some inf on how this actually works and why hostNetwork is required.