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 support for ExternalName service type in dynamic mode #2804

Merged
merged 2 commits into from
Jul 25, 2018
Merged

add support for ExternalName service type in dynamic mode #2804

merged 2 commits into from
Jul 25, 2018

Conversation

ElvinEfendi
Copy link
Member

@ElvinEfendi ElvinEfendi commented Jul 18, 2018

What this PR does / why we need it:
Adds support for service of type ExternalName in dynamic mode. It's worth to mention that in dynamic mode when DNS setting changes for the externalname one won't have to reload Nginx, as soon as the TTL expires, Lua code will resolve the domain again.

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

Special notes for your reviewer:

@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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. 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. labels Jul 18, 2018

function _M.resolve(host)
local r, err = resolver:new{
nameservers = {"8.8.8.8", {"8.8.4.4", 53} },
Copy link
Member

Choose a reason for hiding this comment

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

We have the DNS servers to use in the controller. Maybe we can pass that during the initialization?

Copy link
Contributor

Choose a reason for hiding this comment

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

Mhm - this will not work for us as it stands - we need to resolve private dns names here (split horizon dns, corporate environment)

Copy link
Member

Choose a reason for hiding this comment

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

Mhm - this will not work for us as it stands - we need to resolve private dns names here (split horizon dns, corporate environment)

That's why I suggested we use the inherited dns name servers the container starts

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for early feedbacks, this was just a quick copy paste from the lua-resty-dns docs, hence WIP :)

We have the DNS servers to use in the controller. Maybe we can pass that during the initialization?

makes sense yeah, I'll do that

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 19, 2018
for _, ans in ipairs(answers) do
if ans.address then
cache:set(host, ans.address, ans.ttl)
return ans.address
Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder if we should use all A records here when there are more than one. Can not think of a reason why we would not wanna do that.

@ElvinEfendi ElvinEfendi changed the title [WIP] add support for ExternalName service type in dynamic mode add support for ExternalName service type in dynamic mode Jul 25, 2018
@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 Jul 25, 2018
@ElvinEfendi
Copy link
Member Author

/assign @aledbf
/assign @antoineco

@ElvinEfendi
Copy link
Member Author

The PR is ready for reviews now.

@ElvinEfendi
Copy link
Member Author

/test all

return { host }
end

local answers, err, _tries = r:query(host, { qtype = r.TYPE_A }, {})
Copy link
Member

Choose a reason for hiding this comment

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

what happens if the host is a CNAME?

Copy link
Member Author

Choose a reason for hiding this comment

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

imagine following:

> ingress-nginx (external-nama-in-dynamic-mode)$ dig www.shopify.com
www.shopify.com.	2441	IN	CNAME	origin.www.shopify.com.
origin.www.shopify.com.	2432	IN	CNAME	brochure-elb-567677451.us-east-1.elb.amazonaws.com.
brochure-elb-567677451.us-east-1.elb.amazonaws.com. 42 IN A 54.165.90.249
brochure-elb-567677451.us-east-1.elb.amazonaws.com. 42 IN A 50.17.21.142
brochure-elb-567677451.us-east-1.elb.amazonaws.com. 42 IN A 34.235.254.128

then it will return all three IP addresses.

if the cname target does not have A record then it will be empty

Copy link
Member

@aledbf aledbf Jul 25, 2018

Choose a reason for hiding this comment

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

👍

(I should read the resty dns API before asking 😉 )

@aledbf
Copy link
Member

aledbf commented Jul 25, 2018

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aledbf, ElvinEfendi

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 merged commit e89c569 into kubernetes:master Jul 25, 2018
@ElvinEfendi ElvinEfendi deleted the external-nama-in-dynamic-mode branch July 25, 2018 15:51
ElvinEfendi added a commit to Shopify/ingress that referenced this pull request Jul 26, 2018
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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enabling dynamic configuration doesnt work with external service
5 participants