endpoint

package
v0.0.0-...-50c2eee Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MediaTypeFormatAndVersion = "application/external.dns.webhook+json;version=1"
	ContentTypeHeader         = "Content-Type"
)
View Source
const (
	// RecordTypeA is a RecordType enum value
	RecordTypeA = "A"
	// RecordTypeAAAA is a RecordType enum value
	RecordTypeAAAA = "AAAA"
	// RecordTypeCNAME is a RecordType enum value
	RecordTypeCNAME = "CNAME"
	// RecordTypeTXT is a RecordType enum value
	RecordTypeTXT = "TXT"
	// RecordTypeSRV is a RecordType enum value
	RecordTypeSRV = "SRV"
	// RecordTypeNS is a RecordType enum value
	RecordTypeNS = "NS"
	// RecordTypePTR is a RecordType enum value
	RecordTypePTR = "PTR"
	// RecordTypeMX is a RecordType enum value
	RecordTypeMX = "MX"
	// RecordTypeNAPTR is a RecordType enum value
	RecordTypeNAPTR = "NAPTR"
)
View Source
const (

	// OwnerLabelKey is the name of the label that defines the owner of an Endpoint.
	OwnerLabelKey = "owner"
	// ResourceLabelKey is the name of the label that identifies k8s resource which wants to acquire the DNS name
	ResourceLabelKey = "resource"
	// OwnedRecordLabelKey is the name of the label that identifies the record that is owned by the labeled TXT registry record
	OwnedRecordLabelKey = "ownedRecord"

	// AWSSDDescriptionLabel label responsible for storing raw owner/resource combination information in the Labels
	// supposed to be inserted by AWS SD Provider, and parsed into OwnerLabelKey and ResourceLabelKey key by AWS SD Registry
	AWSSDDescriptionLabel = "aws-sd-description"

	// DualstackLabelKey is the name of the label that identifies dualstack endpoints
	DualstackLabelKey = "dualstack"
)

Variables

View Source
var ErrInvalidHeritage = errors.New("heritage is unknown or not found")

ErrInvalidHeritage is returned when heritage was not found, or different heritage is found

Functions

func SameEndpoint

func SameEndpoint(a, b *Endpoint) bool

SameEndpoint returns true if two endpoints are same considers example.org. and example.org DNSName/Target as different endpoints

func SameEndpointLabels

func SameEndpointLabels(a, b []*Endpoint) bool

SameEndpointLabels verifies that labels of the two slices of endpoints are the same

func SameEndpoints

func SameEndpoints(a, b []*Endpoint) bool

SameEndpoints compares two slices of endpoints regardless of order [x,y,z] == [z,x,y] [x,x,z] == [x,z,x] [x,y,y] != [x,x,y] [x,x,x] != [x,x,z]

func SamePlanChanges

func SamePlanChanges(a, b map[string][]*Endpoint) bool

SamePlanChanges verifies that two set of changes are the same

func SameProviderSpecific

func SameProviderSpecific(a, b ProviderSpecific) bool

SameProviderSpecific verifies that two maps contain the same string/string key/value pairs

Types

type Changes

type Changes struct {
	// Records that need to be created
	Create []*Endpoint
	// Records that need to be updated (current data)
	UpdateOld []*Endpoint
	// Records that need to be updated (desired data)
	UpdateNew []*Endpoint
	// Records that need to be deleted
	Delete []*Endpoint
}

Changes holds lists of actions to be executed by dns providers

func (*Changes) HasChanges

func (c *Changes) HasChanges() bool

type DNSEndpoint

type DNSEndpoint struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   DNSEndpointSpec   `json:"spec,omitempty"`
	Status DNSEndpointStatus `json:"status,omitempty"`
}

func (*DNSEndpoint) DeepCopy

func (in *DNSEndpoint) DeepCopy() *DNSEndpoint

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DNSEndpoint.

func (*DNSEndpoint) DeepCopyInto

func (in *DNSEndpoint) DeepCopyInto(out *DNSEndpoint)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*DNSEndpoint) DeepCopyObject

func (in *DNSEndpoint) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type DNSEndpointList

type DNSEndpointList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []DNSEndpoint `json:"items"`
}

+kubebuilder:object:root=true DNSEndpointList is a list of DNSEndpoint objects

func (*DNSEndpointList) DeepCopy

func (in *DNSEndpointList) DeepCopy() *DNSEndpointList

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DNSEndpointList.

func (*DNSEndpointList) DeepCopyInto

func (in *DNSEndpointList) DeepCopyInto(out *DNSEndpointList)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*DNSEndpointList) DeepCopyObject

func (in *DNSEndpointList) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type DNSEndpointSpec

type DNSEndpointSpec struct {
	Endpoints []*Endpoint `json:"endpoints,omitempty"`
}

DNSEndpointSpec defines the desired state of DNSEndpoint

func (*DNSEndpointSpec) DeepCopy

func (in *DNSEndpointSpec) DeepCopy() *DNSEndpointSpec

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DNSEndpointSpec.

func (*DNSEndpointSpec) DeepCopyInto

func (in *DNSEndpointSpec) DeepCopyInto(out *DNSEndpointSpec)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type DNSEndpointStatus

type DNSEndpointStatus struct {
	// The generation observed by the external-dns controller.
	// +optional
	ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

DNSEndpointStatus defines the observed state of DNSEndpoint

func (*DNSEndpointStatus) DeepCopy

func (in *DNSEndpointStatus) DeepCopy() *DNSEndpointStatus

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DNSEndpointStatus.

func (*DNSEndpointStatus) DeepCopyInto

func (in *DNSEndpointStatus) DeepCopyInto(out *DNSEndpointStatus)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type DNSServiceProvider

type DNSServiceProvider struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   DNSServiceSpec   `json:"spec,omitempty"`
	Status DNSServiceStatus `json:"status,omitempty"`
}

type DNSServiceProviderList

type DNSServiceProviderList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []DNSServiceProvider `json:"items"`
}

+kubebuilder:object:root=true DNSEndpointList is a list of DNSEndpoint objects

type DNSServiceSpec

type DNSServiceSpec struct {
	// Protocol used to communicate with the provider - one of the build
	// in implementations "aws", "azure", "gcp", "rfc2136", "route53",
	// "alidns", "cloudflare", "dnsimple", "dnsmadeeasy", "infoblox",
	// "linode", "namedotcom", "ovh", "rfc2136", "ultradns"...
	Protocol string `json:"protocol"`

	// URL to the provider's API endpoint, if not hardcoded by the protocol.
	// This will be the Webhook address for out-of-tree providers.
	Address string `json:"address"`

	Zones map[string]string `json:"zones"`
}

DNSServiceSepc represents an provider using the external-dns webhook API.

type DNSServiceStatus

type DNSServiceStatus struct {
}

type DNSSource

type DNSSource struct {
	Name   string
	Domain string
}

type DNSZone

type DNSZone struct {
	Name   string
	Domain string
}

type DomainFilter

type DomainFilter struct {
	// Filters define what domains to match
	Filters []string
	// contains filtered or unexported fields
}

DomainFilter holds a lists of valid domain names

func NewDomainFilter

func NewDomainFilter(domainFilters []string) DomainFilter

NewDomainFilter returns a new DomainFilter given a comma separated list of domains

func NewDomainFilterWithExclusions

func NewDomainFilterWithExclusions(domainFilters []string, excludeDomains []string) DomainFilter

NewDomainFilterWithExclusions returns a new DomainFilter, given a list of matches and exclusions

func NewRegexDomainFilter

func NewRegexDomainFilter(regexDomainFilter *regexp.Regexp, regexDomainExclusion *regexp.Regexp) DomainFilter

NewRegexDomainFilter returns a new DomainFilter given a regular expression

func (DomainFilter) IsConfigured

func (df DomainFilter) IsConfigured() bool

