Open cwrx777 opened 1 month ago
i also tested using the following:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: test-pvc
annotations:
volumeType: local
spec:
accessModes:
- ReadWriteOnce
storageClassName: local-path
resources:
requests:
storage: 10Mi
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: demo
name: busybox
spec:
replicas: 5
selector:
matchLabels:
app: demo
template:
metadata:
labels:
app: demo
spec:
volumes:
- name: vol
persistentVolumeClaim:
claimName: test-pvc
terminationGracePeriodSeconds: 5
containers:
- image: docker.io/rancher/mirrored-library-busybox:1.36.1
imagePullPolicy: IfNotPresent
name: busybox
volumeMounts:
- name: vol
mountPath: "/mnt"
command:
- sh
args:
- -c
- |
while true; do
echo "$(date) $(hostname)" > /mnt/shared.log
sleep $(($RANDOM % 5 + 5))
done
securityContext:
seLinuxOptions: {}
runAsUser: 1000
runAsGroup: 2000
runAsNonRoot: true
readOnlyRootFilesystem: false
allowPrivilegeEscalation: false
privileged: false
capabilities:
drop: ["ALL"]
seccompProfile:
type: "RuntimeDefault"
only one of the pod is able to write to /mnt/shared.log
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{"volumeType":"local"},"name":"test-pvc","namespace":"rmf"},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Mi"}},"storageClassName":"local-path"}}
pv.kubernetes.io/bind-completed: "yes"
pv.kubernetes.io/bound-by-controller: "yes"
volumeType: local
creationTimestamp: "2024-07-19T04:02:16Z"
finalizers:
- kubernetes.io/pvc-protection
name: test-pvc
namespace: rmf
resourceVersion: "2861033"
uid: acb2fb1f-4a49-45d2-92a7-21647cfb297a
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Mi
storageClassName: local-path
volumeMode: Filesystem
volumeName: pvc-51290e8e-9b18-45bb-b0e7-2a726208eed8
status:
accessModes:
- ReadWriteOnce
capacity:
storage: 10Mi
phase: Bound
apiVersion: v1
kind: PersistentVolume
metadata:
annotations:
local.path.provisioner/selected-node: <hostname>
pv.kubernetes.io/provisioned-by: rancher.io/local-path
creationTimestamp: "2024-07-19T03:59:35Z"
finalizers:
- kubernetes.io/pv-protection
name: pvc-51290e8e-9b18-45bb-b0e7-2a726208eed8
resourceVersion: "2861031"
uid: 99adc40e-fff7-4a91-b20e-56710324817d
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 10Mi
claimRef:
apiVersion: v1
kind: PersistentVolumeClaim
name: test-pvc
namespace: rmf
resourceVersion: "2861029"
uid: acb2fb1f-4a49-45d2-92a7-21647cfb297a
local:
path: /var/lib/rancher/k3s/storage/pvc-51290e8e-9b18-45bb-b0e7-2a726208eed8_rmf_test-pvc
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- <hostname>
persistentVolumeReclaimPolicy: Retain
storageClassName: local-storage
volumeMode: Filesystem
status:
lastPhaseTransitionTime: "2024-07-19T04:02:16Z"
phase: Bound
I also notice this event:
running PreBind plugin "VolumeBinding": Operation cannot be fulfilled on persistentvolumeclaims "test-pvc": the object has been modified; please apply your changes to the latest version and try again
I have created a PV with the following yaml
and this PVC
And I want to create two pods, e.g. mysql and mysql-backup, both pods are running in the same node, to be able to access the PV, in the same node as the pods, for accessing mysql data-dir at the same time. both pods are using the same PVC. Will that work?
I have created two pods in
k3s
with volume using the same PVC. In both pods (deployed using helm twice, with different release name), I can see the directory. but only one of the pod can browse the directory whereas the other one encountered 'permission denied' error.folder permission in container in both pods:
folder permission in host: