Skip to content

Commit

Permalink
feat(trait): mount volume from storage class
Browse files Browse the repository at this point in the history
Closes #2994
  • Loading branch information
squakez committed Oct 13, 2024
1 parent c10db08 commit 3ec5298
Show file tree
Hide file tree
Showing 13 changed files with 305 additions and 45 deletions.
4 changes: 3 additions & 1 deletion docs/modules/ROOT/partials/apis/camel-k-crds.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8008,7 +8008,9 @@ Syntax: [configmap{vbar}secret]:name[/key][@path], where name represents the res
|
A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]
A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]. If the PVC is not found, the Integration fails.
You can use the syntax [pvcname:/container/path:size:accessMode<:storageClass>] to create a dynamic PVC based on the Storage Class provided
or the default cluster Storage Class. However, if the PVC exists, the operator would mount it.
|`emptyDirs` +
[]string
Expand Down
15 changes: 14 additions & 1 deletion docs/modules/traits/pages/mount.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ Syntax: [configmap\|secret]:name[/key][@path], where name represents the resourc

| mount.volumes
| []string
| A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]
| A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]. If the PVC is not found, the Integration fails.
You can use the syntax [pvcname:/container/path:size:accessMode<:storageClass>] to create a dynamic PVC based on the Storage Class provided
or the default cluster Storage Class. However, if the PVC exists, the operator would mount it.

| mount.empty-dirs
| []string
Expand All @@ -64,3 +66,14 @@ changes in metadata.
|===

// End of autogenerated code - DO NOT EDIT! (configuration)

== Dynamic creation of PersistentVolumeClaims

If your cluster has some StorageClass defined, you can configure `mount.volume` to create one PersistentVolume on your behalf. This is going to be mounted to the application Pod, according to the configuration given. See Kubernetes documentation about StorageClass to learn more.

[source,console]
$ kamel run test.yaml -t mount.volumes=my-pvc:/tmp/my-pvc:10Mi:ReadOnlyMany

The above command would create a new volume on the fly if it does not exists using "default" StorageClass. You can specify any StorageClass as configuration.

