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

Support Ambassador Host resources as sources #1642

Merged

Conversation

inercia
Copy link
Contributor

@inercia inercia commented Jun 23, 2020

Ambassador can be configured with Host resources (based on the Host CRD) for defining the external DNS host name. This is an example of a Host resource:

  apiVersion: getambassador.io/v2
  kind: Host
  metadata:
    name: e78cb61d56b6.eu.ngrok.io
    annotations:
      external-dns.ambassador-service: my-service
  spec:
    acmeProvider:
      authority: https://acme-v02.api.letsencrypt.org/directory
      email: alvaro.saurin@gmail.com
    ambassadorId:
    - default
    hostname: e78cb61d56b6.eu.ngrok.io
    selector:
      matchLabels:
        hostname: e78cb61d56b6.eu.ngrok.io
    tlsSecret:
      name: e78cb61d56b6.eu.ngrok.io

This code adds a new source, ambassador-host, that

  1. watches Hosts resources with
    a) a hostname, and
    b) a external-dns.ambassador-service annotation that refers to an existing Service srv.
  2. obtains the load balancer IP ip address from svc.Status.LoadBalancer.Ingress
  3. returns the Endpoint with hostname and ip

Closes #1552

@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 Jun 23, 2020
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 23, 2020
@k8s-ci-robot
Copy link
Contributor

Welcome @inercia!

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 cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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 Jun 23, 2020
@inercia inercia force-pushed the inercia/ambassador_host branch 2 times, most recently from f87651d to 7af7f26 Compare June 23, 2020 21:26
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 23, 2020
@inercia inercia force-pushed the inercia/ambassador_host branch 3 times, most recently from 30b6513 to dbdb1b2 Compare June 24, 2020 09:18
@inercia inercia changed the title [WIP] Support Ambassador Host resources as sources Support Ambassador Host resources as sources Jun 24, 2020
@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 Jun 24, 2020
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 1, 2020
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 6, 2020
@inercia
Copy link
Contributor Author

inercia commented Jul 8, 2020

/assign @njuettner

source/store.go Show resolved Hide resolved
source/ambassador_host.go Outdated Show resolved Hide resolved
source/ambassador_host.go Show resolved Hide resolved
source/ambassador_host.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 29, 2020
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 5, 2020
@kflynn
Copy link

kflynn commented Dec 3, 2020

@njuettner, I think that all of your comments have been addressed. I've dealt with the merge conflicts, and I'd like to get this landed.

@kflynn
Copy link

kflynn commented Dec 4, 2020

@njuettner @Lemmons @hjacobs @Raffo So, what's the path forward here? It would be lovely to get this landed before yet another merge conflict blocks it. 🙂

@donofriov
Copy link

Hey @njuettner just following up again as this unblocks some work for me, is there anything else needed or that I can help with to get this merged and released?

Copy link
Contributor

@Raffo Raffo left a comment

Choose a reason for hiding this comment

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

I added two comments and mostly waiting for @njuettner's stamp. Changes look good to me.

Comment on lines 214 to 257
func parseAmbLoadBalancerService(service string) (namespace, name string, err error) {
parts := strings.Split(service, "/")
if len(parts) == 2 {
namespace, name = parts[0], parts[1]
} else {
parts = strings.Split(service, ".")
if len(parts) == 2 {
name, namespace = parts[0], parts[1]
} else {
namespace, name = api.NamespaceDefault, service
}
}
return
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer if we can avoid using named returns, we try to avoid them where possible.

Copy link

Choose a reason for hiding this comment

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

Done.

continue
}

targets, err := sc.targetsFromAmbassadorLoadBalancer(ctx, service)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm also not sure if there is anything that can be done to get this. Do you have other suggestions @njuettner ?

@kyle-co
Copy link

kyle-co commented Jan 5, 2021

This is definitely of interest to my cohorts and I. Any way I can help get this shipped?

@donofriov
Copy link

@Raffo @njuettner This is the last thing we need before we can enable our new production pipeline. Is there anything I can do to help this get merged this week? cc: @kflynn

@springroll12
Copy link

@njuettner Our team would also love to see this land ASAP.

@richarddli
Copy link

@Raffo is there anyone other than @njuettner who can merge this? clearly there's a lot of interest and I can't help but notice that @njuettner really hasn't had any commits since June 2020.

(This PR has been open almost 6 months now.)

@kflynn
Copy link

kflynn commented Jan 19, 2021

@Raffo Related, is there a hard requirement for no named parameters, or would it be OK to land this and then fix that in a followup PR? (I'd prefer to land this one, then do a second one, simply for my own ease of testing.)

@springroll12
Copy link

@Raffo Any movement on this?

@Raffo
Copy link
Contributor

Raffo commented Jan 25, 2021

I can get this merged, but the fact that we can't address a minor comment is of course a bit of a concern in terms of how we can keep this code maintained. I'm going to re-review this this Wednesday when I go through the most urgent PRs.

@kflynn
Copy link

kflynn commented Jan 25, 2021

@Raffo That's actually why I was asking how strong your "I would prefer" was. 🙂 Let me see about addressing that...

@kflynn
Copy link

kflynn commented Jan 27, 2021

@Raffo OK, no more named returns in parseAmbLoadBalancerService -- and I made it more closely match Ambassador's historical semantics, added comments, and added a test for the parsing rules.

Ambassador can be configured with `Host` resources (based on the
`Host` CRD) for defining the external DNS host name.

This code adds a new source, `ambassador-host`, that looks for the
`ambassador/ambassador` Service and and uses the `hostname` from the
`Host` resource.

Signed-off-by: Alvaro Saurin <alvaro.saurin@gmail.com>
Signed-off-by: Flynn <flynn@datawire.io>
@Raffo
Copy link
Contributor

Raffo commented Jan 27, 2021

Perfect, thanks for the update. Reviewing this first thing tomorrow morning.

@Raffo
Copy link
Contributor

Raffo commented Jan 28, 2021

/approve
/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 28, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: inercia, 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 Jan 28, 2021
@k8s-ci-robot k8s-ci-robot merged commit 9759d6b into kubernetes-sigs:master Jan 28, 2021
@kflynn
Copy link

kflynn commented Jan 28, 2021

@Raffo Thanks!! 🙂

@nikolay
Copy link

nikolay commented Feb 2, 2021

@Raffo Any chance to have this released soon?

@vsimon
Copy link

vsimon commented Feb 12, 2021

Hi @Raffo @njuettner, I know you're busy but would you know when there might be a release bump that would include this?

@FriedCircuits
Copy link

Thanks for getting this released. I found it doesn't work when you are using ALBs with Ambassador because the LB info is on the ingress controller vs the ambassador service. I will have to continue adding all the DNS records we need on the ALB annotations.

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. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Ambassador host resource as source