IsConfigured returns true if any inclusion or exclusion rules have been specified.

func (DomainFilter) MarshalJSON

func (df DomainFilter) MarshalJSON() ([]byte, error)

func (DomainFilter) Match

func (df DomainFilter) Match(domain string) bool

Match checks whether a domain can be found in the DomainFilter. RegexFilter takes precedence over Filters

func (DomainFilter) MatchParent

func (df DomainFilter) MatchParent(domain string) bool

func (*DomainFilter) UnmarshalJSON

func (df *DomainFilter) UnmarshalJSON(b []byte) error

type Endpoint

type Endpoint struct {
	// The hostname of the DNS record
	DNSName string `json:"dnsName,omitempty"`

	// The targets the DNS record points to
	Targets Targets `json:"targets,omitempty"`

	// RecordType type of record, e.g. CNAME, A, AAAA, SRV, TXT etc
	RecordType string `json:"recordType,omitempty"`

	// Identifier to distinguish multiple records with the same name and type (e.g. Route53 records with routing policies other than 'simple')
	SetIdentifier string `json:"setIdentifier,omitempty"`

	// TTL for the record
	RecordTTL TTL `json:"recordTTL,omitempty"`

	// Labels stores labels defined for the Endpoint
	// +optional
	Labels Labels `json:"labels,omitempty"`

	// ProviderSpecific stores provider specific config
	// +optional
	ProviderSpecific ProviderSpecific `json:"providerSpecific,omitempty"`
}

Endpoint is a high-level way of a connection between a service and an IP

func FilterEndpointsByOwnerID

func FilterEndpointsByOwnerID(ownerID string, eps []*Endpoint) []*Endpoint

Apply filter to slice of endpoints and return new filtered slice that includes only endpoints that match.

func NewEndpoint

func NewEndpoint(dnsName, recordType string, targets ...string) *Endpoint

NewEndpoint initialization method to be used to create an endpoint

func NewEndpointWithTTL

func NewEndpointWithTTL(dnsName, recordType string, ttl TTL, targets ...string) *Endpoint

NewEndpointWithTTL initialization method to be used to create an endpoint with a TTL struct

func RemoveDuplicates

func RemoveDuplicates(endpoints []*Endpoint) []*Endpoint

RemoveDuplicates returns a slice holding the unique endpoints. This function doesn't contemplate the Targets of an Endpoint as part of the primary Key

func (*Endpoint) DeepCopy

func (in *Endpoint) DeepCopy() *Endpoint

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Endpoint.

func (*Endpoint) DeepCopyInto

func (in *Endpoint) DeepCopyInto(out *Endpoint)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*Endpoint) DeleteProviderSpecificProperty

func (e *Endpoint) DeleteProviderSpecificProperty(key string)

DeleteProviderSpecificProperty deletes any ProviderSpecificProperty of the specified name.

func (*Endpoint) GetProviderSpecificProperty

func (e *Endpoint) GetProviderSpecificProperty(key string) (string, bool)

GetProviderSpecificProperty returns the value of a ProviderSpecificProperty if the property exists.

func (*Endpoint) IsOwnedBy

func (e *Endpoint) IsOwnedBy(ownerID string) bool

IsOwnedBy returns true if the endpoint owner label matches the given ownerID, false otherwise

func (*Endpoint) Key

func (e *Endpoint) Key() EndpointKey

Key returns the EndpointKey of the Endpoint.

func (*Endpoint) SetProviderSpecificProperty

func (e *Endpoint) SetProviderSpecificProperty(key string, value string)

SetProviderSpecificProperty sets the value of a ProviderSpecificProperty.

func (*Endpoint) String

func (e *Endpoint) String() string

func (*Endpoint) WithProviderSpecific

func (e *Endpoint) WithProviderSpecific(key, value string) *Endpoint