NOTE: if the volume exists, then it would reuse it.
48 changes: 32 additions & 16 deletions helm/camel-k/crds/camel-k-crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4831,8 +4831,10 @@ spec:
2.5.'
type: boolean
volumes:
description: 'A list of Persistent Volume Claims to be mounted.
Syntax: [pvcname:/container/path]'
description: |-
A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]. If the PVC is not found, the Integration fails.
You can use the syntax [pvcname:/container/path:size:accessMode<:storageClass>] to create a dynamic PVC based on the Storage Class provided
or the default cluster Storage Class. However, if the PVC exists, the operator would mount it.
items:
type: string
type: array
Expand Down Expand Up @@ -6969,8 +6971,10 @@ spec:
2.5.'
type: boolean
volumes:
description: 'A list of Persistent Volume Claims to be mounted.
Syntax: [pvcname:/container/path]'
description: |-
A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]. If the PVC is not found, the Integration fails.
You can use the syntax [pvcname:/container/path:size:accessMode<:storageClass>] to create a dynamic PVC based on the Storage Class provided
or the default cluster Storage Class. However, if the PVC exists, the operator would mount it.
items:
type: string
type: array
Expand Down Expand Up @@ -9010,8 +9014,10 @@ spec:
2.5.'
type: boolean
volumes:
description: 'A list of Persistent Volume Claims to be mounted.
Syntax: [pvcname:/container/path]'
description: |-
A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]. If the PVC is not found, the Integration fails.
You can use the syntax [pvcname:/container/path:size:accessMode<:storageClass>] to create a dynamic PVC based on the Storage Class provided
or the default cluster Storage Class. However, if the PVC exists, the operator would mount it.
items:
type: string
type: array
Expand Down Expand Up @@ -11027,8 +11033,10 @@ spec:
2.5.'
type: boolean
volumes:
description: 'A list of Persistent Volume Claims to be mounted.
Syntax: [pvcname:/container/path]'
description: |-
A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]. If the PVC is not found, the Integration fails.
You can use the syntax [pvcname:/container/path:size:accessMode<:storageClass>] to create a dynamic PVC based on the Storage Class provided
or the default cluster Storage Class. However, if the PVC exists, the operator would mount it.
items:
type: string
type: array
Expand Down Expand Up @@ -19085,8 +19093,10 @@ spec:
2.5.'
type: boolean
volumes:
description: 'A list of Persistent Volume Claims to be mounted.
Syntax: [pvcname:/container/path]'
description: |-
A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]. If the PVC is not found, the Integration fails.
You can use the syntax [pvcname:/container/path:size:accessMode<:storageClass>] to create a dynamic PVC based on the Storage Class provided
or the default cluster Storage Class. However, if the PVC exists, the operator would mount it.
items:
type: string
type: array
Expand Down Expand Up @@ -21064,8 +21074,10 @@ spec:
2.5.'
type: boolean
volumes:
description: 'A list of Persistent Volume Claims to be mounted.
Syntax: [pvcname:/container/path]'
description: |-
A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]. If the PVC is not found, the Integration fails.
You can use the syntax [pvcname:/container/path:size:accessMode<:storageClass>] to create a dynamic PVC based on the Storage Class provided
or the default cluster Storage Class. However, if the PVC exists, the operator would mount it.
items:
type: string
type: array
Expand Down Expand Up @@ -29197,8 +29209,10 @@ spec:
2.5.'
type: boolean
volumes:
description: 'A list of Persistent Volume Claims to be
mounted. Syntax: [pvcname:/container/path]'
description: |-
A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]. If the PVC is not found, the Integration fails.
You can use the syntax [pvcname:/container/path:size:accessMode<:storageClass>] to create a dynamic PVC based on the Storage Class provided
or the default cluster Storage Class. However, if the PVC exists, the operator would mount it.
items:
type: string
type: array
Expand Down Expand Up @@ -40121,8 +40135,10 @@ spec:
2.5.'
type: boolean
volumes:
description: 'A list of Persistent Volume Claims to be
mounted. Syntax: [pvcname:/container/path]'
description: |-
A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]. If the PVC is not found, the Integration fails.
You can use the syntax [pvcname:/container/path:size:accessMode<:storageClass>] to create a dynamic PVC based on the Storage Class provided
or the default cluster Storage Class. However, if the PVC exists, the operator would mount it.
items:
type: string
type: array
Expand Down
4 changes: 3 additions & 1 deletion pkg/apis/camel/v1/trait/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ type MountTrait struct {
// The destination path can be either a default location or any path specified by the user.
// Syntax: [configmap|secret]:name[/key][@path], where name represents the resource name, key optionally represents the resource key to be filtered and path represents the destination path
Resources []string `property:"resources" json:"resources,omitempty"`
// A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]
// A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]. If the PVC is not found, the Integration fails.
// You can use the syntax [pvcname:/container/path:size:accessMode<:storageClass>] to create a dynamic PVC based on the Storage Class provided
// or the default cluster Storage Class. However, if the PVC exists, the operator would mount it.
Volumes []string `property:"volumes" json:"volumes,omitempty"`
// A list of EmptyDir volumes to be mounted. Syntax: [name:/container/path]
EmptyDirs []string `property:"empty-dirs" json:"emptyDirs,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1673,8 +1673,10 @@ spec:
2.5.'
type: boolean
volumes:
description: 'A list of Persistent Volume Claims to be mounted.
Syntax: [pvcname:/container/path]'
description: |-
A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]. If the PVC is not found, the Integration fails.
You can use the syntax [pvcname:/container/path:size:accessMode<:storageClass>] to create a dynamic PVC based on the Storage Class provided
or the default cluster Storage Class. However, if the PVC exists, the operator would mount it.
items:
type: string
type: array
Expand Down Expand Up @@ -3811,8 +3813,10 @@ spec:
2.5.'
type: boolean
volumes:
description: 'A list of Persistent Volume Claims to be mounted.
Syntax: [pvcname:/container/path]'
description: |-
A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]. If the PVC is not found, the Integration fails.
You can use the syntax [pvcname:/container/path:size:accessMode<:storageClass>] to create a dynamic PVC based on the Storage Class provided
or the default cluster Storage Class. However, if the PVC exists, the operator would mount it.
items:
type: string
type: array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1542,8 +1542,10 @@ spec:
2.5.'
type: boolean
volumes:
description: 'A list of Persistent Volume Claims to be mounted.
Syntax: [pvcname:/container/path]'
description: |-
A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]. If the PVC is not found, the Integration fails.
You can use the syntax [pvcname:/container/path:size:accessMode<:storageClass>] to create a dynamic PVC based on the Storage Class provided
or the default cluster Storage Class. However, if the PVC exists, the operator would mount it.
items:
type: string
type: array
Expand Down Expand Up @@ -3559,8 +3561,10 @@ spec:
2.5.'
type: boolean
volumes:
description: 'A list of Persistent Volume Claims to be mounted.
Syntax: [pvcname:/container/path]'
description: |-
A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]. If the PVC is not found, the Integration fails.
You can use the syntax [pvcname:/container/path:size:accessMode<:storageClass>] to create a dynamic PVC based on the Storage Class provided
or the default cluster Storage Class. However, if the PVC exists, the operator would mount it.
items:
type: string
type: array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7562,8 +7562,10 @@ spec:
2.5.'
type: boolean
volumes:
description: 'A list of Persistent Volume Claims to be mounted.
Syntax: [pvcname:/container/path]'
description: |-
A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]. If the PVC is not found, the Integration fails.
You can use the syntax [pvcname:/container/path:size:accessMode<:storageClass>] to create a dynamic PVC based on the Storage Class provided
or the default cluster Storage Class. However, if the PVC exists, the operator would mount it.
items:
type: string
type: array
Expand Down Expand Up @@ -9541,8 +9543,10 @@ spec:
2.5.'
type: boolean
volumes:
description: 'A list of Persistent Volume Claims to be mounted.
Syntax: [pvcname:/container/path]'
description: |-
A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]. If the PVC is not found, the Integration fails.
You can use the syntax [pvcname:/container/path:size:accessMode<:storageClass>] to create a dynamic PVC based on the Storage Class provided
or the default cluster Storage Class. However, if the PVC exists, the operator would mount it.
items:
type: string
type: array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7630,8 +7630,10 @@ spec:
2.5.'
type: boolean
volumes:
description: 'A list of Persistent Volume Claims to be
mounted. Syntax: [pvcname:/container/path]'
description: |-
A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]. If the PVC is not found, the Integration fails.
You can use the syntax [pvcname:/container/path:size:accessMode<:storageClass>] to create a dynamic PVC based on the Storage Class provided
or the default cluster Storage Class. However, if the PVC exists, the operator would mount it.
items:
type: string
type: array
Expand Down
6 changes: 4 additions & 2 deletions pkg/resources/config/crd/bases/camel.apache.org_pipes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7628,8 +7628,10 @@ spec:
2.5.'
type: boolean
volumes:
description: 'A list of Persistent Volume Claims to be
mounted. Syntax: [pvcname:/container/path]'
description: |-
A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]. If the PVC is not found, the Integration fails.
You can use the syntax [pvcname:/container/path:size:accessMode<:storageClass>] to create a dynamic PVC based on the Storage Class provided
or the default cluster Storage Class. However, if the PVC exists, the operator would mount it.
items:
type: string
type: array
Expand Down
Loading

0 comments on commit 3ec5298

Please sign in to comment.