depresolver

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package depresolver abstracts and implements k8gb dependencies resolver. depresolver responsibilities - abstracts multiple configurations into single point of access - provides predefined values when configuration is missing - validates configuration - executes once

Index

Constants

View Source
const (
	// GeoIP strategy
	GeoStrategy = "geoip"
	// RoundRobin strategy
	RoundRobinStrategy = "roundRobin"
	// Failover strategy
	FailoverStrategy = "failover"
)
View Source
const (
	ReconcileRequeueSecondsKey = "RECONCILE_REQUEUE_SECONDS"
	ClusterGeoTagKey           = "CLUSTER_GEO_TAG"
	ExtClustersGeoTagsKey      = "EXT_GSLB_CLUSTERS_GEO_TAGS"
	ExtDNSEnabledKey           = "EXTDNS_ENABLED"
	EdgeDNSServersKey          = "EDGE_DNS_SERVERS"
	EdgeDNSZoneKey             = "EDGE_DNS_ZONE"
	DNSZoneKey                 = "DNS_ZONE"
	InfobloxGridHostKey        = "INFOBLOX_GRID_HOST"
	InfobloxVersionKey         = "INFOBLOX_WAPI_VERSION"
	InfobloxPortKey            = "INFOBLOX_WAPI_PORT"
	InfobloxUsernameKey        = "INFOBLOX_WAPI_USERNAME"
	// #nosec G101; ignore false positive gosec; see: https://securego.io/docs/rules/g101.html
	InfobloxPasswordKey            = "INFOBLOX_WAPI_PASSWORD"
	InfobloxHTTPRequestTimeoutKey  = "INFOBLOX_HTTP_REQUEST_TIMEOUT"
	InfobloxHTTPPoolConnectionsKey = "INFOBLOX_HTTP_POOL_CONNECTIONS"
	K8gbNamespaceKey               = "POD_NAMESPACE"
	CoreDNSExposedKey              = "COREDNS_EXPOSED"
	LogLevelKey                    = "LOG_LEVEL"
	LogFormatKey                   = "LOG_FORMAT"
	LogNoColorKey                  = "NO_COLOR"
	SplitBrainCheckKey             = "SPLIT_BRAIN_CHECK"
	TracingEnabled                 = "TRACING_ENABLED"
	OtelExporterOtlpEndpoint       = "OTEL_EXPORTER_OTLP_ENDPOINT"
	TracingSamplingRatio           = "TRACING_SAMPLING_RATIO"
	MetricsAddressKey              = "METRICS_ADDRESS"
)

Environment variables keys

View Source
const (
	// Deprecated: Please use EDGE_DNS_SERVERS instead.
	EdgeDNSServerKey = "EDGE_DNS_SERVER"

	// Deprecated: Please use EDGE_DNS_SERVERS instead.
	EdgeDNSServerPortKey = "EDGE_DNS_SERVER_PORT"
)

Deprecated environment variables keys

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Reschedule of Reconcile loop to pickup external Gslb targets
	ReconcileRequeueSeconds int `env:"RECONCILE_REQUEUE_SECONDS, default=30"`
	// ClusterGeoTag to determine specific location
	ClusterGeoTag string `env:"CLUSTER_GEO_TAG"`
	// ExtClustersGeoTags to identify clusters in other locations in format separated by comma. i.e.: "eu,uk,us"
	ExtClustersGeoTags []string `env:"EXT_GSLB_CLUSTERS_GEO_TAGS, default=[]"`
	// EdgeDNSType is READONLY and is set automatically by configuration
	EdgeDNSType EdgeDNSType
	// EdgeDNSServers
	EdgeDNSServers utils.DNSList

	// EdgeDNSZone main zone which would contain gslb zone to delegate; e.g. example.com
	EdgeDNSZone string `env:"EDGE_DNS_ZONE"`
	// DNSZone controlled by gslb; e.g. cloud.example.com
	DNSZone string `env:"DNS_ZONE"`
	// K8gbNamespace k8gb namespace
	K8gbNamespace string `env:"POD_NAMESPACE"`
	// Infoblox configuration
	Infoblox Infoblox
	// CoreDNSExposed flag
	CoreDNSExposed bool `env:"COREDNS_EXPOSED, default=false"`
	// Log configuration
	Log Log
	// MetricsAddress in format address:port where address can be empty, IP address, or hostname, default: 0.0.0.0:8080
	MetricsAddress string `env:"METRICS_ADDRESS, default=0.0.0.0:8080"`

	// SplitBrainCheck flag decides whether split brain TXT records will be stored in edge DNS
	SplitBrainCheck bool `env:"SPLIT_BRAIN_CHECK, default=false"`
	// TracingEnabled flag decides whether to use a real otlp tracer or a noop one
	TracingEnabled bool `env:"TRACING_ENABLED, default=false"`
	// TracingSamplingRatio how many traces should be kept and sent (1.0 - all, 0.0 - none)
	TracingSamplingRatio float64 `env:"TRACING_SAMPLING_RATIO, default=1.0"`
	// OtelExporterOtlpEndpoint where the traces should be sent to (in case of otel collector deployed on the same pod as sidecar -> localhost:4318)
	// otel collector itself can be configured via a configmap to send it somewhere else
	OtelExporterOtlpEndpoint string `env:"OTEL_EXPORTER_OTLP_ENDPOINT, default=localhost:4318"`
	// contains filtered or unexported fields
}

Config is operator configuration returned by depResolver

func (*Config) GetClusterHeartbeatFQDN

func (c *Config) GetClusterHeartbeatFQDN(gslbName string) string

func (*Config) GetClusterNSName

func (c *Config) GetClusterNSName() string

func (*Config) GetExternalClusterHeartbeatFQDNs

func (c *Config) GetExternalClusterHeartbeatFQDNs(gslbName string) (m map[string]string)

func (*Config) GetExternalClusterNSNames

func (c *Config) GetExternalClusterNSNames() (m map[string]string)

type DependencyResolver

type DependencyResolver struct {
	// contains filtered or unexported fields
}

DependencyResolver resolves configuration for GSLB

func NewDependencyResolver

func NewDependencyResolver() *DependencyResolver

NewDependencyResolver returns a new depresolver.DependencyResolver

func (*DependencyResolver) GetDeprecations

func (dr *DependencyResolver) GetDeprecations() (deprecations []string)

func (*DependencyResolver) ResolveGslbSpec

func (dr *DependencyResolver) ResolveGslbSpec(ctx context.Context, gslb *k8gbv1beta1.Gslb, client client.Client) error

ResolveGslbSpec fills Gslb by spec values. It executes always, when gslb is initialised. If spec value is not defined, it will use the default value. Function returns error if input is invalid.

func (*DependencyResolver) ResolveOperatorConfig

func (dr *DependencyResolver) ResolveOperatorConfig() (*Config, error)

ResolveOperatorConfig executes once. It reads operator's configuration from environment variables into &Config and validates

type EdgeDNSType

type EdgeDNSType string

EdgeDNSType specifies to which edge DNS is k8gb connecting

const (
	// DNSTypeNoEdgeDNS is default DNSType. Is used during integration testing when no edgeDNS provider exists
	DNSTypeNoEdgeDNS EdgeDNSType = "NoEdgeDNS"
	// DNSTypeInfoblox type
	DNSTypeInfoblox EdgeDNSType = "Infoblox"
	// DNSTypeRoute53 type
	DNSTypeExternal EdgeDNSType = "ExtDNS"
	// DNSTypeMultipleProviders type
	DNSTypeMultipleProviders EdgeDNSType = "MultipleProviders"
)

type GslbResolver added in v0.10.0

type GslbResolver interface {
	// ResolveOperatorConfig executes once. It reads operator's configuration
	// from environment variables into &Config and validates
	ResolveOperatorConfig() (*Config, error)

	// ResolveGslbSpec fills Gslb by spec values. It executes always, when gslb is initialised.
	// If spec value is not defined, it will use the default value. Function returns error if input is invalid.
	ResolveGslbSpec(ctx context.Context, gslb *k8gbv1beta1.Gslb, client client.Client) error
}

type Infoblox

type Infoblox struct {
	// Host
	Host string `env:"INFOBLOX_GRID_HOST"`
	// Version
	Version string `env:"INFOBLOX_WAPI_VERSION"`
	// Port
	Port int `env:"INFOBLOX_WAPI_PORT, default=0"`
	// Username
	Username string `env:"INFOBLOX_WAPI_USERNAME"`
	// Password
	Password string `env:"INFOBLOX_WAPI_PASSWORD"`
	// HTTPRequestTimeout seconds
	HTTPRequestTimeout int `env:"INFOBLOX_HTTP_REQUEST_TIMEOUT, default=20"`
	// HTTPPoolConnections seconds
	HTTPPoolConnections int `env:"INFOBLOX_HTTP_POOL_CONNECTIONS, default=10"`
}

Infoblox configuration

type Log

type Log struct {
	// Level [panic, fatal, error,warn,info,debug,trace], defines level of logger, default: info
	Level zerolog.Level
	// Format [simple,json] specifies how the logger prints values
	Format LogFormat
	// NoColor prints colored output if Format == simple
	NoColor bool `env:"NO_COLOR, default=false"`
	// contains filtered or unexported fields
}

Log configuration

type LogFormat

type LogFormat int8

LogFormat specifies how the logger prints values

const (
	// JSONFormat prints messages as single json record
	JSONFormat LogFormat = 1 << iota
	// SimpleFormat prints messages in human readable way
	SimpleFormat
	// NoFormat, returned in situation when format is not recognised
	NoFormat
)

func (LogFormat) String

func (f LogFormat) String() string

Jump to

Keyboard shortcuts

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