惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
F
Fortinet All Blogs
Martin Fowler
Martin Fowler
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
IT之家
IT之家
Blog — PlanetScale
Blog — PlanetScale
罗磊的独立博客
V
V2EX
Vercel News
Vercel News
Apple Machine Learning Research
Apple Machine Learning Research
J
Java Code Geeks
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tailwind CSS Blog
I
InfoQ
Engineering at Meta
Engineering at Meta
WordPress大学
WordPress大学
S
SegmentFault 最新的问题
H
Help Net Security
腾讯CDC
D
Docker
P
Proofpoint News Feed
GbyAI
GbyAI
博客园 - 三生石上(FineUI控件)
aimingoo的专栏
aimingoo的专栏

Blogs on CoreDNS: DNS and Service Discovery

CoreDNS-1.14.2 Release CoreDNS-1.14.1 Release CoreDNS-1.14.0 Release CoreDNS-1.13.2 Release CoreDNS-1.13.1 Release CoreDNS-1.13.0 Release CoreDNS-1.12.4 Release CoreDNS-1.12.3 Release CoreDNS-1.12.2 Release CoreDNS-1.12.1 Release CoreDNS-1.12.0 Release CoreDNS-1.11.4 Release CoreDNS-1.11.3 Release CoreDNS-1.11.2 Release CoreDNS-1.11.1 Release CoreDNS-1.11.0 Release CoreDNS-1.10.1 Release CoreDNS-1.10.0 Release CoreDNS-1.9.4 Release CoreDNS-1.9.3 Release CoreDNS-1.9.2 Release CoreDNS-1.9.1 Release CoreDNS and Apache APISIX open new doors for Service Discovery? Trail Of Bits Security Review CoreDNS-1.9.0 Release CoreDNS-1.8.7 Release CoreDNS-1.8.6 Release CoreDNS-1.8.5 Release CoreDNS-1.8.4 Release CoreDNS-1.8.3 Release
Compile Time Enabling or Disabling Plugins
miek · 2017-07-25 · via Blogs on CoreDNS: DNS and Service Discovery

CoreDNS’ plugins (or external plugins) can be enabled or disabled on the fly by specifying (or not specifying) it in the Corefile. But you can also compile CoreDNS with only the plugins you need and leave the rest completely out.

There are two ways to achieve that. It could be done via compile-time configuration file with CoreDNS code base update. It also could be achieved without modifying CoreDNS code.

Build with compile-time configuration file

The with compile-time configuration file, plugin.cfg is all you need to update. It looks like this:

...
whoami:whoami
erratic:erratic
example:github.com/coredns/example
...

The ordering of the plugins is specified by how they are ordered in this file. Each line consists of a name and a repository. Just add or remove your plugin in this file.

Then do a go get <plugin-repo-path> if you need to get the external plugin’s source code. And then just compile CoreDNS with go generate and a go build. You can then check if CoreDNS has the new plugin with coredns -plugins.

Build with external golang source code

Alternatively, you could assemble plugins from different places through an external golang program. It looks like this:

package main

import (
        _ "github.com/coredns/example"

        "github.com/coredns/coredns/coremain"
        "github.com/coredns/coredns/core/dnsserver"
)

var directives = []string{
        "example",
        ...
        ...
        "whoami",
        "startup",
        "shutdown",
}

func init() {
        dnsserver.Directives = directives
}

func main() {
        coremain.Run()
}

In the above sample code, the external plugin example has been imported with:

        _ "github.com/coredns/example"

The directives should also be updated through:

        dnsserver.Directives = directives

The ordering of the plugins is specified by how the arey ordered in the slice directives.

Then you can just compile CoreDNS with go build to have the binary generated with the plugins you selected.