k8sresolver

package
v0.0.0-...-2d7a0ec Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2017 License: Apache-2.0 Imports: 25 Imported by: 0

README

k8sresolver

Kubernetes resolver based on endpoint API

Inspired by https://github.com/sercand/kuberesolver but more suitable for our needs.

Features:

  • K8s resolver that watches endpoint API
  • Different types of auth for kube-apiserver access. (You can run it easily from your local machine as well!)
  • URL in common kube-DNS format: <service>.<namespace>(|.<any suffix>):<port|port name>

Still todo:

  • Metrics
  • Fallback to SRV (?)

Usage

resolver, err := k8sresolver.NewFromFlags(nil)
if err != nil {
    // handle err.
}

watcher, err := resolver.Resolve(target)
if err != nil {
    // handle err.
}

// Wait for next updates.
updates, err := watcher.Next()
if err != nil {
    // handle err.
}

Documentation

Index

Constants

View Source
const (

	// ExpectedTargetFmt is an expected format of the targetEntry Name given to Resolver. This is complainant with
	// the kubeDNS/CoreDNS entry format.
	ExpectedTargetFmt = "<service>(|.<namespace>)(|.<whatever suffix>)(|:<port_name>|:<value number>)"
)

Variables

This section is empty.

Functions

func New

func New(logger logrus.FieldLogger, k8sURL string, source tokenauth.Source, tlsConfig *tls.Config) naming.Resolver

New returns a new Kubernetes resolver with HTTP client (based on given tokenauth Source and tlsConfig) to be used against kube-apiserver.

func NewFromConfig

func NewFromConfig(conf *pb.K8SResolver) (target string, name naming.Resolver, err error)

func NewFromFlags

func NewFromFlags(logger logrus.FieldLogger) (naming.Resolver, error)

NewFromFlags creates resolver from flag from k8sresolver.sharedflags.Set.

func NewWithClient

func NewWithClient(logger logrus.FieldLogger, k8sURL string, k8sClient *http.Client) naming.Resolver

NewWithClient returns a new Kubernetes resolver using given http.Client configured to be used against kube-apiserver.

Types

This section is empty.

Jump to

Keyboard shortcuts

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