kube

package
v0.35.2 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: Apache-2.0 Imports: 29 Imported by: 33

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MCreates        = stats.Int64("kube/creates", "The number of creates", "1")
	CreateCountView = &view.View{
		Name:        "kube/creates-count",
		Measure:     MCreates,
		Description: "The number of create calls",
		Aggregation: view.Count(),
		TagKeys: []tag.Key{
			KeyKind,
		},
	}
	MUpdates        = stats.Int64("kube/updates", "The number of updates", "1")
	UpdateCountView = &view.View{
		Name:        "kube/updates-count",
		Measure:     MUpdates,
		Description: "The number of update calls",
		Aggregation: view.Count(),
		TagKeys: []tag.Key{
			KeyKind,
		},
	}

	MDeletes        = stats.Int64("kube/deletes", "The number of deletes", "1")
	DeleteCountView = &view.View{
		Name:        "kube/deletes-count",
		Measure:     MDeletes,
		Description: "The number of delete calls",
		Aggregation: view.Count(),
		TagKeys: []tag.Key{
			KeyKind,
		},
	}

	KeyOpKind, _ = tag.NewKey("op")

	MInFlight       = stats.Int64("kube/req_in_flight", "The number of requests in flight", "1")
	InFlightSumView = &view.View{
		Name:        "kube/req-in-flight",
		Measure:     MInFlight,
		Description: "The number of requests in flight",
		Aggregation: view.Sum(),
		TagKeys: []tag.Key{
			KeyOpKind,
			KeyKind,
		},
	}

	MEvents         = stats.Int64("kube/events", "The number of events", "1")
	EventsCountView = &view.View{
		Name:        "kube/events-count",
		Measure:     MEvents,
		Description: "The number of events sent from kuberenets to us",
		Aggregation: view.Count(),
	}
)
View Source
var (
	MLists   = stats.Int64("kube/lists", "The number of lists", "1")
	MWatches = stats.Int64("kube/watches", "The number of watches", "1")

	KeyKind, _          = tag.NewKey("kind")
	KeyNamespaceKind, _ = tag.NewKey("ns")

	ListCountView = &view.View{
		Name:        "kube/lists-count",
		Measure:     MLists,
		Description: "The number of list calls",
		Aggregation: view.Count(),
		TagKeys: []tag.Key{
			KeyKind,
			KeyNamespaceKind,
		},
	}
	WatchCountView = &view.View{
		Name:        "kube/watches-count",
		Measure:     MWatches,
		Description: "The number of watch calls",
		Aggregation: view.Count(),
		TagKeys: []tag.Key{
			KeyKind,
			KeyNamespaceKind,
		},
	}
)

Functions

func NewSharedInformer added in v0.10.8

func NewSharedInformer(ctx context.Context, resyncPeriod time.Duration, objType runtime.Object,
	listFunc func(options metav1.ListOptions) (runtime.Object, error),
	watchFunc func(context.Context, metav1.ListOptions) (kubewatch.Interface, error)) cache.SharedIndexInformer

func NotEmptyValue added in v0.10.8

func NotEmptyValue(ns string) string

Types

type KubeWriteOpts

type KubeWriteOpts struct {
	PreWriteCallback func(r *v1.Resource)
}

Kuberenetes specific write options. Allows modifing a resource just before it is written. This allows to make kubernetes specific changes, like adding an owner reference.

func (*KubeWriteOpts) StorageWriteOptsTag

func (*KubeWriteOpts) StorageWriteOptsTag()

type ResourceClient

type ResourceClient struct {
	// contains filtered or unexported fields
}

lazy start in list & watch register informers in register

func NewResourceClient

func NewResourceClient(
	crd crd.Crd,
	clientset versioned.Interface,
	sharedCache SharedCache,
	resourceType resources.InputResource,
	namespaceWhitelist []string,
	resyncPeriod time.Duration,
	resourceStatusUnmarshaler resources.StatusUnmarshaler,
) *ResourceClient

func (*ResourceClient) ApplyStatus added in v0.30.3

func (rc *ResourceClient) ApplyStatus(statusClient resources.StatusClient, inputResource resources.InputResource, opts clients.ApplyStatusOpts) (resources.Resource, error)

func (*ResourceClient) Delete

func (rc *ResourceClient) Delete(namespace, name string, opts clients.DeleteOpts) error

func (*ResourceClient) Kind

func (rc *ResourceClient) Kind() string

func (*ResourceClient) List

func (rc *ResourceClient) List(namespace string, opts clients.ListOpts) (resources.ResourceList, error)

func (*ResourceClient) NewResource

func (rc *ResourceClient) NewResource() resources.Resource

func (*ResourceClient) Read

func (rc *ResourceClient) Read(namespace, name string, opts clients.ReadOpts) (resources.Resource, error)

func (*ResourceClient) Register

func (rc *ResourceClient) Register() error

Registers the client with the shared cache. The cache will create a dedicated informer to list and watch resources of kind rc.Kind() in the namespaces given in rc.namespaceWhitelist.

func (*ResourceClient) Watch

func (rc *ResourceClient) Watch(namespace string, opts clients.WatchOpts) (<-chan resources.ResourceList, <-chan error, error)

func (*ResourceClient) Write

type ResourceClientSharedInformerFactory

type ResourceClientSharedInformerFactory struct {
	// contains filtered or unexported fields
}

The ResourceClientSharedInformerFactory creates a SharedIndexInformer for each of the clients that register with it and, when started, creates a kubernetes controller that distributes notifications for changes to the watches that have been added to the factory. All direct operations on the ResourceClientSharedInformerFactory are synchronized.

func (*ResourceClientSharedInformerFactory) AddWatch

func (f *ResourceClientSharedInformerFactory) AddWatch(bufferSize uint) <-chan v1.Resource

Adds a watch with the given buffer size to the factory.

func (*ResourceClientSharedInformerFactory) GetLister

func (*ResourceClientSharedInformerFactory) Informers

Not part of the interface (used for testing)

func (*ResourceClientSharedInformerFactory) IsClusterCache added in v0.11.1

func (f *ResourceClientSharedInformerFactory) IsClusterCache()

func (*ResourceClientSharedInformerFactory) IsRunning

Not part of the interface (used for testing)

func (*ResourceClientSharedInformerFactory) Register

Creates a new SharedIndexInformer and adds it to the factory's informer registry. NOTE: Currently we cannot share informers between resource clients, because the listWatch functions are configured with the client's specific token. Hence, we must enforce a one-to-one relationship between informers and clients.

func (*ResourceClientSharedInformerFactory) RemoveWatch

func (f *ResourceClientSharedInformerFactory) RemoveWatch(c <-chan v1.Resource)

Removes the given watch to the factory. A call to this method should be deferred passing the channel returned by AddWatch wherever a watch is added.

func (*ResourceClientSharedInformerFactory) Start

Starts all informers in the factory's registry (if they have not yet been started) and configures the factory to call the updateCallback function whenever any of the resources associated with the informers changes.

type ResourceLister

type ResourceLister interface {
	List(selector labels.Selector) (ret []*v1.Resource, err error)
}

type SharedCache

type SharedCache interface {
	// Registers the client with the shared cache
	Register(rc *ResourceClient) error
	// Starts all informers in the factory's registry. Must be idempotent.
	Start()
	// Returns a lister for resources of the given type in the given namespace.
	GetLister(namespace string, obj runtime.Object) (ResourceLister, error)
	// Returns a channel that will receive notifications on changes to resources
	// managed by clients that have registered with the factory.
	// Clients must specify a size for the buffer of the channel they will
	// receive notifications on.
	AddWatch(bufferSize uint) <-chan v1.Resource
	// Removed the given channel from the watches added to the cache
	RemoveWatch(c <-chan v1.Resource)
}

func NewKubeCache

func NewKubeCache(ctx context.Context) SharedCache

start uses this context, runs until context gets cancelled

Directories

Path Synopsis
crd
client/clientset/versioned
This package has the automatically generated clientset.
This package has the automatically generated clientset.
client/clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
client/clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
client/clientset/versioned/typed/solo.io/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
client/clientset/versioned/typed/solo.io/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
solo.io/v1
Package v1 is the v1 version of the API.
Package v1 is the v1 version of the API.

Jump to

Keyboard shortcuts

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