kubernetes volumes not visible

10/19/2021

I have pod definition file

apiVersion: v1
kind: Pod
metadata:
  name: ubuntu-docker-soc
spec:
  containers:
  - name: ubuntu-docker-soc
    image: rajendarre/ubuntu-docker
    command: [ "/bin/sh", "-c", "--" ]
    args: [ "while true; do sleep 30; done;" ]
    volumeMounts:
    - name: dockersock
      mountPath: "/var/run/docker.sock"

  restartPolicy: Never
  volumes:
  - name: dockersock
    hostPath:
      path: /var/run/docker.sock

I have created pod successfully , but command kubectl get pv is not showing any volumes , as I have volume dockersoc , it should come as volume . please let me know understanding is correct ?

-- Rajendar Talatam
kubectl
kubernetes
kubernetes-pod
ubuntu

1 Answer

10/19/2021

PersistentVolume is a provisioned cluster resource, where else local file or directory that you mount from the underlying node directly in your pod is not a cluster resource that requires provisioning. Therefore in your example, kubectl get pv will not get you anything.

Here's a good discussion about PV/PVC on major cloud providers.

-- gohm'c
Source: StackOverflow