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

feat: add support for external IP in ambassador host source #3734

Merged
merged 2 commits into from
Oct 27, 2023

Conversation

fad3t
Copy link
Contributor

@fad3t fad3t commented Jun 26, 2023

Description

Hello!

I would like to submit a PR to add support for external IPs in Ambassador Host resources.
Most of the code has been shamelessly copied from the Service source implementation (https://github.com/kubernetes-sigs/external-dns/blob/master/source/service.go#L591).

I couldn't add any tests as the ones I currently see for Ambassador are rather basic (e.g. making sure the annotation format is correct) while in my case I would need to mock the Kubernetes API and I'm not sure how to do it -- happy to give it a try if somebody can guide me a bit.

Note this fixes #3733.

Let me know if anything is missing or if you have improvement ideas.

Thanks,
Fred

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 26, 2023
@k8s-ci-robot
Copy link
Contributor

Welcome @fad3t!

It looks like this is your first PR to kubernetes-sigs/external-dns 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/external-dns has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 26, 2023
@johngmyers
Copy link
Contributor

Is it intentional that the code also includes the ExternalIPs of Services of type other than LoadBalancer?

The code could be more simply expressed using the refactor in #3728

Would it make sense to call extractLoadBalancerTargets() instead of (incompletely) duplicating the logic?

@johngmyers
Copy link
Contributor

I'm wondering if we should refactor serviceSource.generateEndpoints() to extract a common function for getting the Endpoints for a Service. This would then be called by sources such as Ambassador and Istio (#3720) that obtain their endpoints from one or more associated Services.

What do you think @szuecs ?

@fad3t
Copy link
Contributor Author

fad3t commented Jun 27, 2023

Is it intentional that the code also includes the ExternalIPs of Services of type other than LoadBalancer?

It is not, although I'm not sure there are many deployments of Ambassador using another service type. Anyway, it would be good to add that check, thanks.

The code could be more simply expressed using the refactor in #3728

Right, thanks.

Would it make sense to call extractLoadBalancerTargets() instead of (incompletely) duplicating the logic?

Indeed, I didn't think about reusing that function - maybe to avoid confusion as it's part of the Service source. Might be good to have some kind of common utils functions in a separate file, so that all similar implementations can reuse them (and test them only once). This ties in with your second comment about extracting a common function for this purpose.

How would you like to proceed next?

@johngmyers
Copy link
Contributor

I would like to first get some consensus from approvers on my proposed direction for sources that consume endpoints from associated Services.

Would it make sense for Ambassador to be associated with a Service of type NodePort? It seems to me it might, especially on clouds without good load balancers. Similarly, would it make sense to be associated with a headless Service?

After that, we would refactor the service source to make the target extraction usable by other sources.

@johngmyers johngmyers mentioned this pull request Jun 27, 2023
2 tasks
@fad3t
Copy link
Contributor Author

fad3t commented Jul 24, 2023

Hi,

Any update on this one? Could we maybe consider going for an intermediate solution (= reuse the existing extractLoadBalancerTargets function) while discussions are ongoing -- and refactor in a second step?

Thx,
Fred

@johngmyers
Copy link
Contributor

There needs to be a little refactoring since the TTL shouldn't come from the service's annotation.

@szuecs
Copy link
Contributor

szuecs commented Aug 10, 2023

@johngmyers I think it's fine like this and we can do refactoring after that, or if @fad3t would do it even better.

/ok-to-test

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Aug 10, 2023
@fad3t
Copy link
Contributor Author

fad3t commented Aug 12, 2023

Hi, I replaced my code with the existing extractLoadBalancerTargets function as suggested. I won't be able to look at the refactoring now, but I'll keep this in mind for later (I'd also need to get a bit more familiar with the project code).

Thanks!

@fad3t
Copy link
Contributor Author

fad3t commented Aug 12, 2023

/test pull-external-dns-lint

@mloiseleur
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 6, 2023
@Raffo
Copy link
Contributor

Raffo commented Oct 27, 2023

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Raffo

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 Oct 27, 2023
@k8s-ci-robot k8s-ci-robot merged commit d8f408b into kubernetes-sigs:master Oct 27, 2023
12 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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for ExternalIPs in Ambassador Source
6 participants