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

推荐订阅源

V
Visual Studio Blog
罗磊的独立博客
宝玉的分享
宝玉的分享
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
V2EX
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tailwind CSS Blog
博客园_首页
量子位
月光博客
月光博客
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美
人人都是产品经理
人人都是产品经理
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
爱范儿
爱范儿
S
SegmentFault 最新的问题
雷峰网
雷峰网
小众软件
小众软件
博客园 - 聂微东
美团技术团队
Apple Machine Learning Research
Apple Machine Learning Research
WordPress大学
WordPress大学
Jina AI
Jina AI
Hugging Face - Blog
Hugging Face - Blog

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 k8s_cache 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
Compile Time Enabling or Disabling Plugins
miek · 2017-07-25 · via 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.