Giter Club home page Giter Club logo

oc-mirror's Introduction

oc-mirror

oc-mirror is an OpenShift Client (oc) plugin that manages OpenShift release, operator catalog, helm charts, and associated container images for mirror registries that support OpenShift environments.

Usage

asciicast

The mirror registry reg.mirror.com is used in this example. Replace this value with a real registry host, or create a docker.io/library/registry:2 container locally.\

DISCLAIMER: oc-mirror is not compatible with Quay below version 3.6.

Configuration Examples

Example configurations can be found in the docs here

Environment Prep

  1. Download pull secret and place at ~/.docker/config.json1.
    • Your mirror registry secret must have both push and pull scopes.
  2. Build:
    make build

Building the ImageSet Config

Backends

IMPORTANT: Backends must be configured to utilize the lifecycle management features of oc-mirror. Examples are below.

apiVersion: mirror.openshift.io/v1alpha2
kind: ImageSetConfiguration
archiveSize: 1
storageConfig:
  local:
    path: /home/user/workspace
apiVersion: mirror.openshift.io/v1alpha2
kind: ImageSetConfiguration
storageConfig:
  registry:
    imageURL: localhost:5000/metadata:latest
    skipTLS: true

Lifecycle Management

There is a common misconception that oc-mirror is only a container image mirroring utility. This is partially accurate. In addition to image mirroring, oc-mirror optionally performs content deletions from mirror registries. When content is added to an imageset configuration, that content is published to a mirror registry. When content is removed from an imageset configuration, that content is removed from the mirror registry. This ensures that content is safely removed from the mirror registry when the user specifies.

If a user does not desire content removal from a mirror registry, they can either not remove that content from their imageset configuration or they can publish using a registry account that does not have permissions to perform content deletions. If a user chooses to disallow pruning using an account without permission to perform deletions, the --continue-on-error flag must be used in conjunction with the publishing operation to the mirror registry.

Content Discovery

Updates

  • List updates since the last oc-mirror run
    ./bin/oc-mirror list updates imageset-config.yaml

Releases

  1. List all available release payloads for a version of OpenShift (defaults to stable)
    ./bin/oc-mirror list releases --version=4.9
  2. List all available channels to query for a version of OpenShift
    ./bin/oc-mirror list releases --channels --version=4.9
  3. List all available release payloads for a version of OpenShift in a specified channel
    ./bin/oc-mirror list releases --channel=fast-4.9

Operators

  1. List all available catalogs for a version of OpenShift
    ./bin/oc-mirror list operators --catalogs --version=4.9
  2. List all available packages in a catalog
    ./bin/oc-mirror list operators --catalog=catalog-name
  3. List all available channels in a package
    ./bin/oc-mirror list operators --catalog=catalog-name --package=package-name
  4. List all available versions in a channel
    ./bin/oc-mirror list operators --catalog=catalog-name --package=package-name --channel=channel-name

Mirroring

Note: These workflows are compatible and can be used interchangeably for the same mirror registry.

