Skip to content

Conversation

@ecordell
Copy link
Contributor

@ecordell ecordell commented Jun 5, 2020

The second step in performing a "true" airgapped install required
manual manipulation of the output mapping.txt to properly
mirror.

The source of oc adm catalog mirror is always a catalog image that
has a certain set of image references contained within. When mirroring
these, an ImageContentSourcePolicy and mapping.txt file is generated.

The ICSP always maps the image reference in the catalog to the final
image defined by remapping into the destination registry, so that on
cluster the correct translation can take place.

The mapping.txt file (and the mirroring step performed by oc adm catalog
mirror) always need to map from an existing image to the target image.

When mirroring a catalog to an airgapped cluster, the images need to be
mirrored twice: once to the local filesystem, and once from the local
filesystem.

This commit adds support for a --remap flag which can be passed to
the mirror command. This "remaps" the source image found in the catalog
manifests to another location prior to mirroring, so that multi-stage
mirroring is easy.

For example:

$ oc adm catalog mirror file://rh-ops:1 file://operators --to-manifests=local
$ oc adm catalog mirror file://rh-ops:1 localhost:50000 --remap=./local/mapping.txt

This will mirror images from the external registry to the local fs, and
then again from the local fs to the final registry.

The ICSP generated is unmodified, since it will always need to map from
the images defined in the manifests themselves.

@openshift-ci-robot openshift-ci-robot added the bugzilla/severity-urgent Referenced Bugzilla bug's severity is urgent for the branch this PR is targeting. label Jun 5, 2020
@openshift-ci-robot
Copy link

@ecordell: This pull request references Bugzilla bug 1841885, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.6.0) matches configured target release for branch (4.6.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)
Details

In response to this:

Bug 1841885: Add remapping support for oc adm catalog mirror

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Jun 5, 2020
@openshift-ci-robot
Copy link

@ecordell: This pull request references Bugzilla bug 1841885, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.6.0) matches configured target release for branch (4.6.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)
Details

In response to this:

Bug 1841885: Add remapping support for oc adm catalog mirror

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ecordell ecordell force-pushed the airgap branch 3 times, most recently from 4617e01 to 1765714 Compare June 8, 2020 22:20
@ecordell
Copy link
Contributor Author

ecordell commented Jun 9, 2020

/retest

2 similar comments
@Bowenislandsong
Copy link

/retest

@ecordell
Copy link
Contributor Author

/retest

Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

/hold
There's an ongoing discussion about making oc aware of ICSP, I'd prefer this effort is also aligned with what's being discussed there openshift/enhancements#334 (comment)
@sallyom fyi

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 24, 2020

# Perform an airgapped mirror in two steps:
# mirror the contents of a catalog to local files and save mapping file in ./to-local
%[1]s file://my-catalog:latest file://operators --to-manifests=./to-local
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the src argument here really have the file: prefix? I thought this example was meant to show pulling a remote image my-catalog:latest to file://operators -- am I mistaken?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope you're right - I'll update these docs

%[1]s file://my-catalog:latest file://operators --to-manifests=./to-local

# mirror the contents of a catalog from local files into a target registry using previously calculated mapping file
%[1]s file://my-catalog:latest my-airgapped-registry:5000 --mapping=./rh-ops-manifests/mapping.txt
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is the next step, I would expect the src argument to be file://operators. Am I misunderstanding this command?

Also:

  • where is the rh-ops-manifests directory coming from?
  • is --mapping supposed to be --remap?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, the example is confusing.

where is the rh-ops-manifests directory coming from?

that's supposed to be the output of the previous command - I can make that clearer

is --mapping supposed to be --remap?

yep!

DryRun bool
ManifestOnly bool
DatabasePath string
RemappingFiles []string
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a need to support more than one mapping? If so, we should probably state the merge behavior in the command help.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just did this for parity with with oc image mirror, which takes a list of files: https://github.com/openshift/oc/blob/master/pkg/cli/image/mirror/mirror.go#L174

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 10, 2020
the second step in performing a "true" airgapped install required
manual manipulation of the output mapping.txt and ICSP to properly
mirror.

The source of `oc adm catalog mirror` is always a catalog image that
has a certain set of image references contained within. When mirroring
these, an ImageContentSourcePolicy and mapping.txt file is generated.

The ICSP always maps the image reference in the catalog to the final
image defined by remapping into the destination registry, so that on
cluster the correct translation can take place.

The mapping.txt file (and the mirroring step performed by oc adm catalog
mirror) always need to map from an existing image to the target image.

When mirroring a catalog to an airgapped cluster, the images need to be
mirrored twice: once to the local filesystem, and once from the local
filesystem.

This commit adds support for a `--remap` flag which can be passed to
the mirror command. This "remaps" the source image found in the catalog
manifests to another location prior to mirroring, so that multi-stage
mirroring is easy.

For example:

mirror file://rh-ops:1 file://operators --to-manifests=local
mirror file://rh-ops:1 localhost:50000 --remap=./local/mapping.txt

This will mirror images from the external registry to the local fs, and
then again from the local fs to the final registry.

The ICSP generated is unmodified, since it will always need to map from
the images defined in the manifests themselves.
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 6, 2020
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ecordell
To complete the pull request process, please assign mfojtik after the PR has been reviewed.
You can assign the PR to them by writing /assign @mfojtik in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@smarterclayton
Copy link
Contributor

Generally mirror commands are expected to understand the context of the mapping. I.e. oc adm release mirror understands the disk format from the image, and you can mirror to disk and then back. The --to- argument should be able to infer a reasonable default from disk or the source. If mirror.txt is mappings from source to destination (the format mirror would accept), then it's pretty normal to say the user should use oc image mirror -f mirror.txt to mirror from disk to final destination. But if mirror needs to be changed, then usually that would be where you would have that input be provided back to oc adm catalog mirror

@openshift-ci-robot
Copy link

openshift-ci-robot commented Oct 6, 2020

@ecordell: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/e2e-cmd 94ac86a link /test e2e-cmd

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

`)

Mirroring into an airgapped environment requires two steps: mirroring from the catalog to local files,
and then again from local files into the airgapped registry. See examples ofr the "--remap" flag for more
Copy link
Contributor

Choose a reason for hiding this comment

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

ofr/of
also, I don't see any examples of using --remap flag, you will add those?

@ecordell
Copy link
Contributor Author

ecordell commented Oct 7, 2020

closing in favor of #611

@soltysh
Copy link
Contributor

soltysh commented Oct 9, 2020

closing in favor of #611

/close

@openshift-ci-robot
Copy link

@soltysh: Closed this PR.

Details

In response to this:

closing in favor of #611

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot
Copy link

@ecordell: This pull request references Bugzilla bug 1841885. The bug has been updated to no longer refer to the pull request using the external bug tracker.

Details

In response to this:

Bug 1841885: Add remapping support for oc adm catalog mirror

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugzilla/severity-urgent Referenced Bugzilla bug's severity is urgent for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants