feat: add webhooks for crossplane resources to zarf-agent #2574
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This Implements the Crossplane resources
to rewrite the spec.package and spec.packagePullSecrets field in a similar way as for Pod.
This allows the Crossplane Pod to pull the images from the local registry.
Well... not quite yet. This also implements an extension of the private-registry secret, which is created for namespaces managed by zarf. additionally to the localhost reference to the registry this also adds the same credentials for the route over the kubernetes service.
This implementation rewrites
into
which will by default create a pod like this:
The resulting Pod is a bit of a problem. Since when
https://github.com/defenseunicorns/zarf/blob/0c02643b9f5631a7bdd98650cc87c74901190771/src/internal/agent/hooks/pods.go#L76
is called the function does just replace the hostname.
I could not yet find a nice way to implement this, as the const i would need is in
https://github.com/Avarei/zarf/blob/13a7957b46a0dcacb9baa63d7826f42ea44915d7/src/types/k8s.go#L51
and the package surrounding
https://github.com/defenseunicorns/zarf/blob/0c02643b9f5631a7bdd98650cc87c74901190771/src/pkg/transform/image.go#L27
seems to avoid this kind of external dependency. and i would like to avoid negatively impacting your code quality.
Currently I sidestep this issue by creating a DeploymentRuntimeConfig in Crossplane which lets me overwrite the used image back to the internet version, which will be replaced back to the localhost version when the Pod is created.
Related Issue
Fixes #2572
Checklist before merging