Skip to content

Commit c02ebf9

Browse files
authored
feat: add velero plugin configuration schema and validation (#3169)
* feat: add Velero plugin configuration schema and validation Add support for configuring custom Velero plugins in the Embedded Cluster Config CRD. This is the first PR in a series to enable vendors to extend EC's disaster recovery capabilities with specialized backup plugins. Changes: - Add VeleroExtensions and VeleroPlugin types to ConfigSpec.Extensions - Regenerate CRD schema to include velero.plugins field with validation - Implement plugin validation in lint validator: - Validate image format (OCI reference format) - Detect duplicate plugin images - Check for required fields - Add unit tests for validation logic The new configuration structure allows vendors to specify custom Velero plugins as OCI images that will be injected as initContainers into the Velero deployment. Image references support both explicit registry paths and short names that will use EC's proxy registry. Example configuration: extensions: velero: plugins: - image: myvendor/velero-plugin:v1.0.0 This sets the foundation for PR 2 which will implement the Helm values generation to actually inject these plugins into the Velero deployment. Refs: SC-131045 Signed-off-by: Evans Mungai <[email protected]> * Additional unit tests for image format validation Signed-off-by: Evans Mungai <[email protected]> * Add container name to Velero plugin configuration Signed-off-by: Evans Mungai <[email protected]> * Use oras-go to validate image format Signed-off-by: Evans Mungai <[email protected]> * Better test name Signed-off-by: Evans Mungai <[email protected]> * Fix failing tests Signed-off-by: Evans Mungai <[email protected]> * Remove unsupported example from config_types.go Signed-off-by: Evans Mungai <[email protected]> * Remove unnecessary comments Signed-off-by: Evans Mungai <[email protected]> * Additional comment to explain to copilot Signed-off-by: Evans Mungai <[email protected]> * Use ReferenceRegexp to validate image format Signed-off-by: Evans Mungai <[email protected]> * Fix failing unit test Signed-off-by: Evans Mungai <[email protected]> * Fix lint errors Signed-off-by: Evans Mungai <[email protected]> --------- Signed-off-by: Evans Mungai <[email protected]>
1 parent 3325356 commit c02ebf9

File tree

11 files changed

+707
-1
lines changed

11 files changed

+707
-1
lines changed

kinds/apis/v1beta1/config_types.go

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,34 @@ type Helm struct {
142142
}
143143

144144
type Extensions struct {
145-
Helm *Helm `json:"helm,omitempty"`
145+
Helm *Helm `json:"helm,omitempty"`
146+
Velero VeleroExtensions `json:"velero,omitempty"`
147+
}
148+
149+
// VeleroExtensions contains Velero-specific extension settings
150+
type VeleroExtensions struct {
151+
// Plugins is a list of custom Velero plugins to be added as initContainers
152+
// +kubebuilder:validation:Optional
153+
Plugins []VeleroPlugin `json:"plugins,omitempty"`
154+
}
155+
156+
// VeleroPlugin defines a custom Velero plugin to be added to the Velero deployment
157+
type VeleroPlugin struct {
158+
// Name is the container name for the plugin initContainer
159+
// This name will be used as the initContainer name in the Velero deployment
160+
// +kubebuilder:validation:Required
161+
Name string `json:"name"`
162+
// Image is the OCI image reference for the plugin container
163+
// Examples:
164+
// - "myvendor/velero-postgresql:v1.0.0" (explicit registry)
165+
// +kubebuilder:validation:Required
166+
Image string `json:"image"`
167+
// ImagePullPolicy is the image pull policy for the plugin container.
168+
// Valid values are: Always, IfNotPresent, Never
169+
// If not specified, defaults to IfNotPresent
170+
// +kubebuilder:validation:Optional
171+
// +kubebuilder:validation:Enum=Always;IfNotPresent;Never
172+
ImagePullPolicy string `json:"imagePullPolicy,omitempty"`
146173
}
147174

148175
type Domains struct {

kinds/apis/v1beta1/zz_generated.deepcopy.go

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

operator/charts/embedded-cluster-operator/charts/crds/templates/resources.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,44 @@ spec:
129129
type: object
130130
type: array
131131
type: object
132+
velero:
133+
description: VeleroExtensions contains Velero-specific extension
134+
settings
135+
properties:
136+
plugins:
137+
description: Plugins is a list of custom Velero plugins to
138+
be added as initContainers
139+
items:
140+
description: VeleroPlugin defines a custom Velero plugin
141+
to be added to the Velero deployment
142+
properties:
143+
image:
144+
description: |-
145+
Image is the OCI image reference for the plugin container
146+
Examples:
147+
- "myvendor/velero-postgresql:v1.0.0" (explicit registry)
148+
type: string
149+
imagePullPolicy:
150+
description: |-
151+
ImagePullPolicy is the image pull policy for the plugin container.
152+
Valid values are: Always, IfNotPresent, Never
153+
If not specified, defaults to IfNotPresent
154+
enum:
155+
- Always
156+
- IfNotPresent
157+
- Never
158+
type: string
159+
name:
160+
description: |-
161+
Name is the container name for the plugin initContainer
162+
This name will be used as the initContainer name in the Velero deployment
163+
type: string
164+
required:
165+
- image
166+
- name
167+
type: object
168+
type: array
169+
type: object
132170
type: object
133171
metadataOverrideUrl:
134172
type: string
@@ -451,6 +489,44 @@ spec:
451489
type: object
452490
type: array
453491
type: object
492+
velero:
493+
description: VeleroExtensions contains Velero-specific extension
494+
settings
495+
properties:
496+
plugins:
497+
description: Plugins is a list of custom Velero plugins
498+
to be added as initContainers
499+
items:
500+
description: VeleroPlugin defines a custom Velero plugin
501+
to be added to the Velero deployment
502+
properties:
503+
image:
504+
description: |-
505+
Image is the OCI image reference for the plugin container
506+
Examples:
507+
- "myvendor/velero-postgresql:v1.0.0" (explicit registry)
508+
type: string
509+
imagePullPolicy:
510+
description: |-
511+
ImagePullPolicy is the image pull policy for the plugin container.
512+
Valid values are: Always, IfNotPresent, Never
513+
If not specified, defaults to IfNotPresent
514+
enum:
515+
- Always
516+
- IfNotPresent
517+
- Never
518+
type: string
519+
name:
520+
description: |-
521+
Name is the container name for the plugin initContainer
522+
This name will be used as the initContainer name in the Velero deployment
523+
type: string
524+
required:
525+
- image
526+
- name
527+
type: object
528+
type: array
529+
type: object
454530
type: object
455531
metadataOverrideUrl:
456532
type: string

operator/config/crd/bases/embeddedcluster.replicated.com_configs.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,44 @@ spec:
127127
type: object
128128
type: array
129129
type: object
130+
velero:
131+
description: VeleroExtensions contains Velero-specific extension
132+
settings
133+
properties:
134+
plugins:
135+
description: Plugins is a list of custom Velero plugins to
136+
be added as initContainers
137+
items:
138+
description: VeleroPlugin defines a custom Velero plugin
139+
to be added to the Velero deployment
140+
properties:
141+
image:
142+
description: |-
143+
Image is the OCI image reference for the plugin container
144+
Examples:
145+
- "myvendor/velero-postgresql:v1.0.0" (explicit registry)
146+
type: string
147+
imagePullPolicy:
148+
description: |-
149+
ImagePullPolicy is the image pull policy for the plugin container.
150+
Valid values are: Always, IfNotPresent, Never
151+
If not specified, defaults to IfNotPresent
152+
enum:
153+
- Always
154+
- IfNotPresent
155+
- Never
156+
type: string
157+
name:
158+
description: |-
159+
Name is the container name for the plugin initContainer
160+
This name will be used as the initContainer name in the Velero deployment
161+
type: string
162+
required:
163+
- image
164+
- name
165+
type: object
166+
type: array
167+
type: object
130168
type: object
131169
metadataOverrideUrl:
132170
type: string

operator/config/crd/bases/embeddedcluster.replicated.com_installations.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,44 @@ spec:
193193
type: object
194194
type: array
195195
type: object
196+
velero:
197+
description: VeleroExtensions contains Velero-specific extension
198+
settings
199+
properties:
200+
plugins:
201+
description: Plugins is a list of custom Velero plugins
202+
to be added as initContainers
203+
items:
204+
description: VeleroPlugin defines a custom Velero plugin
205+
to be added to the Velero deployment
206+
properties:
207+
image:
208+
description: |-
209+
Image is the OCI image reference for the plugin container
210+
Examples:
211+
- "myvendor/velero-postgresql:v1.0.0" (explicit registry)
212+
type: string
213+
imagePullPolicy:
214+
description: |-
215+
ImagePullPolicy is the image pull policy for the plugin container.
216+
Valid values are: Always, IfNotPresent, Never
217+
If not specified, defaults to IfNotPresent
218+
enum:
219+
- Always
220+
- IfNotPresent
221+
- Never
222+
type: string
223+
name:
224+
description: |-
225+
Name is the container name for the plugin initContainer
226+
This name will be used as the initContainer name in the Velero deployment
227+
type: string
228+
required:
229+
- image
230+
- name
231+
type: object
232+
type: array
233+
type: object
196234
type: object
197235
metadataOverrideUrl:
198236
type: string

operator/config/crd/bases/embeddedcluster.replicated.com_kubernetesinstallations.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,44 @@ spec:
152152
type: object
153153
type: array
154154
type: object
155+
velero:
156+
description: VeleroExtensions contains Velero-specific extension
157+
settings
158+
properties:
159+
plugins:
160+
description: Plugins is a list of custom Velero plugins
161+
to be added as initContainers
162+
items:
163+
description: VeleroPlugin defines a custom Velero plugin
164+
to be added to the Velero deployment
165+
properties:
166+
image:
167+
description: |-
168+
Image is the OCI image reference for the plugin container
169+
Examples:
170+
- "myvendor/velero-postgresql:v1.0.0" (explicit registry)
171+
type: string
172+
imagePullPolicy:
173+
description: |-
174+
ImagePullPolicy is the image pull policy for the plugin container.
175+
Valid values are: Always, IfNotPresent, Never
176+
If not specified, defaults to IfNotPresent
177+
enum:
178+
- Always
179+
- IfNotPresent
180+
- Never
181+
type: string
182+
name:
183+
description: |-
184+
Name is the container name for the plugin initContainer
185+
This name will be used as the initContainer name in the Velero deployment
186+
type: string
187+
required:
188+
- image
189+
- name
190+
type: object
191+
type: array
192+
type: object
155193
type: object
156194
metadataOverrideUrl:
157195
type: string

operator/schemas/config-embeddedcluster-v1beta1.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,43 @@
128128
}
129129
}
130130
}
131+
},
132+
"velero": {
133+
"description": "VeleroExtensions contains Velero-specific extension settings",
134+
"type": "object",
135+
"properties": {
136+
"plugins": {
137+
"description": "Plugins is a list of custom Velero plugins to be added as initContainers",
138+
"type": "array",
139+
"items": {
140+
"description": "VeleroPlugin defines a custom Velero plugin to be added to the Velero deployment",
141+
"type": "object",
142+
"required": [
143+
"image",
144+
"name"
145+
],
146+
"properties": {
147+
"image": {
148+
"description": "Image is the OCI image reference for the plugin container\nExamples:\n - \"myvendor/velero-postgresql:v1.0.0\" (explicit registry)",
149+
"type": "string"
150+
},
151+
"imagePullPolicy": {
152+
"description": "ImagePullPolicy is the image pull policy for the plugin container.\nValid values are: Always, IfNotPresent, Never\nIf not specified, defaults to IfNotPresent",
153+
"type": "string",
154+
"enum": [
155+
"Always",
156+
"IfNotPresent",
157+
"Never"
158+
]
159+
},
160+
"name": {
161+
"description": "Name is the container name for the plugin initContainer\nThis name will be used as the initContainer name in the Velero deployment",
162+
"type": "string"
163+
}
164+
}
165+
}
166+
}
167+
}
131168
}
132169
}
133170
},

