connector

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2025 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Overview

Package connector contains a reusable abstraction for efficiently watching for changes in resources in a Kubernetes cluster.

Index

Constants

View Source
const (
	// AnnotationMeshServiceSync defines mesh service sync annotation
	AnnotationMeshServiceSync = "flomesh.io/mesh-service-sync"

	// AnnotationMeshServiceSyncManagedBy defines mesh service sync connector uid annotation
	AnnotationMeshServiceSyncManagedBy = "flomesh.io/mesh-service-sync-managed-by"

	// AnnotationMeshServiceInternalSync defines mesh service internal sync annotation
	AnnotationMeshServiceInternalSync = "flomesh.io/mesh-service-internal-sync"

	// AnnotationCloudServiceInheritedFrom defines cloud service inherited annotation
	AnnotationCloudServiceInheritedFrom = "flomesh.io/cloud-service-inherited-from"

	// AnnotationCloudServiceAttachedTo defines cloud service attached to namespace
	AnnotationCloudServiceAttachedTo = "flomesh.io/cloud-service-attached-to"

	// AnnotationCloudServiceInheritedClusterID defines cloud service cluster id annotation
	AnnotationCloudServiceInheritedClusterID = "flomesh.io/cloud-service-inherited-cluster-id"

	// AnnotationMeshEndpointAddr defines mesh endpoint addr annotation
	AnnotationMeshEndpointAddr = "flomesh.io/cloud-endpoint-addr"
)
View Source
const (
	// AnnotationServiceSyncK8sToCloud is the key of the annotation that determines
	// whether to sync the k8s Service to Consul/Eureka.
	AnnotationServiceSyncK8sToCloud = "flomesh.io/service-sync-k8s-to-cloud"

	// AnnotationServiceSyncK8sToFgw is the key of the annotation that determines
	// whether to sync the k8s Service to fsm gateway.
	AnnotationServiceSyncK8sToFgw = "flomesh.io/service-sync-k8s-to-fgw"

	// AnnotationCloudHealthCheckService defines health check service annotation
	AnnotationCloudHealthCheckService = "flomesh.io/cloud-health-check-service"

	// AnnotationServiceName is set to override the name of the service
	// registered. By default this will be the name of the CatalogService resource.
	AnnotationServiceName = "flomesh.io/service-name"

	// AnnotationServicePort specifies the port to use as the service instance
	// port when registering a service. This can be a named port in the
	// service or an integer value.
	AnnotationServicePort = "flomesh.io/service-port"

	// AnnotationServiceTags specifies the tags for the registered service
	// instance. Multiple tags should be comma separated. Whitespace around
	// the tags is automatically trimmed.
	AnnotationServiceTags = "flomesh.io/service-tags"

	// AnnotationServiceMetaPrefix is the prefix for setting meta key/value
	// for a service. The remainder of the key is the meta key.
	AnnotationServiceMetaPrefix = "flomesh.io/service-meta-"

	// AnnotationServiceWeight is the key of the annotation that determines
	// the traffic weight of the service which is spanned over multiple k8s cluster.
	// e.g. CatalogService `backend` in k8s cluster `A` receives 25% of the traffic
	// compared to same `backend` service in k8s cluster `B`.
	AnnotationServiceWeight = "flomesh.io/service-weight"
)
View Source
const (
	// HealthAny is special, and is used as a wild card,
	// not as a specific state.
	HealthAny      = "any"
	HealthPassing  = "passing"
	HealthWarning  = "warning"
	HealthCritical = "critical"
	HealthMaint    = "maintenance"
)
View Source
const (
	NACOS_DEFAULT_CLUSTER = "DEFAULT"
)

Variables

View Source
var (
	// ClusterSetKey is the key used in the meta to track the "k8s" source.
	ClusterSetKey = "fsm.connector.service.cluster.set"

	// ConnectUIDKey is the key used in the meta to track the "k8s" source.
	ConnectUIDKey = "fsm.connector.service.connector.uid"

	// CloudK8SNS is the key used in the meta to record the namespace
	// of the service/node registration.
	CloudK8SNS          = "fsm.connector.service.k8s.ns"
	CloudK8SRefKind     = "fsm.connector.service.k8s.ref.kind"
	CloudK8SRefValue    = "fsm.connector.service.k8s.ref.name"
	CloudK8SNodeName    = "fsm.connector.service.k8s.node.name"
	CloudK8SPort        = "fsm.connector.service.k8s.port"
	CloudHTTPViaGateway = "fsm.connector.service.http.via.gateway"
	CloudGRPCViaGateway = "fsm.connector.service.grpc.via.gateway"
	CloudViaGatewayMode = "fsm.connector.service.via.gateway.mode"
)
View Source
var (
	GatewayAPIEnabled = false
)

Functions

func Encode added in v1.3.8

func Encode(m *MicroSvcMeta) (string, uint64)

func WatchMeshConfigUpdated added in v1.1.4

func WatchMeshConfigUpdated(
	connectController ConnectController,
	msgBroker *messaging.Broker,
	stop <-chan struct{})

WatchMeshConfigUpdated watches update of meshconfig

Types

type AgentCheck added in v1.2.1

type AgentCheck struct {
	CheckID   string
	ServiceID string
	Name      string
	Namespace string
	Type      string
	Status    string
	Output    string
}

AgentCheck represents a check known to the agent

func (*AgentCheck) ToConsul added in v1.2.1

func (ac *AgentCheck) ToConsul() *consul.AgentCheck

type AgentService added in v1.2.1

type AgentService struct {
	ID           string
	InstanceId   string
	ClusterId    string
	MicroService MicroService
	Weights      AgentWeights
	Ports        map[MicroServicePort]MicroServicePort
	Tags         []string
	Meta         map[string]interface{}

	GRPCInterface    string
	GRPCMethods      []string
	GRPCInstanceMeta map[string]interface{}

	HealthCheck bool
}

AgentService represents a service known to the agent

func (*AgentService) FromConsul added in v1.2.1

func (as *AgentService) FromConsul(ins *consul.AgentService)

func (*AgentService) FromEureka added in v1.2.1

func (as *AgentService) FromEureka(ins *eureka.Instance)

func (*AgentService) FromNacos added in v1.2.1

func (as *AgentService) FromNacos(ins *nacos.Instance)

func (*AgentService) FromVM added in v1.2.1

func (*AgentService) FromZookeeper added in v1.5.0

func (as *AgentService) FromZookeeper(ins discovery.ServiceInstance)

func (*AgentService) ToConsul added in v1.2.1

func (as *AgentService) ToConsul() *consul.AgentService

type AgentWeights added in v1.2.1

type AgentWeights struct {
	Passing int
	Warning int
}

func (*AgentWeights) FromConsul added in v1.2.1

func (aw *AgentWeights) FromConsul(w consul.AgentWeights)

func (*AgentWeights) ToConsul added in v1.2.1

func (aw *AgentWeights) ToConsul() consul.AgentWeights

type Backgrounder

type Backgrounder interface {
	Run(<-chan struct{})
}

Backgrounder should be implemented by a Resource that requires additional background processing. If a Resource implements this, then the CacheController will automatically Run the Backgrounder for the duration of the controller.

The channel will be closed when the CacheController is quitting. The CacheController will block until the Backgrounder completes.

type C2KContext added in v1.2.1

type C2KContext struct {

	// EndpointsKeyToName maps from Kube controller keys to Kube endpoints names.
	// Controller keys are in the form <kube namespace>/<kube endpoints name>
	// e.g. default/foo, and are the keys Kube uses to inform that something
	// changed.
	EndpointsKeyToName map[string]string

	// SourceServices maps from k8s service name to cloud service name.
	// Holds all services extended by prefix and suffix that should be synced to Kube.
	SourceServices map[KubeSvcName]CloudSvcName

	// NativeServices maps from k8s service name to cloud service name.
	// Holds native services without extended by prefix and suffix.
	NativeServices map[KubeSvcName]CloudSvcName

	// CatalogServices holds catalog services
	CatalogServices     []ctv1.NamespacedService
	CatalogServicesHash uint64

	// holds all Kube service
	KubeServiceCache map[KubeSvcKey]*corev1.Service

	// SyncedKubeServiceCache holds all Kube services that were created by this sync process. Keys are Kube service names.
	SyncedKubeServiceCache map[KubeSvcName]*corev1.Service
	SyncedKubeServiceHash  map[KubeSvcName]uint64
}

C2KContext is the c2k context for connector controller

func NewC2KContext added in v1.2.1

func NewC2KContext() *C2KContext

type CacheController added in v1.2.1

type CacheController struct {
	Resource Resource
	// contains filtered or unexported fields
}

CacheController is a generic cache.Controller implementation that watches Kubernetes for changes to specific set of resources and calls the configured callbacks as data changes.

func (*CacheController) HasSynced added in v1.2.1

func (c *CacheController) HasSynced() bool

HasSynced implements cache.Controller.

func (*CacheController) LastSyncResourceVersion added in v1.2.1

func (c *CacheController) LastSyncResourceVersion() string

LastSyncResourceVersion implements cache.Controller.

func (*CacheController) Run added in v1.2.1

func (c *CacheController) Run(stopCh <-chan struct{})

Run starts the CacheController and blocks until stopCh is closed.

Important: Callers must ensure that Run is only called once at a time.

type CatalogDeregistration added in v1.2.1

type CatalogDeregistration struct {
	ctv1.NamespacedService

	Node       string
	ServiceID  string
	ServiceRef string
}

func (*CatalogDeregistration) ToConsul added in v1.2.1

func (*CatalogDeregistration) ToEureka added in v1.2.1

func (cdr *CatalogDeregistration) ToEureka() *eureka.Instance

func (*CatalogDeregistration) ToNacos added in v1.2.1

func (*CatalogDeregistration) ToZookeeper added in v1.5.0

type CatalogRegistration added in v1.2.1

type CatalogRegistration struct {
	Node           string
	Address        string
	NodeMeta       map[string]string
	Service        *AgentService
	Check          *AgentCheck
	SkipNodeUpdate bool
}

func (*CatalogRegistration) ToConsul added in v1.2.1

func (*CatalogRegistration) ToEureka added in v1.2.1

func (cr *CatalogRegistration) ToEureka() *eureka.Instance

func (*CatalogRegistration) ToNacos added in v1.2.1

func (cr *CatalogRegistration) ToNacos(cluster, group string, weight float64) *vo.RegisterInstanceParam

func (*CatalogRegistration) ToZookeeper added in v1.5.0

type CatalogService added in v1.2.1

type CatalogService struct {
	Node        string
	ServiceID   string
	ServiceName string
	ServiceRef  string
}

func (*CatalogService) FromConsul added in v1.2.1

func (cs *CatalogService) FromConsul(svc *consul.CatalogService)

func (*CatalogService) FromEureka added in v1.2.1

func (cs *CatalogService) FromEureka(svc *eureka.Instance)

func (*CatalogService) FromNacos added in v1.2.1

func (cs *CatalogService) FromNacos(svc *nacos.Instance)

func (*CatalogService) FromZookeeper added in v1.5.0

func (cs *CatalogService) FromZookeeper(svc discovery.ServiceInstance)

type CloudSvcName added in v1.5.0

type CloudSvcName string

type ConnectController added in v1.2.1

type ConnectController interface {
	BroadcastListener(stopCh <-chan struct{})

	GetConnectorProvider() ctv1.DiscoveryServiceProvider
	GetConnectorNamespace() string
	GetConnectorName() string
	GetConnectorUID() string

	GetConsulConnector(namespace, name string) *ctv1.ConsulConnector
	GetEurekaConnector(namespace, name string) *ctv1.EurekaConnector
	GetNacosConnector(namespace, name string) *ctv1.NacosConnector
	GetZookeeperConnector(namespace, name string) *ctv1.ZookeeperConnector
	GetMachineConnector(namespace, name string) *ctv1.MachineConnector
	GetGatewayConnector(namespace, name string) *ctv1.GatewayConnector
	GetConnector() (connector, spec interface{}, uid string, ok bool)

	Refresh()

	WaitLimiter()

	GetSyncPeriod() time.Duration

	GetC2KContext() *C2KContext
	GetK2CContext() *K2CContext
	GetK2GContext() *K2GContext

	GetClusterSet() string
	SetClusterSet(name, group, zone, region string)

	SetServiceInstanceIDFunc(f ServiceInstanceIDFunc)
	GetServiceInstanceID(name, addr string, port MicroServicePort, protocol MicroServiceProtocol) string

	GetClusterId() string
	GetPassingOnly() bool
	GetC2KFilterTag() string
	GetC2KFilterMetadatas() []ctv1.Metadata
	GetC2KExcludeMetadatas() []ctv1.Metadata
	GetC2KFilterIPRanges() []*cidr.CIDR
	GetC2KExcludeIPRanges() []*cidr.CIDR
	GetK2CFilterIPRanges() []*cidr.CIDR
	GetK2CExcludeIPRanges() []*cidr.CIDR
	GetPrefixTag() string
	GetSuffixTag() string
	GetPrefixMetadata() string
	GetSuffixMetadata() string

	GetC2KFixedHTTPServicePort() *uint32

	GetC2KAppendLabels() map[string]string
	GetC2KAppendAnnotations() map[string]string

	EnableC2KTagStrategy() bool
	GetC2KTagToLabelConversions() map[string]string
	GetC2KTagToAnnotationConversions() map[string]string

	EnableC2KMetadataStrategy() bool
	GetC2KMetadataToLabelConversions() map[string]string
	GetC2KMetadataToAnnotationConversions() map[string]string

	EnableC2KConversions() bool
	GetC2KServiceConversions() map[string]ctv1.ServiceConversion

	GetC2KWithGateway() bool
	GetC2KMultiGateways() bool

	GetNacos2KClusterSet() []string
	GetNacos2KGroupSet() []string

	GetK2CDefaultSync() bool
	GetK2CSyncClusterIPServices() bool
	GetK2CSyncLoadBalancerEndpoints() bool
	GetK2CNodePortSyncType() ctv1.NodePortSyncType

	GetK2CSyncIngress() bool
	GetK2CSyncIngressLoadBalancerIPs() bool

	GetK2CAddServicePrefix() string
	GetK2CAddK8SNamespaceAsServiceSuffix() bool

	GetK2CAppendTagSet() mapset.Set
	GetK2CAppendMetadataSet() mapset.Set

	EnableK2CTagStrategy() bool
	GetK2CTagToLabelConversions() map[string]string
	GetK2CTagToAnnotationConversions() map[string]string

	EnableK2CMetadataStrategy() bool
	GetK2CMetadataToLabelConversions() map[string]string
	GetK2CMetadataToAnnotationConversions() map[string]string

	GetK2CAllowK8SNamespaceSet() mapset.Set
	GetK2CDenyK8SNamespaceSet() mapset.Set

	GetK2CWithGateway() bool
	GetK2CWithGatewayMode() ctv1.WithGatewayMode

	GetConsulNodeName() string
	GetConsulEnableNamespaces() bool
	GetConsulDestinationNamespace() string
	GetConsulEnableK8SNSMirroring() bool
	GetConsulK8SNSMirroringPrefix() string
	GetConsulCrossNamespaceACLPolicy() string
	GetConsulGenerateInternalServiceHealthCheck() bool

	GetEurekaHeartBeatInstance() bool
	GetEurekaHeartBeatPeriod() time.Duration
	GetEurekaCheckServiceInstanceID() bool

	GetNacosGroupId() string
	GetNacosClusterId() string

	GetZookeeperBasePath() string
	GetZookeeperCategory() string
	GetZookeeperAdaptor() string

	GetK2GDefaultSync() bool
	GetK2GAllowK8SNamespaceSet() mapset.Set
	GetK2GDenyK8SNamespaceSet() mapset.Set

	GetViaIngressIPSelector() ctv1.AddrSelector
	GetViaEgressIPSelector() ctv1.AddrSelector

	GetViaIngressAddr() string
	SetViaIngressAddr(ingressAddr string)

	GetViaEgressAddr() string
	SetViaEgressAddr(egressAddr string)

	GetViaIngressHTTPPort() uint
	SetViaIngressHTTPPort(httpPort uint)

	GetViaIngressGRPCPort() uint
	SetViaIngressGRPCPort(grpcPort uint)

	GetViaEgressHTTPPort() uint
	SetViaEgressHTTPPort(httpPort uint)

	GetViaEgressGRPCPort() uint
	SetViaEgressGRPCPort(grpcPort uint)

	GetAuthConsulUsername() string
	GetAuthConsulPassword() string

	GetAuthNacosUsername() string
	GetAuthNacosPassword() string
	GetAuthNacosAccessKey() string
	GetAuthNacosSecretKey() string
	GetAuthNacosNamespaceId() string
	GetAuthNacosTokenTtl() time.Duration

	SyncCloudToK8s() bool
	SyncK8sToCloud() bool
	SyncK8sToGateway() bool

	GetHTTPAddr() string
	GetDeriveNamespace() string
	Purge() bool
	AsInternalServices() bool

	CacheCatalogInstances(key string, catalogFunc func() (interface{}, error)) (interface{}, error)
	CacheRegisterInstance(key string, instance interface{}, registerFunc func() error) error
	CacheDeregisterInstance(key string, deregisterFunc func() error) error
	CacheCleaner(stopCh <-chan struct{})
}

ConnectController is the controller interface for K8s connectors

type Event

type Event struct {
	// Key is in the form of <namespace>/<name>, e.g. default/pod-abc123,
	// and corresponds to the resource modified.
	Key string
	// Obj holds the resource that was modified at the time of the event
	// occurring. If possible, the resource should be retrieved from the informer
	// cache, instead of using this field because the cache will be more up to
	// date at the time the event is processed.
	// In some cases, such as a delete event, the resource will no longer exist
	// in the cache and then it is useful to have the resource here.
	Obj interface{}
}

Event is something that occurred to the resources we're watching.

type GRPCMeta added in v1.5.0

type GRPCMeta struct {
	Interface string              `json:"interface,omitempty"`
	Methods   map[string][]string `json:"methods,omitempty"`
}

type K2CContext added in v1.2.1

type K2CContext struct {

	// ServiceMap holds services we should sync to cloud. Keys are the
	// in the form <kube namespace>/<kube svc name>.
	ServiceMap chm.ConcurrentMap[string, *corev1.Service]

	// EndpointsMap uses the same keys as serviceMap but maps to the endpoints
	// of each service.
	EndpointsMap chm.ConcurrentMap[string, *corev1.Endpoints]

	// IngressServiceMap uses the same keys as serviceMap but maps to the ingress
	// of each service if it exists.
	IngressServiceMap chm.ConcurrentMap[string, chm.ConcurrentMap[string, string]]

	// ServiceHostnameMap maps the name of a service to the hostName and port that
	// is provided by the Ingress resource for the service.
	ServiceHostnameMap chm.ConcurrentMap[string, ServiceAddress]

	// registeredServiceMap holds the services in cloud that we've registered from kube.
	// It's populated via cloud's API and lets us diff what is actually in
	// cloud vs. what we expect to be there.
	RegisteredServiceMap chm.ConcurrentMap[string, []*CatalogRegistration]

	// ServiceNames is all namespaces mapped to a set of valid cloud service names
	ServiceNames chm.ConcurrentMap[string, mapset.Set]

	// Namespaces is all namespaces mapped to a map of cloud service ids mapped to their CatalogRegistrations
	Namespaces chm.ConcurrentMap[string, chm.ConcurrentMap[string, *CatalogRegistration]]

	//deregistrations
	Deregs chm.ConcurrentMap[string, *CatalogDeregistration]

	// Watchers is all namespaces mapped to a map of cloud service
	// names mapped to a cancel function for watcher routines
	Watchers chm.ConcurrentMap[string, chm.ConcurrentMap[string, context.CancelFunc]]
}

K2CContext is the k2c context for connector controller

func NewK2CContext added in v1.2.1

func NewK2CContext() *K2CContext

type K2GContext added in v1.2.1

type K2GContext struct {

	// ServiceMap holds services we should sync to gateway. Keys are the
	// in the form <kube namespace>/<kube svc name>.
	ServiceMap map[string]*corev1.Service

	//
	// Syncer Context
	//
	Services map[string]*corev1.Service
	Deregs   map[string]*corev1.Service
}

K2GContext is the k2g context for connector controller

func NewK2GContext added in v1.2.1

func NewK2GContext() *K2GContext

type KubeSvcKey added in v1.5.0

type KubeSvcKey string

KubeSvcKey is in the form <kube namespace>/<kube svc name>

type KubeSvcName added in v1.5.0

type KubeSvcName string

type MicroEndpointMeta added in v1.3.8

type MicroEndpointMeta struct {
	Ports   map[MicroServicePort]MicroServiceProtocol `json:"ports,omitempty"`
	Address MicroServiceAddress                       `json:"address,omitempty"`

	GRPCMeta map[string]interface{} `json:"grpcMeta,omitempty"`

	Native struct {
		ClusterSet     string               `json:"clusterSet,omitempty"`
		ClusterId      string               `json:"clusterId,omitempty"`
		ViaGatewayHTTP string               `json:"viaGatewayHttp,omitempty"`
		ViaGatewayGRPC string               `json:"viaGatewayGrpc,omitempty"`
		ViaGatewayMode ctv1.WithGatewayMode `json:"viaGatewayMode,omitempty"`
	} `json:"native"`
	Local struct {
		InternalService   bool                                      `json:"internalService,omitempty"`
		WithGateway       bool                                      `json:"withGateway,omitempty"`
		WithMultiGateways bool                                      `json:"withMultiGateways,omitempty"`
		BindFgwPorts      map[MicroServicePort]MicroServiceProtocol `json:"bindFgwPorts,omitempty"`
	} `json:"local"`
}

MicroEndpointMeta defines micro endpoint meta

func (*MicroEndpointMeta) Init added in v1.3.8

func (m *MicroEndpointMeta) Init(controller ConnectController, discClient ServiceDiscoveryClient)

type MicroService added in v1.2.2

type MicroService struct {
	ctv1.NamespacedService
	// contains filtered or unexported fields
}

func (*MicroService) Endpoint added in v1.5.0

func (s *MicroService) Endpoint() *MicroServiceEndpoint

func (*MicroService) EndpointAddress added in v1.5.0

func (s *MicroService) EndpointAddress() *MicroServiceAddress

func (*MicroService) EndpointPort added in v1.5.0

func (s *MicroService) EndpointPort() *MicroServicePort

func (*MicroService) Protocol added in v1.5.0

func (s *MicroService) Protocol() *MicroServiceProtocol

func (*MicroService) SetGRPCPort added in v1.5.0

func (s *MicroService) SetGRPCPort(port int32)

func (*MicroService) SetHTTPPort added in v1.5.0

func (s *MicroService) SetHTTPPort(port int32)

func (*MicroService) Via added in v1.5.0

func (s *MicroService) Via() *MicroServiceVia

type MicroServiceAddress added in v1.5.0

type MicroServiceAddress string

MicroServiceAddress defines string as microservice address

func (*MicroServiceAddress) Get added in v1.5.0

func (a *MicroServiceAddress) Get() string

func (*MicroServiceAddress) Set added in v1.5.0

func (a *MicroServiceAddress) Set(addr string)

func (*MicroServiceAddress) To4 added in v1.5.0

func (a *MicroServiceAddress) To4() net.IP

To4 converts the IPv4 address ip to a 4-byte representation. If ip is not an IPv4 address, To4 returns nil.

func (*MicroServiceAddress) To16 added in v1.5.0

func (a *MicroServiceAddress) To16() net.IP

To16 converts the IP address ip to a 16-byte representation. If ip is not an IP address (it is the wrong length), To16 returns nil.

type MicroServiceEndpoint added in v1.5.0

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

func (*MicroServiceEndpoint) Get added in v1.5.0

func (*MicroServiceEndpoint) Set added in v1.5.0

type MicroServicePort added in v1.5.0

type MicroServicePort int32

MicroServicePort defines int as microservice port

func (*MicroServicePort) Get added in v1.5.0

func (p *MicroServicePort) Get() int32

func (*MicroServicePort) Set added in v1.5.0

func (p *MicroServicePort) Set(port int32)

type MicroServiceProtocol added in v1.5.0

type MicroServiceProtocol string

MicroServiceProtocol defines string as microservice protocol

func (*MicroServiceProtocol) Empty added in v1.5.0

func (p *MicroServiceProtocol) Empty() bool

func (*MicroServiceProtocol) Get added in v1.5.0

func (p *MicroServiceProtocol) Get() string

func (*MicroServiceProtocol) Set added in v1.5.0

func (p *MicroServiceProtocol) Set(protocol string)

func (*MicroServiceProtocol) SetVar added in v1.5.0

func (p *MicroServiceProtocol) SetVar(protocol MicroServiceProtocol)

type MicroServiceVia added in v1.5.0

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

func (*MicroServiceVia) Get added in v1.5.0

func (*MicroServiceVia) Set added in v1.5.0

func (v *MicroServiceVia) Set(viaAddress MicroServiceAddress, viaPort MicroServicePort)

type MicroSvcMeta

type MicroSvcMeta struct {
	Ports       map[MicroServicePort]MicroServicePort      `json:"-"`
	TargetPorts map[MicroServicePort]MicroServiceProtocol  `json:"ports,omitempty"`
	Endpoints   map[MicroServiceAddress]*MicroEndpointMeta `json:"endpoints,omitempty"`

	GRPCMeta *GRPCMeta `json:"grpcMeta,omitempty"`

	HealthCheck bool `json:"healthcheck,omitempty"`
}

MicroSvcMeta defines micro service meta

func Decode added in v1.3.8

func Decode(svc *corev1.Service, enc string) *MicroSvcMeta

func (*MicroSvcMeta) Marshal added in v1.3.8

func (m *MicroSvcMeta) Marshal() string

func (*MicroSvcMeta) Unmarshal added in v1.3.8

func (m *MicroSvcMeta) Unmarshal(str string)

type QueryOptions added in v1.2.1

type QueryOptions struct {
	// AllowStale allows any Consul server (non-leader) to service
	// a read. This allows for lower latency and higher throughput
	AllowStale bool

	// Namespace overrides the `default` namespace
	// Note: Namespaces are available only in Consul Enterprise
	Namespace string

	// WaitIndex is used to enable a blocking query. Waits
	// until the timeout or the next index is reached
	WaitIndex uint64

	// WaitTime is used to bound the duration of a wait.
	// Defaults to that of the Config, but can be overridden.
	WaitTime time.Duration

	// Providing a peer name in the query option
	Peer string

	// Filter requests filtering data prior to it being returned. The string
	// is a go-bexpr compatible expression.
	Filter string
	// contains filtered or unexported fields
}

QueryOptions are used to parameterize a query

func (*QueryOptions) Context added in v1.2.1

func (o *QueryOptions) Context() context.Context

func (*QueryOptions) ToConsul added in v1.2.1

func (o *QueryOptions) ToConsul() *consul.QueryOptions

func (*QueryOptions) WithContext added in v1.2.1

func (o *QueryOptions) WithContext(ctx context.Context) *QueryOptions

type Resource

type Resource interface {
	// Informer returns the SharedIndexInformer that the controller will
	// use to watch for changes. An Informer is the long-running task that
	// holds blocking queries to K8S and stores data in a local store.
	Informer() cache.SharedIndexInformer

	// Upsert is the callback called when processing the queue
	// of changes from the Informer. If an error is returned, the given item
	// will be retried.
	Upsert(key string, obj interface{}) error
	// Delete is called on object deletion.
	// obj is the last known state of the object before deletion. In some
	// cases, it may not be up to date with the latest state of the object.
	// If an error is returned, the given item will be retried.
	Delete(key string, obj interface{}) error
}

Resource should be implemented by anything that should be watchable by CacheController. The Resource needs to be aware of how to create the Informer that is responsible for making API calls as well as what to do on Upsert and Delete.

type ResourceDeleteFunc added in v1.2.1

type ResourceDeleteFunc func(string, interface{}) error

type ResourceUpsertFunc added in v1.2.1

type ResourceUpsertFunc func(string, interface{}) error

ResourceUpsertFunc and ResourceDeleteFunc are the callback types for when a resource is inserted, updated, or deleted.

type ServiceAddress added in v1.2.1

type ServiceAddress struct {
	HostName string
	Port     int32
}

type ServiceConversion added in v1.5.0

type ServiceConversion struct {
	Service CloudSvcName
}

type ServiceDiscoveryClient added in v1.2.1

type ServiceDiscoveryClient interface {
	CatalogServices(q *QueryOptions) ([]ctv1.NamespacedService, error)
	CatalogInstances(service string, q *QueryOptions) ([]*AgentService, error)
	RegisteredInstances(service string, q *QueryOptions) ([]*CatalogService, error)
	RegisteredServices(q *QueryOptions) ([]ctv1.NamespacedService, error)
	Register(reg *CatalogRegistration) error
	Deregister(dereg *CatalogDeregistration) error
	EnableNamespaces() bool
	EnsureNamespaceExists(ns string) (bool, error)
	RegisteredNamespace(kubeNS string) string
	MicroServiceProvider() ctv1.DiscoveryServiceProvider
	IsInternalServices() bool
	Close()
}

type ServiceInstanceIDFunc added in v1.2.1

type ServiceInstanceIDFunc func(name, addr string, port MicroServicePort, protocol MicroServiceProtocol) string

Directories

Path Synopsis
Package ctok implements a syncer from cloud to k8s.
Package ctok implements a syncer from cloud to k8s.

Jump to

Keyboard shortcuts

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