k8s

package
v0.0.0-...-de984a2 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package k8s communicates with Kubernetes to watch nodes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WatchNodes

func WatchNodes(ctx context.Context, master, kubeconfig string, resync time.Duration, store cache.Store) error

WatchNodes connects to the k8s API server (using an in-cluster configuration if kubconfig and master are empty), watches nodes until the provided context is finished, and publishes any changes to the provided cache.Store.

The provided watcher will be resync'd at a scheduled interval regardless of any changes if resync is non-zero.

Types

type Node

type Node struct {
	Name     string
	Internal []net.IP
	External []net.IP
}

Node contains Address information about Kubernetes nodes.

type NodeStore

type NodeStore struct {
	sync.Mutex
	Name     string              // The name of the NodeStore, for observability (logging, metrics, tracing).
	Timeout  time.Duration       // How long to block (worst case) on events.
	OnChange func(UpdateRequest) // A function that will be called whenever DNS records change.
	Logger   *zap.Logger
	// contains filtered or unexported fields
}

NodeStore is a cache.Store that maintains the full set of nodes, and notifies interested parties of changes.

func NewNodeStore

func NewNodeStore(name string) *NodeStore

NewNodeStore returns an initialized NodeStore.

func (*NodeStore) Add

func (s *NodeStore) Add(obj interface{}) error

Add implements cache.Store.

func (*NodeStore) Delete

func (s *NodeStore) Delete(obj interface{}) error

Delete implements cache.Store.

func (*NodeStore) Get

func (s *NodeStore) Get(obj interface{}) (item interface{}, exists bool, err error)

func (*NodeStore) GetByKey

func (s *NodeStore) GetByKey(key string) (item interface{}, exists bool, err error)

func (*NodeStore) List

func (s *NodeStore) List() []interface{}

We only implement cache.Store for cache.Reflector, and cache.Reflector does not call List/Get methods.

func (*NodeStore) ListKeys

func (s *NodeStore) ListKeys() []string

func (*NodeStore) Replace

func (s *NodeStore) Replace(objs []interface{}, unusedResourceVersion string) error

Replace implements cache.Store.

func (*NodeStore) Resync

func (s *NodeStore) Resync() error

Resync implements cache.Store.

func (*NodeStore) Update

func (s *NodeStore) Update(obj interface{}) error

Update implements cache.Store.

type Record

type Record struct {
	IsInternal bool // Whether this record contains internal IPs or external IPs.
	IPs        []net.IP
}

Record is a DNS record that contains the full set of nodes.

type UpdateRequest

type UpdateRequest struct {
	Ctx    context.Context
	Record Record
}

UpdateRequest is a request to change a DNS address.

Jump to

Keyboard shortcuts

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