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

Treat 10.x.x.x registry addresses as local/insecure #289

Closed
berndtj opened this issue Oct 18, 2018 · 8 comments
Closed

Treat 10.x.x.x registry addresses as local/insecure #289

berndtj opened this issue Oct 18, 2018 · 8 comments

Comments

@berndtj
Copy link
Contributor

berndtj commented Oct 18, 2018

10.x.x.x registries should be considered insecure in the same manor registries suffixed with .local are. This is needed to pull from in cluster insecure registries:

Needed for: GoogleContainerTools/kaniko#405

berndtj added a commit to berndtj/go-containerregistry that referenced this issue Oct 18, 2018
This change assumes RFC1916 addresses are insecure and use the
http scheme.  This is the same as we assume for .local addresses.

With this change images can be built from local insecure registries,
not just pushed.

Fix: google#289

Signed-off-by: Berndt Jung <[email protected]>
@jonjohnsonjr
Copy link
Collaborator

Fixing this actually exacerbates another issue: #279

We probably want the behavior to first attempt https and fallback to http only for things that match the heuristic... (really, we need a flag or env var or something).

berndtj added a commit to berndtj/go-containerregistry that referenced this issue Oct 18, 2018
This change assumes RFC1918 addresses are insecure and use the
http scheme.  This is the same as we assume for .local addresses.

With this change images can be built from local insecure registries,
not just pushed.

Fix: google#289

Signed-off-by: Berndt Jung <[email protected]>
@berndtj
Copy link
Contributor Author

berndtj commented Oct 18, 2018

Yeah, it does. I think the real problem is that we don't have a distinction between source and destination within Kaniko, so the insecure flag only applies to destination. Fallback actually sounds like a pretty good solution that would "just work".

@berndtj
Copy link
Contributor Author

berndtj commented Oct 18, 2018

I've got another fix which should fix both my issue and #279. If we just do a fallback in the ping, it seems to work. I'm still evaluating this.

@berndtj
Copy link
Contributor Author

berndtj commented Oct 19, 2018

Here is a fallback proposal: https://github.com/google/go-containerregistry/compare/master...berndtj:http-fallback?expand=1

I actually prefer the fix in this PR as I'm not really afraid of any unintended consequences and it's more explicit. My suggestion for a long-term fix and the "right" way would be to make the "insecure" property (and flag) take a list of CIDRs and domains. So for kaniko it would look like:

executor --insecure '10.0.0.0/8' --insecure '*.local'

There would be some work in propagating that though. This would also have to be propogated in knative serving. I think the above patch doesn't hurt anything by assuming RFC1918 addresses are insecure (GKE nodes assume this as well by default).

@berndtj
Copy link
Contributor Author

berndtj commented Oct 19, 2018

@jonjohnsonjr I don't think I read your comment that closely. Is your suggestion that we more or less combine the two PRs above in that we keep the patterns and then if the patterns match, we do a fall-back, and only for those addresses. I think I can make that work... where reg.Scheme() would return back a list of schemes to use based on the match (i.e. localhost just returns back ["http"], and *.local returns ["https", "http"] and default just returns ["https"]). Does that sound like it would address all of the issues in a less hacky way?

@jonjohnsonjr
Copy link
Collaborator

Essentially yes, but I don't like it :(

I think what I'd really want is for our behavior to just be the same as this: https://docs.docker.com/registry/insecure/

I don't love how we implicitly assume certain endpoints are safe to be insecure, but it's harder to plumb these flags/configs around, so I'm not sure what to do 🙃

/cc @mattmoor what do you think?

@jonjohnsonjr
Copy link
Collaborator

@berndtj I haven't forgotten about this, just pondering still what the best path forward would be.

I think I'm fine with this PR going in as-is if we followup with the fallback.

re: the fallback proposal, I think it would be cleaner to pull the retry into the bearer transport's Roundtrip.

I'm not sure if it's easy (or even possible) to discriminate TLS-related errors from other connection-related errors, but perhaps retrying anything is a good idea.

In the bearer transport we could add something like:

	res, err := sendRequest()
	if err != nil {
                if bt.registry.Scheme() == "http" {
                        in.URL.Scheme = "http"
                        return sendRequest()
                }
		return nil, err
	}

And use "https" for every request first. It might make sense to split that logic out into an insecureFallbackTransport or something and wrap the bearerTransport's inner transport with it here.

@berndtj
Copy link
Contributor Author

berndtj commented Nov 7, 2018

I can clean it up. I'm not thrilled with this methodology either. I think long-term it needs to be explicitly settable.

jonjohnsonjr pushed a commit that referenced this issue Jan 28, 2019
This change assumes RFC1918 addresses are insecure and use the
http scheme.  This is the same as we assume for .local addresses.

With this change images can be built from local insecure registries,
not just pushed.

Fix: #289

Signed-off-by: Berndt Jung <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants