-
Notifications
You must be signed in to change notification settings - Fork 239
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
Initial version of OCI registry as storage #2375
Conversation
ae8f452
to
fdc4b3c
Compare
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.
Thanks for this effort, leaving a few comments :)
fdc4b3c
to
87e640f
Compare
87e640f
to
883e55b
Compare
949df75
to
6ed631f
Compare
|
b2f720f
to
0e701d0
Compare
1bdb104
to
84d77f3
Compare
if !ok { | ||
return "", fmt.Errorf("expected data [url] not found in secret: %s", bundle.Spec.ContentsID) | ||
} | ||
return fmt.Sprintf("oci://%s/%s:latest", string(url), bundle.Spec.ContentsID), nil |
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.
We do this a lot, but it might not work with IPv6 addresses? Is there a url module we can use?
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'll investigate...
@@ -34,6 +34,11 @@ func ApplyBootstrapResources(systemNamespace, systemRegistrationNamespace string | |||
APIGroups: []string{fleet.SchemeGroupVersion.Group}, | |||
Resources: []string{fleet.BundleDeploymentResourceNamePlural + "/status"}, | |||
}, | |||
{ |
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.
We grant this permission, even if ociutils.ExperimentalOCIIsEnabled is false?
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.
good point.
This approach is passing the env variable to fleet-controller
and gitjob
(upstream) only.
Do we have a mechanism to pass env variables to the agent?
How can we be sure that the env variable is passed when registration is initiated by the agent
?
We could have the case of an upstream supporting OCI and downstream that doesn't... which means the bundledeployments
it accesses may not be valid...
Good topic for discussion. :)
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 might work if we put it in the agents config.
However, these permissions are limited to the cluster namespace.
84d77f3
to
8029c2c
Compare
Implements an initial proposal to use OCI registries as storage. Adds the following new options to the `gitrepo` yaml: ```yaml // when ociRegistry is defined fleet will use oci registry as storage ociRegistry: // url is the OCI registry url. url: "docker.io/your-user-here" // secret name where the credentials for the OCI registry are. // expects a generic secret with username and password keys set. authSecretName: oci-secret // basicHTTP allows fleet to uses basic http connections to communicate // with the registry (defaults to false) basicHTTP: false // insecureSkipTLS allows connections to the OCI registry // without certs (defaults to false) insecureSkipTLS: false ``` New parameters are passed to `fleet apply` to propagate the values above. If at least the `url` value is set, `fleet apply` will do the following: * Creates a manifest from the resources found in the `bundle` * Creates and push an OCI manifest * Clears the `bundle`'s resource list (contents are in the OCI registry) * Adds the `contentID` value (this is a new value) in the `bundle`s spec * Creates a secret to pass the OCI registry values to the `fleet` controller and `agents`. This secret contains all the values so the controller and agents are able to reach the OCI registry. The upstream `fleet` controller then reconciles the just created `bundle` (remember, with no resources and the content's id set). When targetting, it also clones the secret containing all the OCI values, just changing the namespace to match the `bundledeployment`'s namespace. (This way the agents will be able to obtain the OCI values) It will also flag the `bundledeployment` to state that the content is stored in the OCI registry instead to a `content` resource. When deploying, the agents will check if the `bundledeployment` is flagged to has its contents in an OCI registry. If so, it gathers the OCI values it needs to access the registry from the `bundledeployment` secret and pulls the OCI manifest which is converted back into a `fleet` manifest. The agent deploys the manifest just like a regular manifest that was stored as a `contents` resource. All secrets created have the owner set to the `bundle` or `bundledeployment` so they are properly garbage collected when their owners are deleted. This to be defined / todo: * OCI registry garbage collection? (do we need this?) * Sign the OCI manifest when pushing the OCI manifest and check for the signature when pulling and before deploying to avoid back doors. At the moment the code checks that the `id` annotation is found in the OCI manifest and that it matches the expected content id. We could, maybe, use annotations to add a signature field. This has been tested with: * `zot` with basic HTTP * `zot` with HTTPS connections and insecure (self signed certs) * `zot` with secure HTTPS (through ngrok) * `dockerhub` (secure HTTPS) Refers to: rancher#2114 Signed-off-by: Xavi Garcia <xavi.garcia@suse.com>
In order to use the feature the `EXPERIMENTAL_OCI_STORAGE` environment variable should be `true`. Adds tests for testing without the experimental flag. Signed-off-by: Xavi Garcia <xavi.garcia@suse.com>
8029c2c
to
36d793c
Compare
} | ||
|
||
func newOCIRepository(id string, opts OCIOpts) (*remote.Repository, error) { | ||
repo, err := remote.NewRepository(filepath.Join(opts.URL, id)) |
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 find this problematic. We call it a "URL", but it's a simplified URL at best, as it is missing the protocol part, e.g. "oci://".
Later on we have to modify this string to turn it into a URL.
ORAS calls this a "reference": https://oras.land/docs/concepts/reference/
I can't force push to this branch, conflicts are resolved in #2561 |
Implements an initial proposal to use OCI registries as storage.
NOTE: The feature is only available when the environment variable
EXPERIMENTAL_OCI_STORAGE
is set totrue
.Adds the following new options to the
gitrepo
yaml:New parameters are passed to
fleet apply
to propagate the values above.If at least the
url
value is set,fleet apply
will do the following:bundle
bundle
's resource list (contents are in the OCI registry)contentID
value (this is a new value) in thebundle
s specfleet
controller andagents
. This secret contains all the values so the controller and agents are able to reach the OCI registry.The upstream
fleet
controller then reconciles the just createdbundle
(remember, with no resources and the content's id set).When targeting, it also clones the secret containing all the OCI values, just changing the namespace to match the
bundledeployment
's namespace. (This way the agents will be able to obtain the OCI values) It will also flag thebundledeployment
to state that the content is stored in the OCI registry instead to acontent
resource.When deploying, the agents will check if the
bundledeployment
is flagged to has its contents in an OCI registry. If so, it gathers the OCI values it needs to access the registry from thebundledeployment
secret and pulls the OCI manifest which is converted back into afleet
manifest.The agent deploys the manifest just like a regular manifest that was stored as a
contents
resource.All secrets created have the owner set to the
bundle
orbundledeployment
so they are properly garbage collected when their owners are deleted.To be defined / todo / other considerations:
id
annotation is found in the OCI manifest and that it matches the expected content id. We could, maybe, use annotations to add a signature field.bundle
+ resource list +content
resource if there is any issue connecting to the OCI registry. That's something we could do asbundle
keeps the info to know if it is stored in a remote OCI registry or not.This has been tested with:
zot
with basic HTTPzot
with HTTPS connections and insecure (self signed certs)zot
with secure HTTPS (through ngrok)dockerhub
(secure HTTPS)Refers to: #2114