Does PVC (PersistentVolumeClaim) work on DO? Followed the tutorial, but the volume is mounted readonly inside pod no matter what I did.

February 28, 2019 457 views
Kubernetes

k get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
pvc-74c6a1d6-3b4f-11e9-b7b8-6217111e43b6 1Gi RWO Delete Bound default/admin do-block-storage 83s

k describe pods
Name: k8sinit-5d464b9dbb-q555h
Namespace: default
Priority: 0
PriorityClassName: <none>
Node: recursing-aryabhata-ukc0/10.135.91.105
Start Time: Thu, 28 Feb 2019 11:54:11 +0000
Labels: pod-template-hash=5d464b9dbb
run=k8sinit
Annotations: <none>
Status: Pending
IP:

Controlled By: ReplicaSet/k8sinit-5d464b9dbb
Containers:
init:
Container ID:

Image: registry.trophyking.io/init:1.0
Image ID:

Ports: 443/TCP, 80/TCP
Host Ports: 0/TCP, 0/TCP
State: Waiting
Reason: ContainerCreating
Ready: False
Restart Count: 0
Environment: <none>
Mounts:
/admin from admin (rw)
/var/run/secrets/kubernetes.io/serviceaccount from default-token-c7f86 (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
admin:
Type: Secret (a volume populated by a Secret)
SecretName: digitaloceanrw
Optional: false
default-token-c7f86:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-c7f86
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message


Normal Scheduled 12s default-scheduler Successfully assigned default/k8sinit-5d464b9dbb-q555h to recursing-aryabhata-ukc0
Normal Pulling 9s kubelet, recursing-aryabhata-ukc0 pulling image "registry.trophyking.io/init:1.0"
root@trophyking-devops:~/k8s# k describe pods
Name: k8sinit-5d464b9dbb-q555h
Namespace: default
Priority: 0
PriorityClassName: <none>
Node: recursing-aryabhata-ukc0/10.135.91.105
Start Time: Thu, 28 Feb 2019 11:54:11 +0000
Labels: pod-template-hash=5d464b9dbb
run=k8sinit
Annotations: <none>
Status: Running
IP: 10.244.0.217
Controlled By: ReplicaSet/k8sinit-5d464b9dbb
Containers:
init:
Container ID: docker://3f5f0f7f7a814198e6ad1006f0444b2b6a8fadd2b2d94bc87cafc9d5d6c8bb5b
Image: registry.trophyking.io/init:1.0
Image ID: docker-pullable://registry.trophyking.io/init@sha256:9b91484c2ef307f2c0e769519f17f2dec287a7eec8c0dacf73ad3d1b565c85e0
Ports: 443/TCP, 80/TCP
Host Ports: 0/TCP, 0/TCP
State: Running
Started: Thu, 28 Feb 2019 11:54:31 +0000
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/admin from admin (rw)
/var/run/secrets/kubernetes.io/serviceaccount from default-token-c7f86 (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
admin:
Type: Secret (a volume populated by a Secret)
SecretName: digitaloceanrw
Optional: false
default-token-c7f86:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-c7f86
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message


Normal Scheduled 24s default-scheduler Successfully assigned default/k8sinit-5d464b9dbb-q555h to recursing-aryabhata-ukc0
Normal Pulling 21s kubelet, recursing-aryabhata-ukc0 pulling image "registry.trophyking.io/init:1.0"
Normal Pulled 4s kubelet, recursing-aryabhata-ukc0 Successfully pulled image "registry.trophyking.io/init:1.0"
Normal Created 4s kubelet, recursing-aryabhata-ukc0 Created container
Normal Started 4s kubelet, recursing-aryabhata-ukc0 Started container

k exec -it k8sinit-5d464b9dbb-q555h bash
root@k8sinit-5d464b9dbb-q555h:/usr/local/apache2# mount | grep admin
tmpfs on /admin type tmpfs (ro,relatime)

1 Answer

Hey friend,

Thank you for asking this question here. Our resident Kubernetes genius, John, weighed in with this:

This documentation should be helpful:
https://kubernetes.io/docs/concepts/storage/persistent-volumes/#claims-as-volumes

You'll want the volumes section to look something like this:

Volumes:
  arbitrary-volume:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  do-pvc
    ReadOnly:   false

Jarland

Have another answer? Share your knowledge.