-
Notifications
You must be signed in to change notification settings - Fork 707
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
Flux oci support 2 #4932
Flux oci support 2 #4932
Conversation
✅ Deploy Preview for kubeapps-dev canceled.Built without sensitive environment variables
|
Oh no - hope you're starting to feel better.
Yes, since the flux controller work began, we've chatted about the fact that up until now, Kubeapps has always been able to use the user's credential because actions were synchronous. But with packaging systems that reconcile in the background (asynchronously from user actions), such as Carvel and Flux, an extra credential is required - such as the service account that is associated with the installed package. That's all well and good, but for flux we also need to be able to manage package repositories asynchronously, so in the past you've added the extra RBAC and service account for flux which enables the controller to access Flux So one option here would be to add the RBAC to read secrets there as well. Except, well, Flux isn't alone here: even the existing standard helm plugin needs to access
Yes, this has been an issue since the OCI spec was released without it solved, and everyone implemented their custom API around it :/
Not that you should, but an annotation could be (ab)used to hint or specify the repositories?
...
Yeah - it'd be neat, but it's a project in itself, providing that compatibility layer, with a potentially high maintenance burden. It was (from memory) one of the options at the time when the OCI support was added to Helm, but given a standard for listing repositories was not available at the time, the decision to simply specify the repositories that would be presented was taken. I see that now the OCI Registry As a Storage (ORAS) project has a v2 experimental version with support for listing repositories - it may be worth a look. ORAS tends to develop the new features that then may be later added to the OCI distribution spec. As it is, it looks like the v2 experimental stuff still just that: experimental. See what you think. Personally feels like it may not be worth investing in plugging that hole and instead using a work-around, but you might have other ideas.
I'll take a look now :) |
Thanks, Michael. re: Not that you should, but an annotation could be (ab)used to hint or specify the repositories? re: Yeah - it'd be neat, but it's a project in itself, providing that compatibility layer, re: Personally feels like it may not be worth investing in plugging that hole and instead using a work-around. |
limitations under the License. | ||
*/ | ||
|
||
// a copy of fluxcd source-controller internal/transport/transport.go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it's just this one file for the transport that's been copied in: I reckon it might be worth a comment here why we're deciding to copy this file into here (why the functionality is important enough - probably obvious to you, but won't be to other contributors until they dig in). Also, I think you already checked last time, but is there a way to convince the flux project to move this (one) package out of their internal
packages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it implements pooling. I.e. it is goodness
I am certainly not trying to blaze any trails with this
Line 35 in 284c24e
// Code from Helm Registry Client. Copied here since it belonged to a internal package. |
re: is there a way to convince the flux project to move this (one) package out of their internal packages
Egghh, how would I start this conversation? What can I offer to flux guys to make it worth the effort of changing what's there? There has to be something in it for flux guys in what I am suggesting. Let me sleep on it....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add some words to clarify why I chose to copy
// This Secret may either hold "username" and "password" fields or be of the | ||
// apiv1.SecretTypeDockerConfigJson type and hold a apiv1.DockerConfigJsonKey field with a | ||
// complete Docker configuration. If both, "username" and "password" are | ||
// empty, a nil LoginOption and a nil error will be returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering why it's not an error if the secret passed in does not contain the expected data? Or is it that you pass a number of secrets through without checking them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, at the moment my code is not checking the type of secret being passed in. So any kind of secret may be used. Whereas I am only interested in the basic auth-side of it (may be used with Opaque, basic-auth possibly other secret types). So the state when username and password == "" is NOT semantically an error. All it means is that I treat this case as if there was no secret at all. For now anyway
return false, nil | ||
} | ||
|
||
// ref https://github.com/distribution/distribution/blob/main/docs/spec/api.md#listing-repositories |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I didn't realise this was now supported, but yeah, the _catalog endpoint isn't quite what we'd normally want, since it's all repositories on the registry (well, also specific to the registry implementation). That is, it doesn't allow us to ask for the repositories on a certain path, afair. Found this from a couple of years ago: #1358 (comment) )
return nil, status.Errorf(codes.Internal, "failed to create registry client: %v", err) | ||
} | ||
if file != "" { | ||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there's a bit of debugging logging and commented out code here - not sure if you wanted it reviewed yet in its current state? I'm ignoring the commented out stuff, but wondering why it's here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
work in progress. No need to review commented out code, of course. These are just notes to myself. It'll be clean at the end, I pinky promise
Excellent then :) |
Plus I already started down this path and moved a "small sized mountain". So, the fallacy of sunk costs is playing a role |
Re: I see that now the OCI Registry As a Storage (ORAS) project has a v2 experimental version with support for listing repositories - it may be worth a look |
I took a second look (at the implementation this time) and I take back the comment. I think IT might be possible to re-use most of what they have. So, I am going to try to adopt it provided I can somehow shoehorn a server side repository name filter in there. The caveat is what they have only applies to vendors that implement "Docker Registry API V2 or |
Gasp. I may have to wait a little while on this (server-side filtering of repo names): |
This is an incremental checkin towards flux plug-in OCI support. I wanted to
checkpoint before the changes "get out of hand". All tests are passing
Working slower than usual due to poor health. Hope to improve that by end of next week.
Two serious unsolved questions remain:
This is true for both regular helm and helm OCI repos. Since the code runs in the context of
kubeapps-internal-kubeappsapis service account, to workaround I have a hack YAML
to put that service account into cluster admin role. Also, I see that flux source-controller itself does
not have this issue and I have yet to conclusively figure out why. Didn't spend enough
time debugging, just wanted to move on
Update: @dlaloue-vmware found the reason why flux source-controller does not run into the issue:
https://fluxcd.io/docs/security/#controller-permissions
Their solution is to run the controller as cluster-admin. Which maybe fine for them but not for us: #3899 (comment)
To be continued...
not provide for it. No one's solved this yet to my knowledge, Sigh. Flux does not solve it, but rather
very carefully dances around it which, honestly, left me disappointed. Also, the way it is done,
it limits my options because the flux's HelmRepository CR does not have a place to hang a list even if we
put the burden on the user to provide it (like we do with helm direct)
@dlaloue-vmware suggested we solve it just for a few biggest OCI registry providers that we know of
(e.g. harbor, github) using vendor-specific API endpoints while leaving the rest (Gcp, Azure, AWS ECR, OpenShift, Oracle OCI, kind, Rancher , etc. as an exercise for later.
My research so far:
Don't know about others yet for sure. The general idea, if we have it working, that would be a really good value-add for kubeapps because no one else has it. Anyway, I am still thinking about how to do it cleanly.
Anybody and everybody is invite to review. Thanks in advance