Skip to content

Conversation

@banjoh
Copy link
Member

@banjoh banjoh commented Nov 7, 2025

What this PR does / why we need it:

Add ability to configure custom Velero plugins through the Embedded Cluster
config specification. Plugins are injected as initContainers into the Velero
deployment.

Changes:

  • Add VeleroPlugin type to ConfigSpec.Extensions.Velero with required Name
    and Image fields, and optional ImagePullPolicy
  • Implement plugin injection in Velero addon's GenerateHelmValues to read
    plugins from EmbeddedConfigSpec and append as initContainers
  • Add validation for Velero plugins (duplicate names/images, image format)
  • Fix validateImageFormat to correctly distinguish registry ports from image
    tags (e.g., registry.io:5000/repo/image:tag)
  • Add EmbeddedConfigSpec field to Velero struct to pass config during
    installation/upgrade/restore
  • Add comprehensive unit tests for plugin injection scenarios
  • Update CRD schemas and generated deepcopy methods

The implementation only uses plugins from EmbeddedConfigSpec, following the
existing pattern where EndUserConfigSpec is only used for overrides via
addOnOverrides mechanism.

Example configuration:

  extensions:
    velero:
      plugins:
        - name: velero-plugin-postgresql
          image: myvendor/velero-postgresql:v1.0.0
          imagePullPolicy: Always

Signed-off-by: Evans Mungai [email protected]

Which issue(s) this PR fixes:

sc-131045

Does this PR require a test?

Does this PR require a release note?


Does this PR require documentation?

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]>
Ref: sc-131045

Add ability to configure custom Velero plugins through the Embedded Cluster
config specification. Plugins are injected as initContainers into the Velero
deployment.

Changes:
- Add VeleroPlugin type to ConfigSpec.Extensions.Velero with required Name
  and Image fields, and optional ImagePullPolicy
- Implement plugin injection in Velero addon's GenerateHelmValues to read
  plugins from EmbeddedConfigSpec and append as initContainers
- Add validation for Velero plugins (duplicate names/images, image format)
- Fix validateImageFormat to correctly distinguish registry ports from image
  tags (e.g., registry.io:5000/repo/image:tag)
- Add EmbeddedConfigSpec field to Velero struct to pass config during
  installation/upgrade/restore
- Add comprehensive unit tests for plugin injection scenarios
- Update CRD schemas and generated deepcopy methods

The implementation only uses plugins from EmbeddedConfigSpec, following the
existing pattern where EndUserConfigSpec is only used for overrides via
addOnOverrides mechanism.

Example configuration:
  extensions:
    velero:
      plugins:
        - name: velero-plugin-postgresql
          image: myvendor/velero-postgresql:v1.0.0
          imagePullPolicy: Always

Signed-off-by: Evans Mungai <[email protected]>
@github-actions
Copy link

github-actions bot commented Nov 7, 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-af3f231" -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-af3f231?airgap=true" -H "Authorization: $EC_SMOKE_TEST_LICENSE_ID" -o embedded-cluster-smoke-test-staging-app-ci.tgz

Happy debugging!

@banjoh banjoh force-pushed the evansmungai/sc-131045/add-inject-velero-plugin-to-helm-values branch from be277fe to e40e253 Compare November 10, 2025 15:21
Signed-off-by: Evans Mungai <[email protected]>
Signed-off-by: Evans Mungai <[email protected]>
}

// Inject custom Velero plugins from ConfigSpec before any further processing
if err := v.injectPluginInitContainers(hv, domains); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

why not call this inside helmValues() function above?

}

// validateVeleroPlugins validates Velero plugin configurations
func (v *Validator) validateVeleroPlugins(veleroExt ecv1beta1.VeleroExtensions) []error {
Copy link
Member

Choose a reason for hiding this comment

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

hmm, this seems like something that should exist in the new EC lint code rather than / in addition to here.

return fmt.Errorf("image cannot be empty")
}

// Basic validation: image should not contain invalid characters
Copy link
Member

Choose a reason for hiding this comment

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

why not just use the ReferenceRegexp regex from https://pkg.go.dev/github.com/distribution/reference?

Copy link
Member

@sgalsaleh sgalsaleh left a comment

Choose a reason for hiding this comment

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

Can you please add 3 dryrun tests for:

  • V2 installs
  • V3 headless installs
  • V3 non-headless installs?

For V2 dryrun install tests, the code is at: https://github.com/replicatedhq/embedded-cluster/blob/main/tests/dryrun/install_test.go

For V3 dryrun install tests, the code is at: https://github.com/replicatedhq/embedded-cluster/blob/main/tests/dryrun/v3_install_test.go

You can follow the existing pattern. You'll need to create a custom EC config for these tests that include custom velero plugins in the EC config and only use it for these 3 tests, and verify that the velero helm values are generated correctly.

Signed-off-by: Evans Mungai <[email protected]>
Ref: sc-131045

