Skip to content

Conversation

@banjoh
Copy link
Member

@banjoh banjoh commented Nov 6, 2025

What this PR does / why we need it:

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: ghcr.io/banjoh/velero-plugin-cnpg-restore:latest
          imagePullPolicy: Always # Optional: defaults to IfNotPresent

This sets the foundation for #3177 which will implement the Helm values generation to actually inject these plugins into the Velero deployment.

Which issue(s) this PR fixes:

Ref: sc-131045

Does this PR require a test?

Does this PR require a release note?


Does this PR require documentation?

@banjoh banjoh marked this pull request as draft November 6, 2025 14:33
@banjoh banjoh force-pushed the evansmungai/sc-131045/add-ec-config-to-add-velero-plugins branch from ccb27c9 to 0db3432 Compare November 6, 2025 14:35
@github-actions
Copy link

github-actions bot commented Nov 6, 2025

This PR has been released (on staging) and is available for download with a embedded-cluster-smoke-test-staging-app license ID.

Online Installer:

curl "https://staging.replicated.app/embedded/embedded-cluster-smoke-test-staging-app/ci/appver-dev-b385ae3" -H "Authorization: $EC_SMOKE_TEST_LICENSE_ID" -o embedded-cluster-smoke-test-staging-app-ci.tgz

Airgap Installer (may take a few minutes before the airgap bundle is built):

curl "https://staging.replicated.app/embedded/embedded-cluster-smoke-test-staging-app/ci-airgap/appver-dev-b385ae3?airgap=true" -H "Authorization: $EC_SMOKE_TEST_LICENSE_ID" -o embedded-cluster-smoke-test-staging-app-ci.tgz

Happy debugging!

@banjoh banjoh changed the title feat: add Velero plugin configuration schema and validation feat: add velero plugin configuration schema and validation Nov 7, 2025
@banjoh banjoh marked this pull request as ready for review November 7, 2025 15:36
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]>
@banjoh banjoh force-pushed the evansmungai/sc-131045/add-ec-config-to-add-velero-plugins branch from 7a3670b to d3986cc Compare November 7, 2025 15:43
return errors
}

// validateImageFormat validates that an image string follows a valid OCI image reference format
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a standard regex used by tools like docker that we can just use instead of reimplementing this from scratch?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is. I changed this implementation to use oras library for that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the comment below about basic validation irrelevant / inaccurate now then?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is. I removed it

Signed-off-by: Evans Mungai <[email protected]>
expectError: true,
errorCount: 1,
errorFields: []string{"extensions.velero.plugins[0].image"},
errorMsgs: []string{"invalid repository"},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Image Validation Returns Unexpected Error Message

The test expects error message to contain "invalid repository" but validateImageFormat returns "invalid image reference". This causes the test assertion at line 670 to fail since the actual error message won't match the expected substring.

Fix in Cursor Fix in Web

Signed-off-by: Evans Mungai <[email protected]>
Signed-off-by: Evans Mungai <[email protected]>
@banjoh banjoh merged commit c02ebf9 into main Nov 12, 2025
53 checks passed
@banjoh banjoh deleted the evansmungai/sc-131045/add-ec-config-to-add-velero-plugins branch November 12, 2025 22:05
JGAntunes pushed a commit that referenced this pull request Nov 13, 2025
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants