netmaker

package module
v0.0.0-...-925b50d Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

README

netmaker-coredns-plugin

Name

netmaker - adds the ability to convert server names into their floating IPs.

Description

This plugin allows to resolve names build like <server_name>.[network-name] into the corresponding floating IP.

Syntax

  • api_url is the full URL of the netmaker server (ie: https://netmaker.example.com)
  • api_key is the API_KEY that allows to make queries to the API server on DNS endpoint(https://docs.netmaker.org/api.html#authentication)
  • fallthrough allow to fall to next plugin. It accepts zones arguments to filter next plugins.
  • refresh_duration specifies the interval to refresh informations from netmaker servers.

Examples

.:53 {
    log
    errors
    netmaker {
        api_url https://api.netmaker.example.com
        api_key secret_key
        refresh_duration 1s
        fallthrough
    }
    forward . /etc/resolv.conf
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	APIURL     string
	APIToken   string
	HttpClient *http.Client
}

func NewClient

func NewClient(APIURL string, APIToken string) *Client

func (Client) DNS

func (nm Client) DNS(ctx context.Context) ([]DNSEntry, error)

type DNSEntries

type DNSEntries map[string]hostAddresses

DNSEntries associate hostname to a map of addresses if the host is in multiple networks kube-node1:

delivery: 100.96.0.1
prod:     100.64.0.5

type DNSEntry

type DNSEntry struct {
	Address string `json:"address" bson:"address" validate:"required,ip"`
	Name    string `json:"name" bson:"name" validate:"required,name_unique,min=1,max=192"`
	Network string `json:"network" bson:"network" validate:"network_exists"`
}

type DNSer

type DNSer interface {
	DNS(context.Context) ([]DNSEntry, error)
}

type Netmaker

type Netmaker struct {
	Next plugin.Handler
	Fall fall.F
	// Zone is the zone of the base query in the configuration file
	// this is the global domain.
	Zone string
	// Entries is the cache of hosts informations
	Entries *DNSEntries
	// RefreshDuration is the interval at which we will refresh informations from database
	RefreshDuration time.Duration
	DNSClient       DNSer
}

Netmaker is a plugin that talks to netmaker API to retrieve hosts

func (Netmaker) Name

func (nm Netmaker) Name() string

Name implements the plugin.Handler interface.

func (Netmaker) ServeDNS

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

ServeDNS implements the plugin.Handler interface.

Jump to

Keyboard shortcuts

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