k8s

package
v0.0.0-...-e1a04f4 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LogNode = false

Functions

This section is empty.

Types

type K8SData

type K8SData struct {
	// Common model for the 'machines' database. Multiple sources of authoritative info are merged.
	MDB *MDB

	//
	IPToSrc sync.Map
	PodInfo sync.Map

	Pods atomic.Int32

	Slices   atomic.Int32
	SliceIPs atomic.Int32
	// contains filtered or unexported fields
}

K8SData holds the data for one K8S cluster.

func (*K8SData) OnAdd

func (k *K8SData) OnAdd(obj interface{}, isInInitialList bool)

func (*K8SData) OnDelete

func (k *K8SData) OnDelete(obj interface{})

func (*K8SData) OnUpdate

func (k *K8SData) OnUpdate(old, new interface{})

type K8SIPWatcher

type K8SIPWatcher struct {

	// User data structures and callbacks. No direct deps on informers
	*K8SData
	Stop chan struct{}
	// contains filtered or unexported fields
}

K8SIPWatcher watches pods, nodes, services and endpoints/slices to find IPs - using the shared informers.

The informer machinery creates an in-memory replica of the K8S data from etcd, with callbacks on changes.

TODO: also istio serviceentry and workloadentry ?

func Start

func Start(kd *K8SData, config *rest.Config) (*K8SIPWatcher, error)

Start watching K8S, based on the config. The initial sync will happen in background - main() can do other initialization, but before readiness must call WaitForSync.

Will create 'clientsets' using generated code for strong-typed access to objects, as well as strong-typed listeners and informer objects.

func (*K8SIPWatcher) WaitForInit

func (c *K8SIPWatcher) WaitForInit(stopCh chan struct{}) error

Run is used to wait for the sync to happen, and switch from initial sync to 'events' mode.

type MDB

type MDB struct {
	IPToW sync.Map

	NameToW sync.Map

	Services sync.Map
}

Objects to consider:

Pod Node Service EndpointSlice Endpoints Gateway

Istio: WorkloadEntry ServiceEntry

kind: EndpointSlice metadata:

name: example-abc
labels:
  kubernetes.io/service-name: example

addressType: IPv4 ports:

  • name: http protocol: TCP port: 80

endpoints:

  • addresses:
  • "10.1.2.3" conditions: ready: true hostname: pod-1 nodeName: node-1 zone: us-west2-a

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