Skip to content
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

[OCPNODE-521] Add CRD ImageDigestMirrorSet and ImageTagMirrorSet #1126

Merged
merged 1 commit into from
Mar 15, 2022

Conversation

QiWang19
Copy link
Member

@openshift-ci openshift-ci bot requested review from jwforres and mfojtik February 28, 2022 19:07
@QiWang19 QiWang19 force-pushed the mirrorset branch 2 times, most recently from 430b766 to ca942a5 Compare February 28, 2022 20:16
@QiWang19 QiWang19 changed the title Add CRD ImageDigestMirrorSet and ImageTagMirrorSet [OCPNODE-521] Add CRD ImageDigestMirrorSet and ImageTagMirrorSet Feb 28, 2022
@QiWang19
Copy link
Member Author

@umohnani8 @mrunalp PTAL

pattern: ^((?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])(?:(?:\.(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]))+)?(?::[0-9]+)?)(?:(?:/[a-z0-9]+(?:(?:(?:[._]|__|[-]*)[a-z0-9]+)+)?)+)?$
x-kubernetes-list-type: set
neverContactSource:
description: When enabled, prevents image pull from the specified repository in the pull spec if the image pull form the mirror list fails. Default is false, the image will continue to be pulled from the pull spec if the image can not be pulled from the mirror list. neverContactSource is valid configuration only when one or more mirrors are in the mirror list.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is pull spec the same as the source here? I think to the blear we should say something like prevents image pull from the source registry if all mirrors fail
@mtrmac wdyt?

Copy link
Member Author

@QiWang19 QiWang19 Mar 6, 2022

Choose a reason for hiding this comment

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

The source here is probably a regex, something like prevents image pull from the pull spec that matches the source?

Copy link
Contributor

Choose a reason for hiding this comment

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

The rest of the CR documentation seems to fairly consistently say something like “from the repository specified in the pull spec”, so this should be consistent.

(In other documents we talk about source or primary locations; this CR doesn’t seem to use that terminology right now. I don’t very much care what the name is, but it should be consistent.)

Copy link
Contributor

Choose a reason for hiding this comment

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

(And just for the record, the source is a repo or repo namespace, or a wild-carded host name pattern, as documented in the comments; it is never a regex. Though the general point that we might not be pulling from exactly the Source string value is completely correct.)

@QiWang19 QiWang19 force-pushed the mirrorset branch 2 times, most recently from 8f3df92 to d5b530a Compare March 6, 2022 01:46
@QiWang19
Copy link
Member Author

QiWang19 commented Mar 6, 2022

@mtrmac PTAL.

// https://github.com/containers/image/blob/main/docs/containers-registries.conf.5.md#choosing-a-registry-toml-table
// +optional
// +listType=set
Mirrors []Mirrors `json:"mirrors,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Is my registry authentication presented to these mirrors? Given multiple possible tokens, are tokens tried against each mirror first or is a single token tried against all mirrors first?

Copy link
Member Author

Choose a reason for hiding this comment

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

tokens tried against each mirror. The order of mirrors in this mirrors list is the desired order. The mirrors will be tried in this order, if you have multiple tokens including the token for the current pulling mirror, the token will be used to access the mirror.

Copy link
Contributor

Choose a reason for hiding this comment

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

All of these mirrors configurations are invisible to Kubelet, and the CRI (the Kubelet / CRI-O API) does not currently allow passing credentials for multiple registries.

So, what happens is that the Kubelet reads the Pod’s pull secret, if any, and extracts the credentials only matching source, and provides them in the CRI API. If the Pod’s pull secret contains any credentials for mirrors, those are completely ignored. CRI-O uses the CRI-provided credentials to contact the source only; for mirrors, it uses credentials available in the node-global config.json (in OpenShift, that’s the global cluster pull secret).


(IIRC, if the Pod’s pull secret(s) contain multiple sets of credentials for the same registry, Kubelet tries the pull operation, with each credential. So, in that case, we would try all of the credentials for the source registry; but the mirrors, if any, would all use the global cluster pull secret, repeatedly on each of those retries.)


(The inability of the user to provide mirror credentials via a pod’s pull secret is a known limitation of the mirroring mechanism, and nothing changes about that with this enhancement / these API changes.)


// SourcePolicy defines the fallback policy if fails to pull image from the mirrors.
// +kubebuilder:validation:Enum=sourceNever;sourceLast
type SourcePolicy string
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking: SourcePolicy feels a bit too generic of a name to use within the wide scope of of config/v1 . MirrorSourcePolicy at least? ImageMirrorSourceAccess?

pattern: ^((?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])(?:(?:\.(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]))+)?(?::[0-9]+)?)(?:(?:/[a-z0-9]+(?:(?:(?:[._]|__|[-]*)[a-z0-9]+)+)?)+)?$
x-kubernetes-list-type: set
neverContactSource:
description: When enabled, prevents image pull from the specified repository in the pull spec if the image pull form the mirror list fails. Default is false, the image will continue to be pulled from the pull spec if the image can not be pulled from the mirror list. neverContactSource is valid configuration only when one or more mirrors are in the mirror list.
Copy link
Contributor

Choose a reason for hiding this comment

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

The rest of the CR documentation seems to fairly consistently say something like “from the repository specified in the pull spec”, so this should be consistent.

(In other documents we talk about source or primary locations; this CR doesn’t seem to use that terminology right now. I don’t very much care what the name is, but it should be consistent.)

NeverContactSource MirrorSourcePolicy = "neverContactSource"

// allowContactingSource allow falling back to the specified repository in the pull spec if the image pull from the mirror list fails.
AllowContactingSource MirrorSourcePolicy = "allowContactingSource"
Copy link
Contributor

Choose a reason for hiding this comment

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

CamelCase, "AllowContactingSource"

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed and the above CamelCase

@deads2k
Copy link
Contributor

deads2k commented Mar 14, 2022

After comments on case, this looks good.

Add CRD ImageDigestMirrorSet and ImageTagMirrorSet to have API for epics:

    https://issues.redhat.com/browse/OCPNODE-521: different API for two saprate lists for digest
    image pull and tag image pull using mirrors.
    https://issues.redhat.com/browse/OCPNODE-810: add an option for user to choose if the source of
    the mirror should be denied if the mirrors pull failed.
Enhancement:
[OCPNODE-747] New CRD ImageDigestMirrorSet and ImageTagMirrorSet to support AllowMirrByTags enhancements#929

Signed-off-by: Qi Wang <qiwan@redhat.com>
Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

LGTM, to the little extent I understand K8s API rules.

(Note David’s comments though.)

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 14, 2022

@QiWang19: all tests passed!

Full PR test history. Your PR dashboard.

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.

@deads2k
Copy link
Contributor

deads2k commented Mar 15, 2022

/approve

@deads2k
Copy link
Contributor

deads2k commented Mar 15, 2022

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 15, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 15, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, QiWang19

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

The pull request process is described here

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 15, 2022
@mburke5678
Copy link

mburke5678 commented Mar 15, 2022

/label docs-approved

FYI: @TanyaShearonRH

@openshift-ci openshift-ci bot added the docs-approved Signifies that Docs has signed off on this PR label Mar 15, 2022
@mrunalp
Copy link
Member

mrunalp commented Mar 15, 2022

/label

@QiWang19
Copy link
Member Author

/label px-approved
/label qe-approved

@openshift-ci openshift-ci bot added px-approved Signifies that Product Support has signed off on this PR qe-approved Signifies that QE has signed off on this PR labels Mar 15, 2022
@openshift-merge-robot openshift-merge-robot merged commit d7c10d0 into openshift:master Mar 15, 2022
QiWang19 added a commit to QiWang19/client-go that referenced this pull request Mar 15, 2022
Update openshift/api dependency to import ImageDigest/TagMirrorSet CRD: openshift/api#1126

Signed-off-by: Qi Wang <qiwan@redhat.com>
QiWang19 added a commit to QiWang19/client-go that referenced this pull request Mar 16, 2022
Update openshift/api dependency to import ImageDigest/TagMirrorSet CRD: openshift/api#1126

Signed-off-by: Qi Wang <qiwan@redhat.com>
QiWang19 added a commit to QiWang19/client-go that referenced this pull request Mar 16, 2022
Update openshift/api dependency to import ImageDigest/TagMirrorSet CRD: openshift/api#1126

Signed-off-by: Qi Wang <qiwan@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. docs-approved Signifies that Docs has signed off on this PR lgtm Indicates that a PR is ready to be merged. px-approved Signifies that Product Support has signed off on this PR qe-approved Signifies that QE has signed off on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants