-
Notifications
You must be signed in to change notification settings - Fork 119
Add releaseImageRepo and releaseComponentRepo to ImageSetConfiguration #1452
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
base: main
Are you sure you want to change the base?
Changes from all commits
a59d114
8a6412e
b9223df
05ade39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # Custom Release Repository Paths | ||
|
|
||
| ## Overview | ||
|
|
||
| By default, oc-mirror copies release images to `openshift/release-images` and release component images to `openshift/release` on the destination registry. The `releaseImageRepo` and `releaseComponentRepo` fields in the ImageSetConfiguration allow you to override these destination paths, for example to preserve the original source repository paths. | ||
|
|
||
| ## Configuration | ||
|
|
||
| Add the fields to the `platform` section of your ImageSetConfiguration: | ||
|
|
||
| ```yaml | ||
| apiVersion: mirror.openshift.io/v2alpha1 | ||
| kind: ImageSetConfiguration | ||
| mirror: | ||
| platform: | ||
| releaseImageRepo: "openshift-release-dev/ocp-release" | ||
| releaseComponentRepo: "openshift-release-dev/ocp-v4.0-art-dev" | ||
| channels: | ||
| - name: stable-4.22 | ||
| minVersion: 4.22.0 | ||
| maxVersion: 4.22.0 | ||
| ``` | ||
|
|
||
| | Field | Default | Description | | ||
| |-------|---------|-------------| | ||
| | `releaseImageRepo` | `openshift/release-images` | Destination repository path for release images | | ||
| | `releaseComponentRepo` | `openshift/release` | Destination repository path for release component images | | ||
|
|
||
| Both fields are optional. When omitted, the default paths are used. | ||
|
|
||
| ## Example | ||
|
|
||
| Given the following `imageset-config.yaml`: | ||
|
|
||
| ```yaml | ||
| apiVersion: mirror.openshift.io/v2alpha1 | ||
| kind: ImageSetConfiguration | ||
| mirror: | ||
| platform: | ||
| releaseImageRepo: "openshift-release-dev/ocp-release" | ||
| releaseComponentRepo: "openshift-release-dev/ocp-v4.0-art-dev" | ||
| channels: | ||
| - name: stable-4.22 | ||
| minVersion: 4.22.0 | ||
| maxVersion: 4.22.0 | ||
| ``` | ||
|
|
||
| Run oc-mirror: | ||
|
|
||
| ```bash | ||
| oc-mirror --v2 \ | ||
| --authfile ./pull-secret.json \ | ||
| --config ./isc.yaml \ | ||
| --workspace file:///home/user/oc-mirror-workspace \ | ||
| docker://registry.example.com/mirrors/quay.io | ||
| ``` | ||
|
|
||
| With the default configuration, release images would be copied to: | ||
|
|
||
| ```text | ||
| registry.example.com/mirrors/quay.io/openshift/release-images:4.22.0-x86_64 | ||
| registry.example.com/mirrors/quay.io/openshift/release:4.22.0-x86_64-<component> | ||
| ``` | ||
|
|
||
| With the overrides above, they are instead copied to: | ||
|
|
||
| ```text | ||
| registry.example.com/mirrors/quay.io/openshift-release-dev/ocp-release:4.22.0-x86_64 | ||
| registry.example.com/mirrors/quay.io/openshift-release-dev/ocp-v4.0-art-dev:4.22.0-x86_64-<component> | ||
| ``` | ||
|
|
||
| ## IDMS Configuration | ||
|
|
||
| With the original source paths preserved on the mirror, a single `ImageDigestMirrorSet` entry can cover all of `quay.io`: | ||
|
|
||
| ```yaml | ||
| apiVersion: config.openshift.io/v1 | ||
| kind: ImageDigestMirrorSet | ||
| metadata: | ||
| name: quay-io-mirror | ||
| spec: | ||
| imageDigestMirrors: | ||
| - source: quay.io | ||
| mirrors: | ||
| - registry.example.com/mirrors/quay.io | ||
| mirrorSourcePolicy: NeverContactSource # optional, for fully disconnected environments | ||
| ``` | ||
|
|
||
| Because the mirrored paths match the source paths, every image under `quay.io/` is automatically resolved to `registry.example.com/mirrors/quay.io/` with no per-repository mappings needed. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,69 @@ | ||
| # Mirror OKD | ||
|
|
||
| To pass signatures verification when trying to mirror OKD images, you need to set the following env variables: | ||
| - OCP_SIGNATURE_URL="https://storage.googleapis.com/openshift-ci-release/releases/signatures/openshift/release/" | ||
| - OCP_SIGNATURE_VERIFICATION_PK="/path/to/PK" (recovered from "https://raw.githubusercontent.com/openshift/cluster-update-keys/master/keys/verifier-public-key-openshift-ci-4") | ||
| ## Signature Verification | ||
|
|
||
| To pass signature verification when mirroring OKD images, set the following environment variables: | ||
|
|
||
| ```bash | ||
| export OCP_SIGNATURE_URL="https://storage.googleapis.com/openshift-ci-release/releases/signatures/openshift/release/" | ||
| export OCP_SIGNATURE_VERIFICATION_PK="/path/to/verifier-public-key-openshift-ci-4" | ||
| ``` | ||
|
|
||
| The public key can be retrieved from https://raw.githubusercontent.com/openshift/cluster-update-keys/master/keys/verifier-public-key-openshift-ci-4 | ||
|
|
||
| Alternatively, use `--ignore-release-signature` to skip release signature verification. | ||
|
|
||
| ## Basic Configuration | ||
|
|
||
| OKD channels follow a different naming convention than OCP. Releases are listed at https://origin-release.ci.openshift.org, but note that the channel names differ from the website headings: | ||
|
|
||
| | Website heading | Channel name | | ||
| |-----------------|--------------| | ||
| | 4-scos-stable | `stable-4-scos` | | ||
| | 4-scos-next | `next-4-scos` | | ||
| | 5-scos-next | `next-5-scos` | | ||
|
|
||
| The `type: okd` field must be set. | ||
|
|
||
| ```yaml | ||
| --- | ||
| apiVersion: mirror.openshift.io/v2alpha1 | ||
| kind: ImageSetConfiguration | ||
| mirror: | ||
| platform: | ||
| graph: false | ||
| channels: | ||
| - name: 4-stable | ||
| minVersion: 4.18.0-okd-scos.8 | ||
| maxVersion: 4.18.0-okd-scos.8 | ||
| type: okd | ||
| ``` | ||
| - name: stable-4-scos | ||
| minVersion: 4.18.0-okd-scos.8 | ||
| maxVersion: 4.18.0-okd-scos.8 | ||
| type: okd | ||
| ``` | ||
|
|
||
| ## Custom Repository Paths | ||
|
|
||
| By default, OKD release images are copied to `openshift/release-images` and component images to `openshift/release` on the destination registry. Use `releaseImageRepo` and `releaseComponentRepo` to override these paths, for example to match the source repository layout: | ||
|
|
||
| ```yaml | ||
| mirror: | ||
| platform: | ||
| releaseImageRepo: "okd/scos-release" | ||
| releaseComponentRepo: "okd/scos-content" | ||
| channels: | ||
| ... | ||
| ``` | ||
|
|
||
| Run oc-mirror: | ||
|
|
||
| ```bash | ||
| oc-mirror --v2 \ | ||
| --authfile ./pull-secret.json \ | ||
| --config ./imageset-config.yaml \ | ||
| --workspace file:///home/user/oc-mirror-workspace \ | ||
| docker://registry.example.com/mirrors/quay.io | ||
| ``` | ||
|
|
||
| With the overrides above, images are copied to: | ||
|
|
||
| ``` | ||
| registry.example.com/mirrors/quay.io/okd/scos-release:4.18.0-okd-scos.8 | ||
| registry.example.com/mirrors/quay.io/okd/scos-content:4.18.0-okd-scos.8-<component> | ||
| ``` |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -708,6 +708,10 @@ http: | |||||||||
| // setupLocalStorage - private function that sets up | ||||||||||
| // a local (distribution) registry | ||||||||||
| func (o *ExecutorSchema) setupLocalStorage(ctx context.Context) error { | ||||||||||
| // distribution/distribution parses all REGISTRY_* env vars as config overrides, | ||||||||||
| // colliding with the Podman/containers REGISTRY_AUTH_FILE convention. | ||||||||||
| // The value has already been captured as the --authfile default (options.go). | ||||||||||
| os.Unsetenv("REGISTRY_AUTH_FILE") | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win Handle
As per path instructions, "**/*.go: Go security (prodsec-skills): - Never ignore error returns". Proposed fix- os.Unsetenv("REGISTRY_AUTH_FILE")
+ if err := os.Unsetenv("REGISTRY_AUTH_FILE"); err != nil {
+ return fmt.Errorf("unset REGISTRY_AUTH_FILE: %w", err)
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI AgentsSource: Path instructions |
||||||||||
| config, err := o.setupLocalRegistryConfig() | ||||||||||
| if err != nil { | ||||||||||
| o.Log.Error("parsing config %v", err) | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -337,6 +337,15 @@ func (o *LocalStorageCollector) prepareGraphImage(ctx context.Context) (v2alpha1 | |
| } | ||
|
|
||
| func (o LocalStorageCollector) prepareM2DCopyBatch(images []v2alpha1.RelatedImage, releaseTag string) ([]v2alpha1.CopyImageSchema, error) { | ||
| releaseImagePath := releaseImagePathComponents | ||
| if o.Config.Mirror.Platform.ReleaseImageRepo != "" { | ||
| releaseImagePath = o.Config.Mirror.Platform.ReleaseImageRepo | ||
| } | ||
| releaseComponentPath := releaseComponentPathComponents | ||
| if o.Config.Mirror.Platform.ReleaseComponentRepo != "" { | ||
| releaseComponentPath = o.Config.Mirror.Platform.ReleaseComponentRepo | ||
| } | ||
|
|
||
| result := make([]v2alpha1.CopyImageSchema, 0, len(images)) | ||
| for _, img := range images { | ||
| var src string | ||
|
|
@@ -348,7 +357,7 @@ func (o LocalStorageCollector) prepareM2DCopyBatch(images []v2alpha1.RelatedImag | |
| } | ||
| src = imgSpec.ReferenceWithTransport | ||
|
|
||
| pathComponents := preparePathComponents(imgSpec, img.Type, img.Name) | ||
| pathComponents := preparePathComponents(imgSpec, img.Type, img.Name, releaseImagePath, releaseComponentPath) | ||
| tag := prepareTag(imgSpec, img.Type, releaseTag, img.Name) | ||
|
|
||
| dest = consts.DockerProtocol + strings.Join([]string{o.destinationRegistry(), pathComponents + ":" + tag}, "/") | ||
|
|
@@ -361,6 +370,15 @@ func (o LocalStorageCollector) prepareM2DCopyBatch(images []v2alpha1.RelatedImag | |
| } | ||
|
|
||
| func (o LocalStorageCollector) prepareD2MCopyBatch(images []v2alpha1.RelatedImage, releaseTag string) ([]v2alpha1.CopyImageSchema, error) { | ||
| releaseImagePath := releaseImagePathComponents | ||
| if o.Config.Mirror.Platform.ReleaseImageRepo != "" { | ||
| releaseImagePath = o.Config.Mirror.Platform.ReleaseImageRepo | ||
| } | ||
| releaseComponentPath := releaseComponentPathComponents | ||
| if o.Config.Mirror.Platform.ReleaseComponentRepo != "" { | ||
| releaseComponentPath = o.Config.Mirror.Platform.ReleaseComponentRepo | ||
| } | ||
|
|
||
|
Comment on lines
+373
to
+381
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is duplicated |
||
| result := make([]v2alpha1.CopyImageSchema, 0, len(images)) | ||
| for _, img := range images { | ||
| var src string | ||
|
|
@@ -371,7 +389,7 @@ func (o LocalStorageCollector) prepareD2MCopyBatch(images []v2alpha1.RelatedImag | |
| return nil, err | ||
| } | ||
|
|
||
| pathComponents := preparePathComponents(imgSpec, img.Type, img.Name) | ||
| pathComponents := preparePathComponents(imgSpec, img.Type, img.Name, releaseImagePath, releaseComponentPath) | ||
| tag := prepareTag(imgSpec, img.Type, releaseTag, img.Name) | ||
|
|
||
| src = consts.DockerProtocol + strings.Join([]string{o.LocalStorageFQDN, pathComponents + ":" + tag}, "/") | ||
|
|
@@ -581,15 +599,15 @@ func (o LocalStorageCollector) handleGraphImage(ctx context.Context) (v2alpha1.C | |
| } | ||
| } | ||
|
|
||
| func preparePathComponents(imgSpec image.ImageSpec, imgType v2alpha1.ImageType, imgName string) string { | ||
| func preparePathComponents(imgSpec image.ImageSpec, imgType v2alpha1.ImageType, imgName string, releaseImagePath, releaseComponentPath string) string { | ||
| pathComponents := "" | ||
| switch { | ||
| case imgType == v2alpha1.TypeOCPRelease: | ||
| pathComponents = releaseImagePathComponents | ||
| pathComponents = releaseImagePath | ||
| case imgType == v2alpha1.TypeCincinnatiGraph: | ||
| pathComponents = imgSpec.PathComponent | ||
| case imgType == v2alpha1.TypeOCPReleaseContent && imgName != "": | ||
| pathComponents = releaseComponentPathComponents | ||
| pathComponents = releaseComponentPath | ||
| case imgSpec.IsImageByDigestOnly(): | ||
| pathComponents = imgSpec.PathComponent | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.