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

New Plugin: extkubernetes - Expose External IPs of Load Balancers #2337

Closed
wants to merge 8 commits into from

Conversation

chrisohaver
Copy link
Member

@chrisohaver chrisohaver commented Nov 26, 2018

1. Why is this pull request needed and what does it do?

  • Adds a new plugin (extkubernetes) that exposes external ip addresses of loadBalancer services
  • Starts to moves some code common with kubernetes to pkg/kubernetes (e.g. API connection, watch).

"Connection sharing" with the kubernetes plugin is not implemented (that is, if both plugins are active, they do not share the same API connection). I think the general mode of deployment would be to serve external IPs from a separate instance of CoreDNS, not from the internal cluster DNS, so connection sharing would seldom be a factor. But if there is a demand to serve the data from the same instance, then we can implement connection sharing later.

No coredns/ci test yet. It will be complicated to implement, but doable. It will involve setting up virtual routers and load balancers (metalLB) in the framework of the test. I'll start on this only if it looks like the plugin will be accepted.

2. Which issues (if any) are related?

#1851
kubernetes/dns#242

3. Which documentation changes (if any) need to be made?

plugin/pkg/kubernetes/kubernetes.go Outdated Show resolved Hide resolved
plugin/pkg/kubernetes/kubernetes.go Show resolved Hide resolved
plugin/pkg/kubernetes/watch.go Outdated Show resolved Hide resolved
plugin/pkg/kubernetes/watch.go Outdated Show resolved Hide resolved
plugin/pkg/kubernetes/watch.go Outdated Show resolved Hide resolved
plugin/pkg/kubernetes/watch.go Outdated Show resolved Hide resolved
@codecov-io
Copy link

codecov-io commented Nov 26, 2018

Codecov Report

Merging #2337 into master will decrease coverage by 0.38%.
The diff coverage is 49.18%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2337      +/-   ##
==========================================
- Coverage   56.45%   56.07%   -0.39%     
==========================================
  Files         203      216      +13     
  Lines       10157    10702     +545     
==========================================
+ Hits         5734     6001     +267     
- Misses       3986     4238     +252     
- Partials      437      463      +26
Impacted Files Coverage Δ
plugin/kubernetes/watch.go 0% <ø> (-43.48%) ⬇️
plugin/pkg/kubernetes/controller.go 0% <0%> (ø)
plugin/extkubernetes/watch.go 0% <0%> (ø)
plugin/extkubernetes/apiproxy.go 0% <0%> (ø)
plugin/extkubernetes/health.go 0% <0%> (ø)
plugin/kubernetes/autopath.go 0% <0%> (ø) ⬆️
plugin/pkg/kubernetes/xfr.go 0% <0%> (ø)
plugin/kubernetes/xfr.go 90.82% <100%> (+2.49%) ⬆️
plugin/kubernetes/parse.go 91.11% <100%> (ø) ⬆️
plugin/kubernetes/setup.go 70.15% <100%> (ø) ⬆️
... and 26 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2032586...d0f9446. Read the comment docs.

@chrisohaver
Copy link
Member Author

FYI, @johnbelamaric

@chrisohaver
Copy link
Member Author

I should clarify that the state of this PR is that it is functional. I've tested it using minikube + metalLB, and it works as expected. Hence I am not marking this as a work in progress.
There is still some code duplication, more code could be moved to pkg/kubernetes.

Awaiting feedback and general acceptance of the approach before continuing.

@miekg
Copy link
Member

miekg commented Nov 28, 2018

This almost duplicates the kubernetes plugin. Please figure out a way to not do that and not fill up pkg/* with kubernetes stuff

@@ -44,6 +44,7 @@ hosts:hosts
route53:route53
federation:federation
kubernetes:kubernetes
extkubernetes:extkubernetes
Copy link
Member

Choose a reason for hiding this comment

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

don't really like the name, should we just go for external, or externelkubernetes or ... something?


## Description

Creates A/AAAA, SRV, and PTR records for the External IPs of each LoadBalancer type Service in a Kubernetes cluster.
Copy link
Member

Choose a reason for hiding this comment

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

Please full sentences. The extkubernernetes plugin ...

}
```

* `resyncperiod` specifies the Kubernetes API refresh period to be **DURATION**.
Copy link
Member

Choose a reason for hiding this comment

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

Just reference the kubernetes plugin here? Removes the need to duplicate all the info here.

func (p *proxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
upstream := p.Select()
network := "tcp"
address := upstream.Name
Copy link
Member

Choose a reason for hiding this comment

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

address is only used in the dial just below? No need to put this in a new var

http.Error(w, fmt.Sprintf("Unable to establish connection to upstream %s://%s: %s", network, address, err), 500)
return
}
hj, ok := w.(http.Hijacker)
Copy link
Member

Choose a reason for hiding this comment

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

why is this needed?

"context"

"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/request"
Copy link
Member

Choose a reason for hiding this comment

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

fmt


// ServeDNS implements the plugin.Handler interface.
func (k Kubernetes) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
opt := plugin.Options{}
Copy link
Member

Choose a reason for hiding this comment

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

where is opt used? Please move this closer

meta "k8s.io/apimachinery/pkg/apis/meta/v1"
)

var dnsTestCases = []test.Case{
Copy link
Member

Choose a reason for hiding this comment

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

is this just duplicating stuff?

@miekg
Copy link
Member

miekg commented Nov 28, 2018 via email

@fturib
Copy link
Contributor

fturib commented Nov 28, 2018

from @johnbelamaric:

For this reason I think it makes sense to be a different plugin.

from @miekg :

This almost duplicates the kubernetes plugin. Please figure out a way to not do that and not fill up pkg/* with kubernetes stuff

I guess there is too much constraints here.

If we want to make 2 separates plugins, then we'd better have common code (throuhg lib), and also maybe share the same connection to K8s API.

I am not sure why the number of lines make a difference: I would think the important is to have code that with good design, and maintainable, and UT (which adds line for sure).

@miekg
Copy link
Member

miekg commented Nov 28, 2018 via email

@fturib
Copy link
Contributor

fturib commented Nov 28, 2018

I do not find the meaning for CLOC (https://acronyms.thefreedictionary.com/CLOC). Can you translate ?

but if duplicated, we need something to keep things in sync

I guess we do not want to duplicate but rather have a common library, no ?
and the common part, packaged as a lib, is moved to plugin/pkg ... Is it not the purpose of this folder ?

@miekg
Copy link
Member

miekg commented Nov 28, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants