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

✨ Add OCI source for provider ConfigMap preparation #683

Merged
merged 6 commits into from
Jan 27, 2025

Conversation

Danil-Grigorev
Copy link
Member

@Danil-Grigorev Danil-Grigorev commented Jan 13, 2025

What this PR does / why we need it:

Allow to specify OCI artifact source for pulling the provider manifests. Similar to URL, the content is stored in a ConfigMap, which is used as a source of truth for the provider state.

This functionality allows to pre-load provider manifests in airGapped environments.

A new operator plugin command is available:

kubectl operator preload -u ttl.sh/manifests:v0.0.1 --infrastructure docker

which fetches according manifests for the provider and outputs prepared ConfigMap resource.

To package and publish manifests, plugin publish subcommand can be used:

kubectl operator preload -d components_directory -u ttl.sh/manifests:v0.0.1

oras can be also used directly:

oras push ttl.sh/${IMAGE_NAME}:v1.9.3 metadata.yaml infrastructure-components.yaml

this image is later available as a source for the Provider resource:

apiVersion: operator.cluster.x-k8s.io/v1alpha2
kind: InfrastructureProvider
metadata:
  name: docker
spec:
  fetchConfig:
    oci: ttl.sh/${IMAGE_NAME}

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 13, 2025
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 13, 2025
Copy link

netlify bot commented Jan 13, 2025

Deploy Preview for kubernetes-sigs-cluster-api-operator ready!

Name Link
🔨 Latest commit 2959930
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-operator/deploys/6797869814cc560008fd7eed
😎 Deploy Preview https://deploy-preview-683--kubernetes-sigs-cluster-api-operator.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Danil-Grigorev Danil-Grigorev force-pushed the oci-provider-source branch 3 times, most recently from e202fd3 to ee6fbae Compare January 14, 2025 14:22
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 14, 2025
@Danil-Grigorev Danil-Grigorev force-pushed the oci-provider-source branch 3 times, most recently from 47baaa7 to 57b8b0b Compare January 17, 2025 10:43
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 17, 2025
@Danil-Grigorev Danil-Grigorev changed the title [WIP] ✨ Add OCI source for provider ConfigMap preparation ✨ Add OCI source for provider ConfigMap preparation Jan 20, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 20, 2025
@Danil-Grigorev Danil-Grigorev force-pushed the oci-provider-source branch 8 times, most recently from bf81b3e to 2b3ca67 Compare January 24, 2025 13:38
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 24, 2025
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 24, 2025
Copy link
Contributor

@alexander-demicev alexander-demicev left a comment

Choose a reason for hiding this comment

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

thanks a lot! I added couple comments but none of them should block merging the PR

/approve

api/v1alpha2/provider_types.go Show resolved Hide resolved
}

// retryWithExponentialBackoff repeats an operation until it passes or the exponential backoff times out.
func retryWithExponentialBackoff(ctx context.Context, opts wait.Backoff, operation func(ctx context.Context) error) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

can this moved to util package or something similar?


// ociAuthentication returns user supplied credentials from provider variables.
func ociAuthentication() *auth.Credential {
username := os.Getenv(providercontroller.OCIUsernameKey)
Copy link
Contributor

Choose a reason for hiding this comment

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

should authentication be documented?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I'll add documentation in the follow-up PR

Copy link
Member Author

Choose a reason for hiding this comment

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

err = fs.Close()
}()

// 1. Add files to the file store
Copy link
Contributor

Choose a reason for hiding this comment

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

will it make sense to create some tmp directory as the file store?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not in this case as this already reads a dir/file path provided by user. There is no need to do it, the dir as well may be a temporary already.

}

metadata, err := store.GetMetadata(provider)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

if metadata is empty should we return an error?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it is checked within the method. If the metadata is incorrect, it will also result in a phase error on the resource later on.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alexander-demicev

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 24, 2025
Copy link
Member

@furkatgofurov7 furkatgofurov7 left a comment

Choose a reason for hiding this comment

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

Great work, thanks. Few non-blocking suggestions inline and below:

Can we have a guide/doc around how to use the new operator plugin as part of the book content as a follow-up?

cmd/plugin/cmd/init.go Show resolved Hide resolved
internal/controller/preflight_checks.go Outdated Show resolved Hide resolved
internal/controller/preflight_checks.go Outdated Show resolved Hide resolved
internal/controller/preflight_checks_test.go Outdated Show resolved Hide resolved
internal/controller/preflight_checks_test.go Outdated Show resolved Hide resolved
internal/controller/phases.go Show resolved Hide resolved
internal/controller/manifests_downloader.go Show resolved Hide resolved
@Danil-Grigorev Danil-Grigorev force-pushed the oci-provider-source branch 2 times, most recently from c0a51ad to 0f25329 Compare January 27, 2025 10:30
@furkatgofurov7
Copy link
Member

@Danil-Grigorev can you please re-run make generate and push the changes?

@furkatgofurov7
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 27, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: b0ae962c2d7320158ae59c8975b5da530b872569

@k8s-ci-robot k8s-ci-robot merged commit 6a31fe3 into kubernetes-sigs:main Jan 27, 2025
14 checks passed
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants