k8s

package
v0.2.10-3 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// LabelsKeyServiceID is used to define the ID of the service
	LabelsKeyServiceID = "lava-service-id"
	// LabelsKeyServiceName is used to define the name of the service
	LabelsKeyServiceName = "lava-service-app"
	// LabelsKeyServiceVersion is used to define the version of the service
	LabelsKeyServiceVersion = "lava-service-version"
	// AnnotationsKeyMetadata is used to define the metadata of the service
	AnnotationsKeyMetadata = "lava-service-metadata"
	// AnnotationsKeyProtocolMap is used to define the protocols of the service
	// Through the value of this field, lava can obtain the application layer protocol corresponding to the port
	// Example value: {"80": "http", "8081": "grpc"}
	AnnotationsKeyProtocolMap = "lava-service-protocols"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cfg

type Cfg struct {
	// kube namespace
	Namespace string
	// kube labelSelector example `app=test`
	LabelSelector string
	// kube fieldSelector example `app=test`
	FieldSelector string
	// set KubeConfig out-of-cluster Use outside cluster
	KubeConfig string
	// set master url
	Master   string
	Filename string
}

func (*Cfg) Build

func (t *Cfg) Build() *kubernetes.Clientset

type Registry

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

Registry The registry simply implements service discovery based on Kubernetes It has not been verified in the production environment and is currently for reference only

func NewRegistry

func NewRegistry(clientSet *kubernetes.Clientset) *Registry

NewRegistry is used to initialize the Registry

func (*Registry) Close

func (s *Registry) Close()

func (*Registry) Deregister

func (s *Registry) Deregister(service *registry.Service, opt ...registry.DeregOpt) result.Error

func (*Registry) GetService

func (s *Registry) GetService(name string, opt ...registry.GetOpt) result.List[*registry.Service]

func (*Registry) Init

func (s *Registry) Init()

func (*Registry) ListService

func (s *Registry) ListService(opt ...registry.ListOpt) result.List[*registry.Service]

func (*Registry) Register

func (s *Registry) Register(service *registry.Service, opt ...registry.RegOpt) result.Error

Register is used to register services Note that on Kubernetes, it can only be used to update the id/name/version/metadata/protocols of the current service, but it cannot be used to update node.

func (*Registry) String

func (s *Registry) String() string

func (*Registry) Watch

func (s *Registry) Watch(name string, opt ...registry.WatchOpt) result.Result[registry.Watcher]

Watch creates a watcher according to the service name.

type Watcher

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

Watcher performs the conversion from channel to iterator It reads the latest changes from the `chan []*registry.ServiceInstance` And the outside can sense the closure of Watcher through stopCh

func (*Watcher) Next

func (t *Watcher) Next() result.Result[*registry.Result]

Next will block until ServiceInstance changes

func (*Watcher) Stop

func (t *Watcher) Stop() error

Stop is used to close the iterator

Jump to

Keyboard shortcuts

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