WithProviderSpecific attaches a key/value pair to the Endpoint and returns the Endpoint. This can be used to pass additional data through the stages of ExternalDNS's Endpoint processing. The assumption is that most of the time this will be provider specific metadata that doesn't warrant its own field on the Endpoint object itself. It differs from Labels in the fact that it's not persisted in the Registry but only kept in memory during a single record synchronization.

func (*Endpoint) WithSetIdentifier

func (e *Endpoint) WithSetIdentifier(setIdentifier string) *Endpoint

WithSetIdentifier applies the given set identifier to the endpoint.

type EndpointKey

type EndpointKey struct {
	DNSName       string
	RecordType    string
	SetIdentifier string
}

EndpointKey is the type of a map key for separating endpoints or targets.

type ExtDNSConfig

type ExtDNSConfig struct {
	ServerAddress  string
	MetricsAddress string

	Once         bool
	DryRun       bool
	UpdateEvents bool

	// Sync is the map of providers to associated sources and settings.
	Sync map[string]*SyncConfig
}

ExtDNSConfig defines the configuration for a multi-provider server, capable of syncing DNS entries operating multiple syncs.

This is enabled with a JSON or yaml configuration instead of CLI. Using CLI it is possible to operate a single provider.

type Labels

type Labels map[string]string

Labels store metadata related to the endpoint it is then stored in a persistent storage via serialization

func NewLabels

func NewLabels() Labels

NewLabels returns empty Labels

func NewLabelsFromStringPlain

func NewLabelsFromStringPlain(labelText string) (Labels, error)

NewLabelsFromString constructs endpoints labels from a provided format string if heritage set to another value is found then error is returned no heritage automatically assumes is not owned by external-dns and returns invalidHeritage error

func (Labels) DeepCopy

func (in Labels) DeepCopy() Labels

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Labels.

func (Labels) DeepCopyInto

func (in Labels) DeepCopyInto(out *Labels)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (Labels) SerializePlain

func (l Labels) SerializePlain(withQuotes bool) string

SerializePlain transforms endpoints labels into a external-dns recognizable format string withQuotes adds additional quotes

type MatchAllDomainFilters

type MatchAllDomainFilters []*DomainFilter

func (MatchAllDomainFilters) Match

func (f MatchAllDomainFilters) Match(domain string) bool

type Provider

type Provider interface {
	Records(ctx context.Context) ([]*Endpoint, error)
	ApplyChanges(ctx context.Context, changes *Changes) error
	// AdjustEndpoints canonicalizes a set of candidate endpoints.
	// It is called with a set of candidate endpoints obtained from the various sources.
	// It returns a set modified as required by the provider. The provider is responsible for
	// adding, removing, and modifying the ProviderSpecific properties to match
	// the endpoints that the provider returns in `Records` so that the change plan will not have
	// unnecessary (potentially failing) changes. It may also modify other fields, add, or remove
	// Endpoints. It is permitted to modify the supplied endpoints.
	AdjustEndpoints(endpoints []*Endpoint) ([]*Endpoint, error)
	GetDomainFilter() DomainFilter
}

Provider defines the interface DNS providers should implement.

type ProviderSpecific

type ProviderSpecific []ProviderSpecificProperty

ProviderSpecific holds configuration which is specific to individual DNS providers

func (ProviderSpecific) DeepCopy

func (in ProviderSpecific) DeepCopy() ProviderSpecific

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProviderSpecific.

func (ProviderSpecific) DeepCopyInto

func (in ProviderSpecific) DeepCopyInto(out *ProviderSpecific)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type ProviderSpecificProperty

type ProviderSpecificProperty struct {
	Name  string `json:"name,omitempty"`
	Value string `json:"value,omitempty"`
}

ProviderSpecificProperty holds the name and value of a configuration which is specific to individual DNS providers

type Source

type Source interface {
	Endpoints(ctx context.Context) ([]*Endpoint, error)
	// AddEventHandler adds an event handler that should be triggered if something in source changes
	AddEventHandler(context.Context, func())
}

Source defines the interface Endpoint sources should implement.

type SourceSpec