Note: oc-mirror metadata is always stored where specified by the user and in an expected location managed by oc-mirror (always "registry/namespace/oc-mirror:UUID). This allows a user to seamlessly switch between a fully-disconnected workflow and a partially disconnected workflow.

Fully Disconnected

  • Create then publish to your mirror registry:
    ./bin/oc-mirror --config imageset-config.yaml file://archives
    ./bin/oc-mirror --from /path/to/archives docker://reg.mirror.com

Partially Disconnected

  • Publish mirror to mirror
    ./bin/oc-mirror --config imageset-config.yaml docker://localhost:5000

Additional Features

  • Get information on your imageset using describe
    ./bin/oc-mirror describe /path/to/archives
  • List updates since last run for releases and operators
    ./bin/oc-mirror list updates imageset-config.yaml

For configuration and options, see the expanded overview and usage docs.

1 For this example, the create and publish steps are run on the same machine. Therefore your ~/.docker/config.json or ${XDG_RUNTIME_DIR}/containers/auth.json should contain auth config for both release/catalog source images and your mirror registry.

oc-mirror Spec

See the config spec for an in-depth description of fields.

Note: The imageset-config.yaml is only used during bundle creation.

Development

Requirements

  • All top-level requirements
  • go version 1.17+

Build

make
./bin/oc-mirror -h

Note: Using oc-mirror init with local builds may result in unexpected release channel names.

Test

Unit:

make test-unit

E2E:

make test-e2e

oc-mirror's People

Contributors

afflom avatar aguidirh avatar badgerops avatar cchen666 avatar d10n avatar david-rh avatar dinhxuanvu avatar dmesser avatar estroz avatar ianwatsonrh avatar jchunkins avatar jeffdyoung avatar jharmison-redhat avatar jpower432 avatar kartikey-star avatar lalatendumohanty avatar leo8a avatar lmzuccarelli avatar openshift-bot avatar openshift-merge-robot avatar pawicao-ibm avatar pratikmahajan avatar prb112 avatar redhatdan avatar sfxworks avatar sherine-k avatar siegy22 avatar soltysh avatar tsmetana avatar usrbinkat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

oc-mirror's Issues

operator catalog diffs are not built into images nor combined with disconnected catalogs

When I run create full with a config that has headsOnly: true for some catalog, or create diff, I expect that diff to be mirrored to disk as an image. I also expect publish to combine that diff with an existing catalog image (pulled from data in a CatalogSource) and pushed to the catalog's registry under a desired tag (defaulting to the tag from the existing catalog image).

Currently this functionality is broken/does not exist. Since opm diff libraries only generate an file-based catalog, a new image must be built containing this file then mirrored. The same needs to happen during publish, but with the output of opm render <existing catalog image> <mirrored diff catalog image>.

Handle metadata (rough)

  • If no metadata found, start new
  • If metadata found, load last imageset and append new run to the existing imageset

Install ICSP/CatalogSource Files

This is a delicate procedure. We need to make sure that we nail the logic on this. The logic needs to be clarified, but this is a rough guess:

  1. patch override operator hub
  2. update icmp for ocp releases, images referenced in the catalogs, and other arbitrary images in the imageset.
  3. check installed operator versions and verify upgrade path to new catalog. Error if operators will become orphaned.
  4. once operators are upgradable to new catalog version, upgrade ocp
  5. patch override operator hub
  6. upgrade operators from new catalog version

For the record, I am not saying that we should be triggering cluster upgrades from this application. Also, some of this might be handled by CVO or OLM. So some of this might not be handled by this app, but some of these objects need to be managed by us.

Create and Publish Optimization: Disk space

Disk space optimization:

  • Remove files as they being processed.
  • For create this would be as they are being archived
  • For publish this would be as the images are being pushed to the registry one at a time and files are pulled from the archives as needed
    Note: Limitation include symlink tracking and unarchiving. We need to capture symlink information in the associations during the create process.

feat(mirror): support operator package and version selection

Allow for more granular control when declaring operators to be downloaded. Allow operator downloads to be optionally selected by individual name and optionally selected by semver. If no semver, the selected named download should behave as expected with headsonly.

Add Stale Bot

Help us feel better about closing tickets that we wont work on.

Feat: Add a new command to do a imageset describe

I want to add a new command to do a describe on a particular imageset.
It will parse the metadata and output into a human readable format so users can verify their bundles before they publish if needed to troubleshoot any bundle sequence issues.

oc-bundle publish duplicates an uncompressed archive?

The size of the generated tar-ball is immense -- 100+GB. Duplicating it to disk before running the publish seems a big waste. Suggest processing the file without extracting to disk first, or extract small portions, process, and delete the temporary files, and continue with the next set of files.

Chore: Logging Cleanup

  • clarify and cleanup comments
  • comment exported items
  • Clean up logging and get better log level categorization of certain messages. (Need more info messages and need to fix log file output)

Duplicate File Paths

The path that operators are downloaded to includes a duplication of paths as seen here:

file://redhat/redhat-operator-index/redhat/redhat-operator-index/rhscl/postgresql-10-rhel7

The path needs to be deduplicated.

Consolidate create functions

It might make more sense to combine create full and create diff into a single function called create. The behavior of the app would be determined by the state of the metadata. If a new imageset (create full) is desired, then a new workspace would be specified. This would reduce cli complexity and provide a similar experience to publish.

Handle multiple credentials

  • Load registry pull secrets from imageset-config.
  • Handle multiple credential strings (multiple registries)

background: Allow users to add separate registry credentials instead of editing serialized json in the red hat pull secret.

e2e test improvement

  1. Improve error identification (currently not failing on oc errors)
  2. add release/additional image testing (currently only tests operators)

ability to install via: go install

I think go install is a pretty well-known/standard approach. but currently, if I do that I get:

$ go install github.com/RedHatGov/bundle@latest
go: downloading github.com/RedHatGov/bundle v0.1.0-alpha.1
go install github.com/RedHatGov/bundle@latest: module github.com/RedHatGov/bundle@latest found (v0.1.0-alpha.1), but does not contain package github.com/RedHatGov/bundle

create: enable image blocking

I want the ability to block and image, ex. alpine, and all images that depend on a blocked image's layer(s) with a warning log.

Add Helm support

Add support for helm charts and associated images:

  • as a imageset-config key under mirror.
  • Default to latest for charts if version is not specified.
  • Pack the chart in the imageset with it's associated images.
  • Output mirrored charts in sub-directories with the icsp/catalog source manifests
  • include chart image references in icsps

Handle Blocked images

Prevent blocked images from being downloaded when declared in additionalImages and operators

"uploading: file" when downloading?

During the first "oc-bundle create full" run, when a given version of OCP is downloaded, the text/prompt is "uploading": uploading:

file://openshift/release sha256:2e41ca5fb22b44b82ce7d08e7436d0965776843a45bcdcf5fc2a38fafe4f027b 9.534MiB
uploading: file://openshift/release sha256:ae411670fc26c36fee9fd1232139e051b31ebbed7b411f22dc21fd153ff06456 85.64MiB
uploading: file://openshift/release sha256:8795e1eff4a91cb42c085fd44ce7724e42b5f536da218a88bcbe5d23b3376eda 103.5MiB
uploading: file://openshift/release sha256:917fc69dd02cce554468e1bce0969c5dc133ba8a0427d08626fd7a3cd461faa1 28.61MiB
uploading: file://openshift/release sha256:fdae22ebfdbf3ab549eeabe88fcf4d14df92758a6d0080989af85810afdbff00 515.6KiB

I would expect downloading and not uploading in this context?

Output of create diff does not update imageset file name

When running create full, the output imageset name is bundle_000000.tar

When running create diff in the same workspace, the output imageset name is the same (bundle_000000.tar).

As a user, I would expect the name of the imageset to reflect the sequence number of the creation.

Add release refs to generated icsps

Use Case:

ImageSourceContentPolicies need to be generated for releases in the event that a cluster would go from connected to disconnected.

Problen:

Currently oc release mirror only produces a mapping to the tagged symlinks on disk.

Solution:

To allow ICSP to be generate we need to get the link target information and manipulate the mapping before the Associations are gathered.

Generate ICSP/CatalogSource files

Generate ICMP/CatalogSource files for the following:

  • Release images
  • operator images as per catalog version
  • additional images as needed

Dev Tooling Init

  • Create basic CI for linting/validation
  • Create contributing page

Handle corrupted images for a re-entrant CLI

If oc-bundle exits during an image download, a partially downloaded layer/image may cause a crash in a subsequent oc-bundle run that attempts to start from where the previous run exited. The command should be "smart" enough to clean up these images and restart the download from the previous run's exit point, or at the very least not crash.

Remove Run() calls to oc

bundle inherits a lot of logic from oc for handling releases and operators. It also uses the registry client from oc mirror for general container image mirroring. The most of the pieces that we needed from oc were unexported, so we resorted to calling Run() from each applicable oc package. By using the Run function from the oc imports, we lose control over logging output, stdout/err, and any other behavior that we want to program into the process.

Remove the Run() calls to oc imports and either use internal logic for or PR oc to export the needed pieces for reuse here.

Add bundle archiving to accomodate full and differential bundles

Requirements:

Full

  • Must create a full archive that is segmented per user define MB size
  • Upon writing a file to the archive it must write an empty file to bundle/

Diff

  • Must create on archive and pull in existing bundle data
  • Must be set to NOT overwrite
  • Pull in each file under source
  • Segment from there

Optional, but nice to have:

  • Bundle verification stronger than GZIP CRC

File name too long "create full"

Running an initial "create full" that includes ubi8, I get a "FATAL error creating image resolver: /config.json" where "" is the content of the pull secret in the imageset-config file. I have the following option in the additionalimages:

  additionalimages:
    - name: registry.redhat.io/ubi8/ubi:latest

Since the pull secret is long and shouldn't be included here, I'll just enclose the few lines before the error happens:

info: Planning completed in 2.59s
sha256:038b03c6db9a6484c7328c33eac4cb7b4d9f64a5a74c3849add4b000222f20c4 file://registry.redhat.io/ubi8/ubi
sha256:ba6956f6fabe47ecee824470fa3e3886e563c7b0e4a5240fe96effe559396234 file://registry.redhat.io/ubi8/ubi
sha256:4ce314c597d03077198d51cdf0421d567234bb559e912b89fbbbfa87ed67dc1f file://registry.redhat.io/ubi8/ubi
sha256:08117490cf2a61a85d560f87a5dac3516c043dc092319880f3874b6b6982e71b file://registry.redhat.io/ubi8/ubi
sha256:7254254afafd44c850940445c0480e449fea73a169aa067389252fef35bd7a3f file://registry.redhat.io/ubi8/ubi:latest
info: Mirroring completed in 0s (0B/s)
FATAL error creating image resolver: {"auths":{"cloud.openshift.com"......................

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.