multicluster

package module
v0.0.0-...-abbcdc0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2022 License: Apache-2.0 Imports: 30 Imported by: 0

README

multicluster

Name

multicluster - implementation of Multicluster DNS

Description

This plugin implements the Kubernetes DNS-Based Multicluster Service Discovery Specification.

Syntax

multicluster [ZONES...] {
    kubeconfig KUBECONFIG [CONTEXT]
    noendpoints
    fallthrough [ZONES...]
}
  • kubeconfig KUBECONFIG [CONTEXT] authenticates the connection to a remote k8s cluster using a kubeconfig file. [CONTEXT] is optional, if not set, then the current context specified in kubeconfig will be used. It supports TLS, username and password, or token-based authentication. This option is ignored if connecting in-cluster (i.e., the endpoint is not specified).
  • noendpoints will turn off the serving of endpoint records by disabling the watch on endpoints. All endpoint queries and headless service queries will result in an NXDOMAIN.
  • fallthrough [ZONES...] If a query for a record in the zones for which the plugin is authoritative results in NXDOMAIN, normally that is what the response will be. However, if you specify this option, the query will instead be passed on down the plugin chain, which can include another plugin to handle the query. If [ZONES...] is omitted, then fallthrough happens for all zones for which the plugin is authoritative. If specific zones are listed (for example in-addr.arpa and ip6.arpa), then only queries for those zones will be subject to fallthrough.

Startup

When CoreDNS starts with the multicluster plugin enabled, it will delay serving DNS for up to 5 seconds until it can connect to the Kubernetes API and synchronize all object watches. If this cannot happen within 5 seconds, then CoreDNS will start serving DNS while the multicluster plugin continues to try to connect and synchronize all object watches. CoreDNS will answer SERVFAIL to any request made for a Kubernetes record that has not yet been synchronized.

Examples

Handle all queries in the clusterset.local zone. Connect to Kubernetes in-cluster.

.:53 {
    multicluster clusterset.local
}

Installation

See CoreDNS documentation about Compile Time Enabling or Disabling Plugins.

Recompile coredns

Add the plugin to plugins.cfg file. The ordering of plugins matters, add it just below kubernetes plugin that has very similar functionality:

...
kubernetes:kubernetes
multicluster:github.com/coredns/multicluster
...

Follow the coredns README file to build it.

Modify cluster's corefile

To enable the plugin for clusterset.local zone, add multicluster configuration to the corefile. Resulting corefile may look like this:

.:53 {
    errors
    health
    multicluster clusterset.local
    kubernetes cluster.local in-addr.arpa ip6.arpa {
      pods insecure
      fallthrough in-addr.arpa ip6.arpa
    }
    prometheus :9153
    forward . /etc/resolv.conf
    cache 30
    loop
    reload
    loadbalance
}

Documentation

Index

Constants

View Source
const (
	DNSSchemaVersion = "1.1.0"
	// Svc is the DNS schema for kubernetes services
	Svc = "svc"
	// Pod is the DNS schema for kubernetes pods
	Pod = "pod"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MultiCluster

type MultiCluster struct {
	Next         plugin.Handler
	Zones        []string
	ClientConfig clientcmd.ClientConfig
	Fall         fall.F
	// contains filtered or unexported fields
}

MultiCluster implements a plugin supporting multi-cluster DNS spec.

func New

func New(zones []string) *MultiCluster

func ParseStanza

func ParseStanza(c *caddy.Controller) (*MultiCluster, error)

ParseStanza parses a kubernetes stanza

func (*MultiCluster) InitController

func (m *MultiCluster) InitController(ctx context.Context) (onStart func() error, onShut func() error, err error)

func (MultiCluster) IsNameError

func (m MultiCluster) IsNameError(err error) bool

IsNameError returns true if err indicated a record not found condition

func (MultiCluster) Lookup

func (m MultiCluster) Lookup(ctx context.Context, state request.Request, name string, typ uint16) (*dns.Msg, error)

Lookup is used to find records else where.

func (MultiCluster) MinTTL

func (m MultiCluster) MinTTL(state request.Request) uint32

MinTTL returns the minimum TTL to be used in the SOA record.

func (MultiCluster) Name

func (m MultiCluster) Name() string

Name implements the Handler interface.

func (*MultiCluster) Ready

func (m *MultiCluster) Ready() bool

Ready implements the ready.Readiness interface. func (m *MultiCluster) Ready() bool { return m.controller.HasSynced() }

func (MultiCluster) Records

func (m MultiCluster) Records(ctx context.Context, state request.Request, exact bool) ([]msg.Service, error)

Returns _all_ services that matches a certain name. Note: it does not implement a specific service.

func (MultiCluster) Reverse

func (m MultiCluster) Reverse(ctx context.Context, state request.Request, exact bool, opt plugin.Options) ([]msg.Service, error)

Reverse communicates with the backend to retrieve service definition based on a IP address instead of a name. I.e. a reverse DNS lookup.

func (MultiCluster) Serial

func (m MultiCluster) Serial(state request.Request) uint32

Serial returns a SOA serial number to construct a SOA record.

func (MultiCluster) ServeDNS

func (m MultiCluster) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

func (MultiCluster) Services

func (m MultiCluster) Services(ctx context.Context, state request.Request, exact bool, opt plugin.Options) ([]msg.Service, error)

Services communicates with the backend to retrieve the service definitions. Exact indicates on exact match should be returned.

type ResponsePrinter

type ResponsePrinter struct {
	dns.ResponseWriter
}

func NewResponsePrinter

func NewResponsePrinter(w dns.ResponseWriter) *ResponsePrinter

NewResponsePrinter returns ResponseWriter.

func (*ResponsePrinter) WriteMsg

func (r *ResponsePrinter) WriteMsg(res *dns.Msg) error

Directories

Path Synopsis
Package object holds functions that convert the objects from the k8s API in to a more memory efficient structures.
Package object holds functions that convert the objects from the k8s API in to a more memory efficient structures.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL