Skip to content

bwplotka/go-k8sresolver

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 

NOTE

This project was moved and incorporated by kedge project and is maintained here: https://github.com/improbable-eng/kedge/tree/master/pkg/resolvers/k8s Please feel free to add issue to this project if you would like to have standalone library instead for this useful feature.

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

See example

resolver, err := k8sresolver.NewFromFlags()
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.
}