coredns / rfc Goto Github PK
View Code? Open in Web Editor NEWPropsals and request for comments for CoreDNS
Propsals and request for comments for CoreDNS
I'm trying to build a plugin that can take action depending on different conditions. For example, the following config will forward dns query to 127.0.0.1:5353
while condition domain_in_file domain_with_local_cdn.txt
is satisfied.
policy {
condition domain_in_file domain_with_local_cdn.txt
action forward . 127.0.0.1:5353
}
However, I found it's hard to reuse existing plugin forward
.
First of all, to support plugin defined config, coredns
let plugin to parse config by themself. Such as forward
:
func parseForward(c *caddy.Controller) (*Forward, error) {
var (
f *Forward
err error
i int
)
for c.Next() {
if i > 0 {
return nil, plugin.ErrOnce
}
i++
f, err = parseStanza(c)
if err != nil {
return nil, err
}
}
return f, nil
}
This function isn't exported so we can't pass the forward config to build a new forward
plugin instance.
Secondly, forward
doesn't provide a configurable initialization function:
// New returns a new Forward.
func New() *Forward {
f := &Forward{maxfails: 2, tlsConfig: new(tls.Config), expire: defaultExpire, p: new(policy.Random), from: ".", hcInterval: hcInterval, opts: options{forceTCP: false, preferUDP: false, hcRecursionDesired: true}}
return f
}
// SetProxy appends p to the proxy list and starts healthchecking.
func (f *Forward) SetProxy(p *Proxy) {
f.proxies = append(f.proxies, p)
p.start(f.hcInterval)
}
No arguments for New()
and only SetProxy
is supported. So it's harder for other plugins to reuse forward
.
Embeddable plugin allows the plugin to be reusable.
Parse(*caddy.Controller) (plugin.Handler, error)
*caddy.Controller
proxy
in fallback
fallback
is an external plugin allow redirecting queries to an alternate set of upstreams based on RCODE.
It's reuse proxy
via proxy.NewStaticUpstream
:
func setup(c *caddy.Controller) error {
...
for c.Next() {
..
u, err := proxy.NewStaticUpstream(&c.Dispenser)
if err != nil {
return plugin.Error("fallback", err)
}
...
}
...
return nil
}
fanout
is an external plugin that parallel proxying DNS messages to upstream resolvers.
Without embed support, they have to implement a dns client by themself:
func (c *client) Request(r *request.Request) (*dns.Msg, error) {
start := time.Now()
conn, err := c.transport.Dial(c.net)
if err != nil {
return nil, err
}
defer func() {
logErrIfNotNil(conn.Close())
}()
logErrIfNotNil(conn.SetWriteDeadline(time.Now().Add(maxTimeout)))
if err = conn.WriteMsg(r.Req); err != nil {
logErrIfNotNil(err)
return nil, err
}
logErrIfNotNil(conn.SetReadDeadline(time.Now().Add(readTimeout)))
var ret *dns.Msg
for {
ret, err = conn.ReadMsg()
if err != nil {
logErrIfNotNil(err)
return nil, err
}
if r.Req.Id == ret.Id {
break
}
}
rc, ok := dns.RcodeToString[ret.Rcode]
if !ok {
rc = fmt.Sprint(ret.Rcode)
}
RequestCount.WithLabelValues(c.addr).Add(1)
RcodeCount.WithLabelValues(rc, c.addr).Add(1)
RequestDuration.WithLabelValues(c.addr).Observe(time.Since(start).Seconds())
return ret, nil
}
https://github.com/networkservicemesh/fanout/blob/master/client.go
kubernetai
serves multiple Kubernetes within a Server which is another example for the embeddable plugin.
They don't need to parse kubernetes
config anymore:
func Parse(c *caddy.Controller) (*Kubernetai, error) {
...
for c.Next() {
var k8s *kubernetes.Kubernetes
k8s, err = kubernetes.ParseStanza(c)
if err != nil {
return nil, err
}
k8i.Kubernetes = append(k8i.Kubernetes, k8s)
}
...
return k8i, nil
}
https://github.com/coredns/kubernetai/blob/master/plugin/kubernetai/setup.go
Please Note: This is a tracking issue for CommunityBridge Program Q2 2020. Anyone interested in this implementation should check link there in https://github.com/cncf/mentoring/tree/master/communitybridge/2020/q2
Please Note: This is reserved for CommunityBridge Program Q2 2020, we don't accept PRs outside of CommunityBridge Program Q2 2020, or without coordination with maintainers.
CNCF is participating CommunityBridge Program by Linux Foundation in Q2 2020. See link for more details. As part of CNCF projects, CoreDNS is actively participating in CommunityBridge Program.
Below are the list of candidate CommunityBridge Program Q2 2020:
External health check and orchestration of CoreDNS in Kubernetes clusters
Please Note: This is a tracking issue for Summer of Code. Anyone interested in this implementation should check link there.
Please Note: This is reserved for Summer of Code, we don't accept PRs outside of Summer of Code, or without coordination with maintainers.
Below are the list of candidate CoreDNS projects for Summer of Code 2020:
External health check and orchestration of CoreDNS in Kubernetes clusters
Anomaly detection of CoreDNS server through machine learning
For anyone who is interested in GSoC, please follow the RFC process set forth in this repo.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.