Documentation ¶
Overview ¶
Package kuberegister registry simply implements the kubernetes-base Registry
Index ¶
- Constants
- Variables
- func GetNamespace() string
- func GetPodName() string
- func LoadNamespace() string
- type ErrorHandleResource
- type Iterator
- type Registry
- func (r *Registry) Close()
- func (r *Registry) Deregister(ctx context.Context, _ *registry.ServiceInstance) error
- func (r *Registry) GetService(_ context.Context, serviceName string) ([]*registry.ServiceInstance, error)
- func (r *Registry) Register(ctx context.Context, service *registry.ServiceInstance) error
- func (r *Registry) Start()
- func (r *Registry) Watch(ctx context.Context, serviceName string) (registry.Watcher, error)
Constants ¶
const ( LabelsKeyServiceID = "rushgo-service-id" // LabelsKeyServiceID is used to define the ID of the service LabelsKeyServiceName = "rushgo-service-name" // LabelsKeyServiceName is used to define the name of the service LabelsKeyServiceVersion = "rushgo-service-version" // LabelsKeyServiceVersion is used to define the version of the service AnnotationsKeyMetadata = "rushgo-service-metadata" // AnnotationsKeyMetadata is used to define the metadata of the service // AnnotationsKeyProtocolMap is used to define the protocols of the service // Through the value of this field, we can obtain the application layer protocol corresponding to the port. // example value: {"80": "http", "8081": "grpc"} AnnotationsKeyProtocolMap = "rushgo-service-protocols" )
Defines the key name of specific fields rushgo needs to cooperate with the following fields to run properly on kubernetes: rushgo-service-id: define the ID of the service rushgo-service-name: define the name of the service rushgo-service-version: define the version of the service rushgo-service-metadata: define the metadata of the service rushgo-service-protocols: define the protocols of the service
Example Deployment:
apiVersion: apps/v1 kind: Deployment metadata:
name: nginx labels: app: nginx
spec:
replicas: 2 selector: matchLabels: app: nginx template: metadata: labels: app: nginx rushgo-service-id: "da5c8329-29ac-411d-b1f0-d9364b313f3e" rushgo-service-name: "nginx" rushgo-service-version: "v1.27.0" annotations: rushgo-service-metadata: | {"region": "sh", "zone": "sh001", "cluster": "pd"} rushgo-service-protocols: | {"80": "http", "8081": "grpc"} spec: containers: - name: nginx image: nginx:1.27.0 ports: - containerPort: 80
const ServiceAccountNamespacePath = "/var/run/secrets/kubernetes.io/serviceaccount/namespace"
Variables ¶
var ErrIteratorClosed = errors.New("iterator closed")
ErrIteratorClosed defines the error that the iterator is closed
Functions ¶
func GetNamespace ¶
func GetNamespace() string
func GetPodName ¶
func GetPodName() string
func LoadNamespace ¶
func LoadNamespace() string
Types ¶
type ErrorHandleResource ¶
ErrorHandleResource defines the error that failed to handle kubernetes resources
func (*ErrorHandleResource) Error ¶
func (err *ErrorHandleResource) Error() string
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator 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 Iterator through stopCh.
func NewIterator ¶
func NewIterator(channel chan []*registry.ServiceInstance, stopCh chan struct{}) *Iterator
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry(clientSet *kubernetes.Clientset) *Registry
NewRegistry initialize the Registry