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

Initial version of OCI registry as storage #2375

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

0xavi0
Copy link
Contributor

@0xavi0 0xavi0 commented Apr 26, 2024

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 to true.

Adds the following new options to the gitrepo 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 pushes 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 bundles 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 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 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.

To be defined / todo / other considerations:

  • 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 implementation does not fallback to normal bundle + resource list + content resource if there is any issue connecting to the OCI registry. That's something we could do as bundle keeps the info to know if it is stored in a remote OCI registry or not.

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: #2114

@0xavi0 0xavi0 added this to the v2.9.0 milestone Apr 26, 2024
@0xavi0 0xavi0 self-assigned this Apr 26, 2024
@0xavi0 0xavi0 requested a review from a team as a code owner April 26, 2024 09:06
@0xavi0 0xavi0 force-pushed the 2114-oci-registry-initial branch 5 times, most recently from ae8f452 to fdc4b3c Compare April 30, 2024 07:25
Copy link
Contributor

@weyfonk weyfonk left a 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 :)

e2e/assets/single-cluster/test-oci-simple.yaml Outdated Show resolved Hide resolved
internal/cmd/cli/apply.go Outdated Show resolved Hide resolved
internal/cmd/cli/apply.go Outdated Show resolved Hide resolved
internal/cmd/cli/apply.go Show resolved Hide resolved
e2e/single-cluster/oci_registry_test.go Show resolved Hide resolved
internal/cmd/controller/reconciler/bundle_controller.go Outdated Show resolved Hide resolved
internal/cmd/controller/reconciler/bundle_controller.go Outdated Show resolved Hide resolved
internal/cmd/agent/deployer/deployer.go Outdated Show resolved Hide resolved
internal/ociutils/ociutils.go Outdated Show resolved Hide resolved
@0xavi0 0xavi0 force-pushed the 2114-oci-registry-initial branch from fdc4b3c to 87e640f Compare May 8, 2024 14:21
@0xavi0 0xavi0 requested review from manno and weyfonk May 8, 2024 14:33
@0xavi0 0xavi0 force-pushed the 2114-oci-registry-initial branch from 87e640f to 883e55b Compare May 17, 2024 14:31
@0xavi0 0xavi0 requested a review from weyfonk May 17, 2024 14:37
@0xavi0 0xavi0 force-pushed the 2114-oci-registry-initial branch 3 times, most recently from 949df75 to 6ed631f Compare May 24, 2024 14:02
@manno
Copy link
Member

manno commented May 28, 2024

  • respect EXPERIMENTAL_OCI_STORAGE env var

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>
@0xavi0 0xavi0 force-pushed the 2114-oci-registry-initial branch from 0e701d0 to f6211bb Compare June 7, 2024 08:55
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>
@0xavi0 0xavi0 force-pushed the 2114-oci-registry-initial branch from 6d98159 to a7d8d1d Compare June 7, 2024 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

None yet

3 participants