Move federation plugin to github.com/coredns/federation (#3139)

* Remove federation

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Rebuild and point to github.com/coredns/federation

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Export `localNodeName` => `LocalNodeName`, to be used by federation (until deprecation)

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Remove plugin/kubernetes/federation.go (=> kubernetes/federation repo)

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Update github.com/coredns/federation

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* sticker-ci fix

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
Yong Tang
2019-08-18 14:41:51 -07:00
committed by GitHub
parent bbf148360b
commit 6402cef337
14 changed files with 7 additions and 669 deletions

View File

@@ -1,51 +0,0 @@
package kubernetes
import (
"errors"
"github.com/coredns/coredns/plugin/etcd/msg"
"github.com/coredns/coredns/plugin/pkg/dnsutil"
"github.com/coredns/coredns/request"
)
// The federation node.Labels keys used.
const (
// TODO: Do not hardcode these labels. Pull them out of the API instead.
//
// We can get them via ....
// import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
// metav1.LabelZoneFailureDomain
// metav1.LabelZoneRegion
//
// But importing above breaks coredns with flag collision of 'log_dir'
LabelZone = "failure-domain.beta.kubernetes.io/zone"
LabelRegion = "failure-domain.beta.kubernetes.io/region"
)
// Federations is used from the federations plugin to return the service that should be
// returned as a CNAME for federation(s) to work.
func (k *Kubernetes) Federations(state request.Request, fname, fzone string) (msg.Service, error) {
nodeName := k.localNodeName()
node, err := k.APIConn.GetNodeByName(nodeName)
if err != nil {
return msg.Service{}, err
}
r, err := parseRequest(state)
if err != nil {
return msg.Service{}, err
}
lz := node.Labels[LabelZone]
lr := node.Labels[LabelRegion]
if lz == "" || lr == "" {
return msg.Service{}, errors.New("local node missing zone/region labels")
}
if r.endpoint == "" {
return msg.Service{Host: dnsutil.Join(r.service, r.namespace, fname, r.podOrSvc, lz, lr, fzone)}, nil
}
return msg.Service{Host: dnsutil.Join(r.endpoint, r.service, r.namespace, fname, r.podOrSvc, lz, lr, fzone)}, nil
}

View File

@@ -21,7 +21,8 @@ func localPodIP() net.IP {
return nil
}
func (k *Kubernetes) localNodeName() string {
// LocalNodeName is exclusively used in federation plugin, will be deprecated later.
func (k *Kubernetes) LocalNodeName() string {
localIP := k.interfaceAddrsFunc()
if localIP == nil {
return ""