-
Notifications
You must be signed in to change notification settings - Fork 9
PKO-275 Add documentation for Global Image Prefix Override feature #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
erdii
merged 6 commits into
package-operator:main
from
avollmer-redhat:feature/global-prefix-override-docs
Sep 8, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9b0deb7
PKO-275 Add documentation for Global Image Prefix Override feature
avollmer-redhat 7971c25
PKO-275 revised comment on review of documentation for Global Image P…
avollmer-redhat b69126a
docs(global-prefix-override): clarify feature description and fixed r…
avollmer-redhat 594b9d7
Update content/en/docs/advanced_features/global-prefix-override.md
erdii 66d55e5
Update content/en/docs/advanced_features/global-prefix-override.md
erdii 43aaa24
Update content/en/docs/advanced_features/global-prefix-override.md
erdii File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
97 changes: 97 additions & 0 deletions
97
content/en/docs/advanced_features/global-prefix-override.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| --- | ||
| title: Global Image Prefix Override | ||
| weight: 2001 | ||
| --- | ||
|
|
||
| The Global Image Prefix Override feature allows using mirrored package and workload images from a private registry without needing to rebuild the images with new image references. | ||
|
|
||
| This feature solves the problem of mirroring upstream images while preserving their original deployment manifests, all without relying on the Package Operator's internal image digest feature. | ||
|
|
||
| For example, this enables deployment of upstream package-operator artifacts from private registries without rebuilding them in downstream pipelines. This solves the previously impossible scenario where organizations needed to mirror upstream images, because PKO's internal image digest feature insist on referencing images by their original address. | ||
|
|
||
| ## Implementation | ||
|
|
||
| Prefix overrides can be configured through either of these options supplied to the `package-operator-manager` binary: | ||
| - Environment variable: `PKO_IMAGE_PREFIX_OVERRIDES` | ||
| - Command-line flag: `image-prefix-overrides` | ||
|
|
||
| Both accept mappings in `from=to` format (e.g., `quay.io/my-org/=mirror.example.com/mirror-org/`). A comma separataed list in the same format can also be provided for multiple overrides. When Package Operator encounters an image reference starting with the `from` prefix, it automatically substitutes it with the `to` prefix while preserving the remainder of the image path. | ||
|
|
||
| ## Usage Example | ||
|
|
||
| The following `mirror.sh` script demonstrates the mirroring of the images and the modification of the bootstrap job manifests. (Images for version v1.82.2 are mirrored from the registry namespace `quay.io/package-operator` into the registry namespace `quay.io/erdii-test/pko-mirror`). | ||
|
|
||
| ```bash | ||
| #!/bin/bash | ||
| set -euxo pipefail | ||
|
|
||
| # Mirror upstream images to private registry | ||
| skopeo copy --all \ | ||
| docker://quay.io/package-operator/package-operator-package:v1.18.2 \ | ||
| docker://quay.io/erdii-test/pko-mirror/package-operator-package:v1.18.2 | ||
|
|
||
| skopeo copy --all \ | ||
| docker://quay.io/package-operator/package-operator-manager:v1.18.2 \ | ||
| docker://quay.io/erdii-test/pko-mirror/package-operator-manager:v1.18.2 | ||
|
|
||
| skopeo copy --all \ | ||
| docker://quay.io/package-operator/remote-phase-manager:v1.18.2 \ | ||
| docker://quay.io/erdii-test/pko-mirror/remote-phase-manager:v1.18.2 | ||
|
|
||
| # Download original bootstrap manifest | ||
| curl -LO https://github.com/package-operator/package-operator/releases/download/v1.18.2/self-bootstrap-job.yaml | ||
|
|
||
| # Apply global prefix override | ||
| yq -i 'with( | ||
| select(.kind == "Job").spec.template.spec.containers[] | ||
| | select(.name == "package-operator").env[] | ||
| | select(.name == "PKO_IMAGE_PREFIX_OVERRIDES") | ||
| ; .value = "quay.io/package-operator/=quay.io/erdii-test/pko-mirror/" | ||
| )' self-bootstrap-job.yaml | ||
|
|
||
| # Update direct image references | ||
| yq -i 'with( | ||
| select(.kind == "Job").spec.template.spec.containers[] | ||
| | select(.name == "package-operator") | ||
| ; ( | ||
| .image |= sub("quay.io/package-operator", "quay.io/erdii-test/pko-mirror"), | ||
| .args[0] |= sub("quay.io/package-operator", "quay.io/erdii-test/pko-mirror") | ||
| ) | ||
| )' self-bootstrap-job.yaml | ||
| ``` | ||
|
|
||
| ## Key Components Explained | ||
|
|
||
| ### Image Mirroring: | ||
| The `skopeo copy` commands create identical copies of all upstream PKO package images in your private registry, maintaining the original tags and manifests. | ||
|
|
||
| ### Prefix Override Injection: | ||
| The first `yq` command modifies the PKO_IMAGE_PREFIX_OVERRIDES environment variable to redirect all PKO package image pulls from quay.io/package-operator/ to quay.io/erdii-test/pko-mirror/ | ||
| while additionally rewriting the prefixes of the templated image address outputs of the [image digest feature](https://github.com/package-operator/website/blob/904d2c0a90d53e01ed59b602181d47b314925b8b/content/en/docs/guides/image-digests.md). Example template directive: {{.images.someNamedImage}} | ||
|
|
||
| The pattern `original-prefix/=new-prefix/` ensures complete prefix substitution while preserving image names and tags | ||
|
|
||
| ### Direct Reference Updates: | ||
| The second `yq` command handles hardcoded image references that bypass the prefix override mechanism by: | ||
|
|
||
| Modifying the container's `.image` field | ||
| Updating the first command-line argument in .args[0] | ||
|
|
||
| To ensure that all artifacts required for PKO's bootstrap procedure are pulled correctly , it is required to reference the bootstrap job workload image directly from the mirrored location. | ||
|
|
||
| The package image location also gets replaced for readability reasons. | ||
|
|
||
| # Deployment Process | ||
|
|
||
| ## 1. Apply the prepared manifest on the target cluster: | ||
| ```kubectl apply -f self-bootstrap-job.yaml``` | ||
|
|
||
| ## 2. Monitor progress until the ClusterPackage CRD becomes available | ||
avollmer-redhat marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ## 3. Verification: | ||
| ``` | ||
| # Verify package image source | ||
| kubectl get clusterpackage package-operator -o yaml | yq .spec.image | ||
|
|
||
| # Confirm manager deployment uses mirrored images | ||
| kubectl get -n package-operator-system deployment/package-operator-manager -o yaml | yq '.spec.template.spec.containers[].image' | ||
| ``` | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.