common

package
v0.0.0-...-f496b69 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NamespaceKubeSystem           = "kube-system"
	NamespaceIstioSystem          = "istio-system"
	Env                           = "env"
	Http                          = "http"
	Grpc                          = "grpc"
	GrpcWeb                       = "grpc-web"
	Http2                         = "http2"
	DefaultMtlsPort               = 15443
	DefaultServiceEntryPort       = 80
	Sep                           = "."
	Dash                          = "-"
	Slash                         = "/"
	DotLocalDomainSuffix          = ".svc.cluster.local"
	Mesh                          = "mesh"
	MulticlusterIngressGateway    = "istio-multicluster-ingressgateway"
	LocalAddressPrefix            = "240.0"
	NodeRegionLabel               = "failure-domain.beta.kubernetes.io/region"
	SpiffePrefix                  = "spiffe://"
	SidecarEnabledPorts           = "traffic.sidecar.istio.io/includeInboundPorts"
	Default                       = "default"
	AdmiralIgnoreAnnotation       = "admiral.io/ignore"
	AdmiralCnameCaseSensitive     = "admiral.io/cname-case-sensitive"
	BlueGreenRolloutPreviewPrefix = "preview"
	RolloutPodHashLabel           = "rollouts-pod-template-hash"
	RolloutActiveServiceSuffix    = "active-service"
	RolloutStableServiceSuffix    = "stable-service"
	WASMPath                      = "wasmPath"
)
View Source
const (
	ClustersMonitoredMetricName    = "clusters_monitored"
	EventsProcessedTotalMetricName = "events_processed_total"

	AddEventLabelValue    = "add"
	UpdateEventLabelValue = "update"
	DeleteEventLabelValue = "delete"
)

Variables

View Source
var (
	RemoteClustersMetric Gauge
	EventsProcessed      Counter
)

Functions

func ConstructGtpKey

func ConstructGtpKey(env, identity string) string

func ConstructRoutingPolicyKey

func ConstructRoutingPolicyKey(env, identity string) string

this function is exactly same as ConstructGtpKey. Not reusing the same function to keep the methods associated with these two objects separate.

func GetAdditionalEndpointLabelFilters

func GetAdditionalEndpointLabelFilters() []string

func GetAdditionalEndpointSuffixes

func GetAdditionalEndpointSuffixes() []string

func GetArgoRolloutsEnabled

func GetArgoRolloutsEnabled() bool

func GetBytes

func GetBytes(key interface{}) ([]byte, error)

func GetCacheRefreshDuration

func GetCacheRefreshDuration() time.Duration

func GetClusterRegistriesNamespace

func GetClusterRegistriesNamespace() string

func GetCname

func GetCname(deployment *k8sAppsV1.Deployment, identifier string, nameSuffix string) string

GetCname returns cname in the format <env>.<service identity>.global, Ex: stage.Admiral.services.registry.global

func GetCnameForRollout

func GetCnameForRollout(rollout *argo.Rollout, identifier string, nameSuffix string) string

GetCname returns cname in the format <env>.<service identity>.global, Ex: stage.Admiral.services.registry.global

func GetCnameVal

func GetCnameVal(vals []string) string

func GetDependenciesNamespace

func GetDependenciesNamespace() string

func GetDeploymentGlobalIdentifier

func GetDeploymentGlobalIdentifier(deployment *k8sAppsV1.Deployment) string

func GetEnableRoutingPolicy

func GetEnableRoutingPolicy() bool

func GetEnableSAN

func GetEnableSAN() bool

func GetEnv

func GetEnv(deployment *k8sAppsV1.Deployment) string

func GetEnvForRollout

func GetEnvForRollout(rollout *argo.Rollout) string

func GetEnvKey

func GetEnvKey() string

func GetEnvoyFilterAdditionalConfig

func GetEnvoyFilterAdditionalConfig() string

func GetEnvoyFilterVersion

func GetEnvoyFilterVersion() string

func GetGlobalTrafficDeploymentLabel

func GetGlobalTrafficDeploymentLabel() string

func GetGtpEnv

func GetGtpEnv(gtp *v1.GlobalTrafficPolicy) string

func GetGtpIdentity

func GetGtpIdentity(gtp *v1.GlobalTrafficPolicy) string

func GetGtpKey

func GetGtpKey(gtp *v1.GlobalTrafficPolicy) string

func GetHostnameSuffix

func GetHostnameSuffix() string

func GetKubeconfigPath

func GetKubeconfigPath() string

func GetMetricsEnabled

func GetMetricsEnabled() bool

func GetNodeLocality

func GetNodeLocality(node *k8sV1.Node) string

func GetPodGlobalIdentifier

