Closed chr0n1x closed 2 months ago
subDir
parameter supports following pv/pvc metadata conversionif
subDir
value contains following string, it would be converted into corresponding pv/pvc name or namespace
${pvc.metadata.name}
${pvc.metadata.namespace}
${pv.metadata.name}
Great! thanks @andyzhangx, I'll take a look!
@andyzhangx sorry but I might be misunderstanding something. for chart version ~1.9, the controller isn't creating a new PersistentVolume
.
My StorageClass
:
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: smb
namespace: {{ .Release.Namespace }}
provisioner: smb.csi.k8s.io
parameters:
source: {{ .Values.smb.host }}
csi.storage.k8s.io/provisioner-secret-name: {{ .Values.smb.credsName | default "smbcreds" }}
csi.storage.k8s.io/provisioner-secret-namespace: {{ .Release.Namespace }}
csi.storage.k8s.io/node-stage-secret-name: {{ .Values.smb.credsName | default "smbcreds" }}
csi.storage.k8s.io/node-stage-secret-namespace: {{ .Release.Namespace }}
reclaimPolicy: Retain # available values: Delete, Retain
volumeBindingMode: Immediate
mountOptions:
- dir_mode=0777
- file_mode=0777
- uid=1001
- gid=1001
I tried adding it as a parameter
, e.g.:
parameters:
subDir: ${pvc.metadata.name}--${pvc.metadata.namespace}/${pv.metadata.name}
note the /
at the end. the controller then errors with:
'ProvisioningFailed' failed to provision volume with StorageClass "smb": rpc
error: code = Internal desc = failed to make subdirectory:
mkdir /tmp/pvc-6134acb6-0879-4eb3-acb9-b7c03f0a431a/smb-pvc--smb-pvc-example/pvc-6134acb6-0879-4eb3-acb9-b7c03f0a431a: no such file or directory
overall though, this doesn't really suit my needs. what I would really like to do is to pass in parameters from the PVC
itself.
So in a separate namespace I have this PersistentVolumeClaim
that I'm kubectl apply -f ...
'ing:
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: smb-pvc
namespace: smb-pvc-example
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 50Mi
storageClassName: smb
The documentation that you linked states that I can use volumeAttributes.subDir
for PV/PVCs
. But I can't seem to get it to work with the manifest above.
Ideally I would like to define the name of the generated PV
IN the PVC
itself when it uses the cluster-defined storage class smb
that I defined above. So something like:
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: smb-pvc
namespace: smb-pvc-example
# THIS is effectively what I want
labels:
csi.storage.k8s.io/pv-generate-name: ${pvc.metadata.name}--${pvc.metadata.namespace}--<name of deployment that Im going to attach to>--${UUID}
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 50Mi
storageClassName: smb
is that possible at all? thanks in advance!
@chr0n1x there is not supported in the upstream: https://github.com/kubernetes-csi/external-provisioner/issues/760, and /
is also not allowed in subDir
parameter
@andyzhangx oh that issue is closed ☹️
I guess they're looking for contrubutors per https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/issues/1018 . Ill close this issue, thanks for the help!
Hello, there's nothing in the examples as far as I can see, so Im requesting here:
Would it make sense to have some way for us to define a
StorageClass
with agenerateName
annotation?I currently have the SMB driver/controller and longhorn installed. ALL PVs created by both CSI drivers start with
pvc-.....
.I'd like to have all SMB-generated PVs to be prefixed with
smb-pvc-...
instead. Ideally, for my usecases I'd like to do something like defining a naming template e.g.:generateName: "${pod.name}-smb-pvc-"
Apologies if there's already documentation for this and I missed this.