type SourceSpec struct {
	Name string

	// Labels allows selecting only resources with specific labels.
	Labels string

	// Namespace allows selecting only resources in a specific namespace.
	Namespace string

	ResolveServiceLoadBalancerHostname bool

	Options map[string]string

	// FQDNTemplate is a template for generating the hostname based on the object.
	FQDNTemplate string
	// Append this suffix to all names, after name.namespace
	// TODO: support including a cluster name
	Suffix string

	// Suffix for internal domain. If not set, "[SRC].mesh.internal" is used.
	//
	InternalDomain string

	// Default external domain, used for public IPs.
	ExternalDomain string
}

Config holds shared configuration options for all Sources.

type SyncConfig

type SyncConfig struct {

	// Address is the URL of the DNS service. If empty, the in-memory provider will be used, for debugging.
	Address string

	// Policy defines deletion/update model - default is create, no delete or update.
	// 'sync' will delete/update entries, but only if the TXT record matches
	// 'upsert' will update entries - but not delete.
	Policy string

	Sources []*SourceSpec

	Zones map[string]string

	DomainFilter   []string
	ExcludeDomains []string

	// TXTPrefix will enable use of the 'registry' mode, creating TXT records with the specified prefix for each record.
	TXTPrefix              string
	TXTOwnerID             string
	TXTCacheInterval       time.Duration
	TXTWildcardReplacement string

	// TargetNetFilter will only sync endpoints with the A or AAAA records in the specified networks.
	// This is only effective for addresses.
	TargetNetFilter   []string
	ExcludeTargetNets []string

	DefaultTargets []string

	ManagedDNSRecordTypes []string
	ExcludeDNSRecordTypes []string

	// How often will the full sync be triggered.
	Interval             time.Duration
	MinEventSyncInterval time.Duration
}

type TTL

type TTL int64

TTL is a structure defining the TTL of a DNS record

func (TTL) IsConfigured

func (ttl TTL) IsConfigured() bool

IsConfigured returns true if TTL is configured, false otherwise

type TargetFilterInterface

type TargetFilterInterface interface {
	Match(target string) bool
}

TargetFilterInterface defines the interface to select matching targets for a specific provider or runtime

type TargetNetFilter

type TargetNetFilter struct {
	// FilterNets define what targets to match
	FilterNets []*net.IPNet
	// contains filtered or unexported fields
}

TargetNetFilter holds a lists of valid target names

func NewTargetNetFilterWithExclusions

func NewTargetNetFilterWithExclusions(targetFilterNets []string, excludeNets []string) TargetNetFilter

NewTargetNetFilterWithExclusions returns a new TargetNetFilter, given a list of matches and exclusions

func (TargetNetFilter) Match

func (tf TargetNetFilter) Match(target string) bool

Match checks whether a target can be found in the TargetNetFilter.

type Targets

type Targets []string

Targets is a representation of a list of targets for an endpoint.

func NewTargets

func NewTargets(target ...string) Targets

NewTargets is a convenience method to create a new Targets object from a vararg of strings

func (Targets) DeepCopy

func (in Targets) DeepCopy() Targets

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Targets.

func (Targets) DeepCopyInto

func (in Targets) DeepCopyInto(out *Targets)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (Targets) IsLess

func (t Targets) IsLess(o Targets) bool

IsLess should fulfill the requirement to compare two targets and choose the 'lesser' one. In the past target was a simple string so simple string comparison could be used. Now we define 'less' as either being the shorter list of targets or where the first entry is less. FIXME We really need to define under which circumstances a list Targets is considered 'less' than another.

func (Targets) Len

func (t Targets) Len() int

func (Targets) Less

func (t Targets) Less(i, j int) bool

func (Targets) Same

func (t Targets) Same(o Targets) bool

Same compares to Targets and returns true if they are identical (case-insensitive)

func (Targets) String

func (t Targets) String() string

func (Targets) Swap

func (t Targets) Swap(i, j int)

Jump to

Keyboard shortcuts

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