func GetPodGlobalIdentifier(pod *k8sV1.Pod) string

func GetRolloutGlobalIdentifier

func GetRolloutGlobalIdentifier(rollout *argo.Rollout) string

func GetRoutingPolicyEnv

func GetRoutingPolicyEnv(rp *v1.RoutingPolicy) string

func GetRoutingPolicyIdentity

func GetRoutingPolicyIdentity(rp *v1.RoutingPolicy) string

func GetRoutingPolicyKey

func GetRoutingPolicyKey(rp *v1.RoutingPolicy) string

func GetRoutingPolicyLabel

func GetRoutingPolicyLabel() string

func GetSAN

func GetSAN(domain string, deployment *k8sAppsV1.Deployment, identifier string) string

GetSAN returns SAN for a service entry in the format spiffe://<domain>/<identifier>, Ex: spiffe://subdomain.domain.com/Admiral.platform.mesh.server

func GetSANForRollout

func GetSANForRollout(domain string, rollout *argo.Rollout, identifier string) string

GetSAN returns SAN for a service entry in the format spiffe://<domain>/<identifier>, Ex: spiffe://subdomain.domain.com/Admiral.platform.mesh.server

func GetSANPrefix

func GetSANPrefix() string

func GetSecretResolver

func GetSecretResolver() string

func GetSha1

func GetSha1(key interface{}) (string, error)

func GetSyncNamespace

func GetSyncNamespace() string

func GetValueForKeyFromDeployment

func GetValueForKeyFromDeployment(key string, deployment *k8sAppsV1.Deployment) string

func GetValueForKeyFromRollout

func GetValueForKeyFromRollout(key string, rollout *argo.Rollout) string

func GetWorkloadIdentifier

func GetWorkloadIdentifier() string

func GetWorkloadSidecarName

func GetWorkloadSidecarName() string

func GetWorkloadSidecarUpdate

func GetWorkloadSidecarUpdate() string

func InitializeConfig

func InitializeConfig(params AdmiralParams)

func InitializeMetrics

func InitializeMetrics()

InitializeMetrics depends on AdmiralParams for metrics enablement.

func IsServiceMatch

func IsServiceMatch(serviceSelector map[string]string, selector *v12.LabelSelector) bool

func MatchGTPsToRollout

func MatchGTPsToRollout(gtpList []v1.GlobalTrafficPolicy, rollout *argo.Rollout) *v1.GlobalTrafficPolicy

Find the GTP that best matches the rollout. It's assumed that the set of GTPs passed in has already been matched via the GtprolloutLabel. Now it's our job to choose the best one. In order: - If one and only one GTP matches the env label of the rollout - use that one. Use "default" as the default env label for all GTPs and rollout. - If multiple GTPs match the rollout label, use the oldest one (Using an old one has less chance of new behavior which could impact workflows) IMPORTANT: If an environment label is specified on either the GTP or the rollout, the same value must be specified on the other for them to match

func MatchRolloutsToGTP

func MatchRolloutsToGTP(gtp *v1.GlobalTrafficPolicy, rollouts []argo.Rollout) []argo.Rollout

Returns the list of rollouts to which this GTP should apply. It is assumed that all inputs already are an identity match If the GTP has an identity label, it should match all rollouts which share that label If the GTP does not have an identity label, it should return all rollouts without an identity label IMPORTANT: If an environment label is specified on either the GTP or the rollout, the same value must be specified on the other for them to match

func ResetSync

func ResetSync()

func SetEnablePrometheus

func SetEnablePrometheus(value bool)

for unit test only

func SetKubeconfigPath

func SetKubeconfigPath(path string)

func ShouldIgnoreResource

func ShouldIgnoreResource(metadata v12.ObjectMeta) bool

Types

type AdmiralParams

type AdmiralParams struct {
	ArgoRolloutsEnabled            bool
	KubeconfigPath                 string
	CacheRefreshDuration           time.Duration
	ClusterRegistriesNamespace     string
	DependenciesNamespace          string
	SyncNamespace                  string
	EnableSAN                      bool
	SANPrefix                      string
	SecretResolver                 string
	LabelSet                       *LabelSet
	LogLevel                       int
	HostnameSuffix                 string
	PreviewHostnamePrefix          string
	MetricsEnabled                 bool
	WorkloadSidecarUpdate          string
	WorkloadSidecarName            string
	AdmiralStateCheckerName        string
	DRStateStoreConfigPath         string
	ServiceEntryIPPrefix           string
	EnvoyFilterVersion             string
	EnvoyFilterAdditionalConfig    string
	EnableRoutingPolicy            bool
	ExcludedIdentityList           []string
	AdditionalEndpointSuffixes     []string
	AdditionalEndpointLabelFilters []string
}

func GetAdmiralParams

func GetAdmiralParams() AdmiralParams

func (AdmiralParams) String

func (b AdmiralParams) String() string

type Counter

type Counter interface {
	With(labelValues ...string) Counter
	Inc()
}

func NewCounterFrom

func NewCounterFrom(name string, help string, labelNames []string) Counter

type Event

type Event int
const (
	Add    Event = 0
	Update Event = 1
	Delete Event = 2
)

type Gauge

type Gauge interface {
	With(labelValues ...string) Gauge
	Set(value float64)
}

func NewGaugeFrom

func NewGaugeFrom(name string, help string, labelNames []string) Gauge

type LabelSet

type LabelSet struct {
	DeploymentAnnotation                string
	SubsetLabel                         string
	NamespaceSidecarInjectionLabel      string
	NamespaceSidecarInjectionLabelValue string
	AdmiralIgnoreLabel                  string
	PriorityKey                         string
	WorkloadIdentityKey                 string //Should always be used for both label and annotation (using label as the primary, and falling back to annotation if the label is not found)
	GlobalTrafficDeploymentLabel        string //label used to tie together deployments and globaltrafficpolicy objects. Configured separately from the identity key because this one _must_ be a label
	EnvKey                              string //key used to group deployments by env. The order would be to use annotation `EnvKey` and then label `EnvKey` and then fallback to label `env` label
	GatewayApp                          string //the value for `app` key that will be used to fetch the loadblancer for cross cluster calls, also referred to as east west gateway
}

func GetLabelSet

func GetLabelSet() *LabelSet

type Map

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

func NewMap

func NewMap() *Map

func (*Map) Copy

func (s *Map) Copy() map[string]string

func (*Map) Delete

func (s *Map) Delete(key string)

func (*Map) Get

func (s *Map) Get(key string) string

func (*Map) Put

func (s *Map) Put(key string, value string)

func (*Map) Range

func (s *Map) Range(fn func(k string, v string))

type MapOfMaps

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

func NewMapOfMaps

func NewMapOfMaps() *MapOfMaps

func (*MapOfMaps) Delete

func (s *MapOfMaps) Delete(key string)

func (*MapOfMaps) Get

func (s *MapOfMaps) Get(key string) *Map

func (*MapOfMaps) Map

func (s *MapOfMaps) Map() map[string]*Map

func (*MapOfMaps) Put

func (s *MapOfMaps) Put(pkey string, key string, value string)

func (*MapOfMaps) PutMap

func (s *MapOfMaps) PutMap(pkey string, inputMap *Map)

func (*MapOfMaps) Range

func (s *MapOfMaps) Range(fn func(k string, v *Map))

type NoopCounter

type NoopCounter struct{}

func (*NoopCounter) Inc

func (g *NoopCounter) Inc()

func (*NoopCounter) With

func (g *NoopCounter) With(...string) Counter

type NoopGauge

type NoopGauge struct{}

func (*NoopGauge) Set

func (g *NoopGauge) Set(float64)

func (*NoopGauge) With

func (g *NoopGauge) With(...string) Gauge

type PromCounter

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

func (*PromCounter) Inc

func (c *PromCounter) Inc()

func (*PromCounter) With

func (c *PromCounter) With(labelValues ...string) Counter

type PromGauge

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

func (*PromGauge) Set

func (g *PromGauge) Set(value float64)

func (*PromGauge) With

func (g *PromGauge) With(labelValues ...string) Gauge

type ResourceType

type ResourceType string
const (
	VirtualService  ResourceType = "VirtualService"
	DestinationRule ResourceType = "DestinationRule"
	ServiceEntry    ResourceType = "ServiceEntry"
)

type SidecarEgress

type SidecarEgress struct {
	Namespace string
	FQDN      string
	CNAMEs    map[string]string
}

type SidecarEgressMap

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

maintains a map from workload identity -> map[namespace]SidecarEgress

func NewSidecarEgressMap

func NewSidecarEgressMap() *SidecarEgressMap

func (*SidecarEgressMap) Delete

func (s *SidecarEgressMap) Delete(key string)

func (*SidecarEgressMap) Get

func (s *SidecarEgressMap) Get(key string) map[string]SidecarEgress

func (*SidecarEgressMap) Put

func (s *SidecarEgressMap) Put(identity string, namespace string, fqdn string, cnames map[string]string)

func (*SidecarEgressMap) Range

func (s *SidecarEgressMap) Range(fn func(k string, v map[string]SidecarEgress))

Range is a thread safe iterator to iterate through the SidecarEgress map

Jump to

Keyboard shortcuts

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