Add ability to configure custom Velero plugins through the Embedded Cluster
config specification. Plugins are injected as initContainers into the Velero
deployment.

Changes:
- Add VeleroPlugin type to ConfigSpec.Extensions.Velero with required Name
  and Image fields, and optional ImagePullPolicy
- Implement plugin injection in Velero addon's GenerateHelmValues to read
  plugins from EmbeddedConfigSpec and append as initContainers
- Add validation for Velero plugins (duplicate names/images, image format)
- Fix validateImageFormat to correctly distinguish registry ports from image
  tags (e.g., registry.io:5000/repo/image:tag)
- Add EmbeddedConfigSpec field to Velero struct to pass config during
  installation/upgrade/restore
- Add comprehensive unit tests for plugin injection scenarios
- Update CRD schemas and generated deepcopy methods

The implementation only uses plugins from EmbeddedConfigSpec, following the
existing pattern where EndUserConfigSpec is only used for overrides via
addOnOverrides mechanism.

Example configuration:
  extensions:
    velero:
      plugins:
        - name: velero-plugin-postgresql
          image: myvendor/velero-postgresql:v1.0.0
          imagePullPolicy: Always

Signed-off-by: Evans Mungai <[email protected]>
…values' of github.com:replicatedhq/embedded-cluster into evansmungai/sc-131045/add-inject-velero-plugin-to-helm-values
Signed-off-by: Evans Mungai <[email protected]>
Ref: sc-131045

Add ability to configure custom Velero plugins through the Embedded Cluster
config specification. Plugins are injected as initContainers into the Velero
deployment.

Changes:
- Add VeleroPlugin type to ConfigSpec.Extensions.Velero with required Name
  and Image fields, and optional ImagePullPolicy
- Implement plugin injection in Velero addon's GenerateHelmValues to read
  plugins from EmbeddedConfigSpec and append as initContainers
- Add validation for Velero plugins (duplicate names/images, image format)
- Fix validateImageFormat to correctly distinguish registry ports from image
  tags (e.g., registry.io:5000/repo/image:tag)
- Add EmbeddedConfigSpec field to Velero struct to pass config during
  installation/upgrade/restore
- Add comprehensive unit tests for plugin injection scenarios
- Update CRD schemas and generated deepcopy methods

The implementation only uses plugins from EmbeddedConfigSpec, following the
existing pattern where EndUserConfigSpec is only used for overrides via
addOnOverrides mechanism.

Example configuration:
  extensions:
    velero:
      plugins:
        - name: velero-plugin-postgresql
          image: myvendor/velero-postgresql:v1.0.0
          imagePullPolicy: Always

Signed-off-by: Evans Mungai <[email protected]>
Signed-off-by: Evans Mungai <[email protected]>
…values' of github.com:replicatedhq/embedded-cluster into evansmungai/sc-131045/add-inject-velero-plugin-to-helm-values
Signed-off-by: Evans Mungai <[email protected]>
Signed-off-by: Evans Mungai <[email protected]>
…ns' into evansmungai/sc-131045/add-inject-velero-plugin-to-helm-values
Signed-off-by: Evans Mungai <[email protected]>
Signed-off-by: Evans Mungai <[email protected]>
Signed-off-by: Evans Mungai <[email protected]>
Signed-off-by: Evans Mungai <[email protected]>
@banjoh banjoh marked this pull request as ready for review November 13, 2025 15:17
@banjoh
Copy link
Member Author

banjoh commented Nov 13, 2025

Can you please add 3 dryrun tests for:

  • V2 installs
  • V3 headless installs
  • V3 non-headless installs?

For V2 dryrun install tests, the code is at: https://github.com/replicatedhq/embedded-cluster/blob/main/tests/dryrun/install_test.go

For V3 dryrun install tests, the code is at: https://github.com/replicatedhq/embedded-cluster/blob/main/tests/dryrun/v3_install_test.go

You can follow the existing pattern. You'll need to create a custom EC config for these tests that include custom velero plugins in the EC config and only use it for these 3 tests, and verify that the velero helm values are generated correctly.

Done

require.NotEmpty(t, values["initContainers"])
initContainers := values["initContainers"].([]any)

// Find our plugin container
Copy link
Member

Choose a reason for hiding this comment

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

how about asserting the number of plugins is at most 2 same as the test above? same for the tests below

sgalsaleh
sgalsaleh previously approved these changes Nov 13, 2025
Signed-off-by: Evans Mungai <[email protected]>
sgalsaleh
sgalsaleh previously approved these changes Nov 13, 2025
Signed-off-by: Evans Mungai <[email protected]>
@banjoh banjoh merged commit 6bcf33a into main Nov 14, 2025
142 of 146 checks passed
@banjoh banjoh deleted the evansmungai/sc-131045/add-inject-velero-plugin-to-helm-values branch November 14, 2025 06:00
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