Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define/influence generated PV names #814

Closed
chr0n1x opened this issue Jul 30, 2024 · 6 comments
Closed

Define/influence generated PV names #814

chr0n1x opened this issue Jul 30, 2024 · 6 comments

Comments

@chr0n1x
Copy link

chr0n1x commented Jul 30, 2024

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 a generateName 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.

@andyzhangx
Copy link
Member

https://github.com/kubernetes-csi/csi-driver-smb/blob/master/docs/driver-parameters.md#subdir-parameter-supports-following-pvpvc-metadata-conversion

ONLY subDir parameter supports following pv/pvc metadata conversion

if 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}

@chr0n1x
Copy link
Author

chr0n1x commented Jul 31, 2024

Great! thanks @andyzhangx, I'll take a look!

@chr0n1x
Copy link
Author

chr0n1x commented Jul 31, 2024

@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!

@andyzhangx
Copy link
Member

@chr0n1x there is not supported in the upstream: kubernetes-csi/external-provisioner#760, and / is also not allowed in subDir parameter

@chr0n1x
Copy link
Author

chr0n1x commented Jul 31, 2024

@andyzhangx oh that issue is closed ☹️

@chr0n1x
Copy link
Author

chr0n1x commented Jul 31, 2024

I guess they're looking for contrubutors per kubernetes-sigs/gcp-compute-persistent-disk-csi-driver#1018 . Ill close this issue, thanks for the help!

@chr0n1x chr0n1x closed this as not planned Won't fix, can't repro, duplicate, stale Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants