Version: v0.0.0-...-6719cd2 Latest Latest

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

Go to latest
Published: Jul 18, 2019 License: Apache-2.0 Imports: 10 Imported by: 0



Package kubediscovery provides an implementation of the Locator interface backed by Kubernetes service discovery.



This section is empty.


This section is empty.


This section is empty.


type KubeClient

type KubeClient struct {
	// contains filtered or unexported fields

KubeClient is a client to interact with the Kubernetes cluster. It's a connection to the Kubernetes API service in the same Kubernetes cluster as this container.

func NewKubeClient

func NewKubeClient() (*KubeClient, error)

NewKubeClient creates a new KubeClient instance. It returns an error if its not running inside the Kubernetes cluster. The caller should create a single instance of KubeClient to create many Locators.

func (*KubeClient) NewLocator

func (client *KubeClient) NewLocator(ctx context.Context, portName string, selector string) (discovery.Locator, error)

NewLocator creates a new Locator to discover Endpoints using Kubernetes service discovery.

The Locator returns endpoints running in the same Kubernetes namespace as this process. To do so, it finds pods by the given label selector; see https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors. It searches each container within such pods and returns a discovery.Endpoint for each container's port that matches the given name.

The returned Locator will stop receiving updates when the supplied context is canceled/expired.

It returns an error when the client connection doesn't have enough privileges to communicate to Kubernetes API service or the given label selector syntax is invalid. Refer https://kubernetes.io/docs/reference/access-authn-authz/rbac/ to create Kubernetes Role-based-access-control settings to allow the process to find other pods.

Source Files

Jump to

Keyboard shortcuts

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