operator/schemas/kubernetesinstallation-embeddedcluster-v1beta1.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,43 @@
154154
}
155155
}
156156
}
157+
},
158+
"velero": {
159+
"description": "VeleroExtensions contains Velero-specific extension settings",
160+
"type": "object",
161+
"properties": {
162+
"plugins": {
163+
"description": "Plugins is a list of custom Velero plugins to be added as initContainers",
164+
"type": "array",
165+
"items": {
166+
"description": "VeleroPlugin defines a custom Velero plugin to be added to the Velero deployment",
167+
"type": "object",
168+
"required": [
169+
"image",
170+
"name"
171+
],
172+
"properties": {
173+
"image": {
174+
"description": "Image is the OCI image reference for the plugin container\nExamples:\n - \"myvendor/velero-postgresql:v1.0.0\" (explicit registry)",
175+
"type": "string"
176+
},
177+
"imagePullPolicy": {
178+
"description": "ImagePullPolicy is the image pull policy for the plugin container.\nValid values are: Always, IfNotPresent, Never\nIf not specified, defaults to IfNotPresent",
179+
"type": "string",
180+
"enum": [
181+
"Always",
182+
"IfNotPresent",
183+
"Never"
184+
]
185+
},
186+
"name": {
187+
"description": "Name is the container name for the plugin initContainer\nThis name will be used as the initContainer name in the Velero deployment",
188+
"type": "string"
189+
}
190+
}
191+
}
192+
}
193+
}
157194
}
158195
}
159196
},

0 commit comments

Comments
 (0)