Skip to content

feat(registry): new CRD option #5372

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

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

mloiseleur
Copy link
Collaborator

@mloiseleur mloiseleur commented May 8, 2025

Description

This is a follow up of #4598, updated with DNSRecord name and rebased on current master code.

This PR is not yet ready, it needs:

  1. extensive testing first. FTM, it can only be used in-cluster.
  2. usage documentation

The use of an other Kubeconfig will be for an other PR. Same for chart integration, with required new RBAC.

Fixes #4575

Checklist

  • Unit tests updated
  • End user documentation updated

@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 8, 2025
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 8, 2025
@ivankatliarchuk
Copy link
Contributor

Any chance we keep all API versions in folders apis/v1alpha?

Example https://github.com/gofogo/k8s-sigs-external-dns-fork/pull/15/files. This PR is in my repo still, it is working, but I have too many PR currently open ;-)

And API GW https://github.com/kubernetes-sigs/gateway-api/tree/main/apis.

The convention is for Custom Resources to keep them under structure apis/v1 apis/v1alpha and etc. This will pay off with versioning in future

@mloiseleur
Copy link
Collaborator Author

Any chance we keep all API versions in folders apis/v1alpha?

I was thinking of doing something like that. That make sense to me 👍 .

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 24, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign mloiseleur for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 docs source and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jun 7, 2025
@mloiseleur mloiseleur mentioned this pull request Jun 9, 2025
3 tasks
@@ -101,3 +101,100 @@ spec:
storage: true
subresources:
status: {}
---
Copy link
Contributor

Choose a reason for hiding this comment

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

The CRDs for the Helm chart should be in separate files and be formatted as described in #5479. The following command would be my suggestion to handle multiple CRDs being generated.

${CONTROLLER_GEN} object crd:crdVersions=v1 paths="./apis/..." output:crd:stdout | yamlfmt - | yq eval '.metadata.annotations |= with_entries(select(.key | test("kubernetes\.io")))' --split-exp '"./charts/external-dns/crds/" + .metadata.name + ".yaml"'

Copy link
Contributor

Choose a reason for hiding this comment

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

This should be fixed with a rebase.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 12, 2025
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ivankatliarchuk
Copy link
Contributor

It probably makes sense to slice this PR into smaller parts. There's no major issue if code is added but not immediately functional. For instance, we could safely introduce code from apid/v1alpha1 without yet generating any YAML files. This approach might significantly speed up the implementation of this extremely cool feature!

case "aws-sd":
reg, err = registry.NewAWSSDRegistry(p, cfg.TXTOwnerID)
case "crd":
reg, err = registry.NewCRDRegistry(p, cfg.KubeConfig, cfg.APIServerURL, cfg.CRDSourceAPIVersion, cfg.Namespace, cfg.TXTOwnerID, cfg.RequestTimeout, cfg.TXTCacheInterval)
Copy link
Contributor

Choose a reason for hiding this comment

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

could we have something like

registry.NewCRDRegistry(p, WithKubeConfig(), WithApiServerUrl(), With...)

Easier to support and extend, alternative registry.NewCRDRegistry(p, cfg), and manage requried fields within the registry. Not a great, as there is coupling but still

Copy link
Contributor

Choose a reason for hiding this comment

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

Something like

type RegistryOptions struct {
    Provider            provider.Provider
    KubeConfig          string
    APIServerURL        string
    CRDSourceAPIVersion string
    Namespace           string
    TXTOwnerID          string
    RequestTimeout      time.Duration
    TXTCacheInterval    time.Duration
    // Add new fields here as needed
}

func NewRegistry(opts RegistryOptions) (Registry, error) {
    // use opts.Provider, opts.KubeConfig, etc.
}

Copy link
Contributor

@ivankatliarchuk ivankatliarchuk Jun 22, 2025

Choose a reason for hiding this comment

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

opton example

type RegistryOption func(*Registry)

func WithKubeConfig(cfg string) RegistryOption { ... }

func NewRegistry(provider provider.Provider, opts ...RegistryOption) (Registry, error) {
    reg := &Registry{Provider: provider}
    for _, opt := range opts {
        opt(reg)
    }
    // ...
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I could add this in another PR, so you just rebase or implement as part of this change and I make changes in other registries

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chart cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. docs needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. source
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Finer grained control over endpoint.DNSEndpoint custom resource
4 participants