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

RFE to allow dynamic creation of Persistent Volumes from storage classes #2994

Closed
ramgopireddy opened this issue Feb 7, 2022 · 15 comments · Fixed by #5889
Closed

RFE to allow dynamic creation of Persistent Volumes from storage classes #2994

ramgopireddy opened this issue Feb 7, 2022 · 15 comments · Fixed by #5889
Labels
area/traits good first issue Does not require full understanding of the codebase kind/feature New feature or request status/never-stale
Milestone

Comments

@ramgopireddy
Copy link

We would like the option to dynamically create a persistent volume using the operator instead of having to create a Persistent Volume first and using it to mount on the integration. Is it possible to extend the Mount trait to allow provisioning of the PV from a storage class as well?

@astefanutti astefanutti added the kind/feature New feature or request label Feb 8, 2022
@squakez squakez added the good first issue Does not require full understanding of the codebase label Feb 15, 2022
@haanhvu
Copy link
Contributor

haanhvu commented Mar 29, 2022

Hi @astefanutti @squakez, I would like to work on this issue. Could you assign it to me? I'm studying the codebase and may ask questions later.

@squakez
Copy link
Contributor

squakez commented Mar 29, 2022

Thanks for your interest.

@haanhvu
Copy link
Contributor

haanhvu commented Apr 17, 2022

From what I see here:

func getVolume(volName, storageType, storageName, filterKey, filterValue string) *corev1.Volume {
items := convertToKeyToPath(filterKey, filterValue)
volume := corev1.Volume{
Name: volName,
VolumeSource: corev1.VolumeSource{},
}
switch storageType {
case "configmap":
volume.VolumeSource.ConfigMap = &corev1.ConfigMapVolumeSource{
LocalObjectReference: corev1.LocalObjectReference{
Name: storageName,
},
Items: items,
}
case "secret":
volume.VolumeSource.Secret = &corev1.SecretVolumeSource{
SecretName: storageName,
Items: items,
}
case "pvc":
volume.VolumeSource.PersistentVolumeClaim = &corev1.PersistentVolumeClaimVolumeSource{
ClaimName: storageName,
}
}
return &volume
}

The mount trait will just mount the PVC, no matter if the PVC is statically or dynamically provisioned.

Is that right @squakez @astefanutti ?

@squakez
Copy link
Contributor

squakez commented Apr 18, 2022

The mount trait will just mount the PVC, no matter if the PVC is statically or dynamically provisioned.

Is that right @squakez @astefanutti ?

Yes, that's my understanding too.

@haanhvu
Copy link
Contributor

haanhvu commented Apr 18, 2022

The mount trait will just mount the PVC, no matter if the PVC is statically or dynamically provisioned.
Is that right @squakez @astefanutti ?

Yes, that's my understanding too.

@squakez if that's the case, then this issue already had a solution?

@squakez
Copy link
Contributor

squakez commented Apr 18, 2022

I think the idea of the issue is to have the trait accepting the parameters to create the PVC on the fly. As an example, we can think the following kamel run -t mount.storage-class=vpc-block -t mount.storage-request=30Gi -t mount.storage-mode=ReadWriteOnce ... which is in charge to create the PVC on the cluster, and later, mount accordingly on the Integration.

@haanhvu
Copy link
Contributor

haanhvu commented Apr 20, 2022

I think the idea of the issue is to have the trait accepting the parameters to create the PVC on the fly. As an example, we can think the following kamel run -t mount.storage-class=vpc-block -t mount.storage-request=30Gi -t mount.storage-mode=ReadWriteOnce ... which is in charge to create the PVC on the cluster, and later, mount accordingly on the Integration.

@squakez should we have another trait for this? I mean, the mount trait should just do what it does: mount the volume. If we need to "create" the volume, should we have another trait for it, like the pvc trait?

@squakez
Copy link
Contributor

squakez commented Apr 20, 2022

@haanhvu we may reason about that for sure. In any case, the business logic would be pretty similar and you'd need to related the mount trait anyway. IMO, we should do a first development within the mount trait, and later figure it out if it makes sense to have a separate trait for that.

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale due to 90 days of inactivity.
It will be closed if no further activity occurs within 15 days.
If you think that’s incorrect or the issue should never stale, please simply write any comment.
Thanks for your contributions!

@squakez
Copy link
Contributor

squakez commented Feb 17, 2023

We could leverage the work done in f82d1e2 to dynamically create a volume based on StorageClasses

@squakez squakez added this to the 2.0.0 milestone Feb 17, 2023
@squakez squakez modified the milestones: 2.0.0, 2.1.0 Jul 27, 2023
@squakez squakez modified the milestones: 2.1.0, 2.2.0 Oct 17, 2023
@squakez squakez modified the milestones: 2.2.0, 2.3.0 Jan 8, 2024
@squakez squakez removed this from the 2.3.0 milestone Apr 2, 2024
@tdiesler
Copy link
Contributor

Perhaps I can have a look

@squakez squakez added this to the 2.4.0 milestone Jun 19, 2024
@tdiesler
Copy link
Contributor

tdiesler commented Jun 19, 2024

I propose ...

kamel run --dev \
    --trait mount.pvc.accessModes=my-pvc:ReadWriteOnce \
    --trait mount.pvc.storageCapacity=my-pvc:5Mi \
    --trait mount.pvc.storageClass=my-pvc:my-storage \
    --trait mount.volumes=my-pvc:/tmp/data pvc-producer.yaml
  • It uses a pvc subsection for all dynamic PVC stuff. We can later migrate this easily to another trait
  • It uses explicit keys for supported PVC props i.e. instead of all in one prop
  • It does not change the semantic of existing mount.* properties
  • Stuff with the same name naturally belongs together

An alternative could be ...

kamel run --dev \
    --trait mount.pvc=my-pvc?accessModes=ReadWriteOnce&storageCapacity=5Mi&storageClass=my-storage \
    --trait mount.volumes=my-pvc:/tmp/data pvc-producer.yaml

@squakez
Copy link
Contributor

squakez commented Jun 19, 2024

Consider that modifying the trait is a hard thing to do as it is encapsulated in the Integration API contract. Whatever we chose, we must try to be as stable as possible. The second approach is better, however I'd avoid to add all that redundancy. Probably the user will read the documentation where he check how to compile a given syntax. IMO, following you suggestion it would be better something like: mount.storage=<pvcName>:<storageClass>:<capacity>:<accessModes>:<mountPath> and, by default, the trait would be in charge to mount withouth the need to specify that.

@tdiesler
Copy link
Contributor

tdiesler commented Jun 19, 2024

Spelled out, this would be ...

kamel run --dev --trait mount.storage=my-pvc:my-storage:5Mi:ReadWriteOnce:/tmp/data pvc-producer.yaml

Using positional arguments (i.e. pvsname=toks[0], class=toks[1], capacity=toks[2], ...) can be problematic when you have optional properties. Name and path are required, so it could perhaps be ...

kamel run --dev 
   --trait mount.storage=my-pvc:/tmp/data?class=my-storage&access=ReadWriteOnce&capacity=5Mi \
   pvc-producer.yaml

This might result in some confusion ...

  1. mount.storage=my-pvc:/tmp/data creates the pvc (with defaults) and mounts it
  2. mount.volumes=my-pvc:/tmp/data requires an existing pvc and mounts it

@squakez squakez modified the milestones: 2.4.0, 2.5.0 Jul 30, 2024
@squakez
Copy link
Contributor

squakez commented Jul 30, 2024

Hello @tdiesler as this is assigned to you, are you thinking to work on this for next milestone or can we clear your name from the assignees?

squakez added a commit to squakez/camel-k that referenced this issue Oct 12, 2024
squakez added a commit to squakez/camel-k that referenced this issue Oct 12, 2024
squakez added a commit that referenced this issue Oct 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/traits good first issue Does not require full understanding of the codebase kind/feature New feature or request status/never-stale
Projects
None yet
5 participants