k8s

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EndpointsForService added in v0.2.0

func EndpointsForService(
	ctx context.Context,
	ns,
	serviceName,
	servicePort string,
	endpointsFn GetEndpointsFunc,
) ([]*url.URL, error)

func FakeEndpointsForURL added in v0.2.0

func FakeEndpointsForURL(
	u *url.URL,
	namespace,
	name string,
	num int,
) (*v1.Endpoints, error)

FakeEndpointsForURL creates and returns a new *v1.Endpoints with a single v1.EndpointSubset in it, which has num v1.EndpointAddresses in it. Each of those EndpointAddresses has a Hostname and IP both equal to u.Hostname()

func FakeEndpointsForURLs added in v0.2.0

func FakeEndpointsForURLs(
	urls []*url.URL,
	namespace,
	name string,
) (*v1.Endpoints, error)

FakeEndpointsForURLs creates and returns a new *v1.Endpoints with a single v1.EndpointSubset in it that has each url in the urls parameter in it.

func Int32P added in v0.1.0

func Int32P(i int32) *int32

Int32P converts an int32 into an *int32. It's a convenience function for various values in Kubernetes API types

func NamespacedNameFromObject added in v0.5.0

func NamespacedNameFromObject(obj client.Object) *types.NamespacedName

func NamespacedNameFromScaledObjectRef added in v0.5.0

func NamespacedNameFromScaledObjectRef(sor *externalscaler.ScaledObjectRef) *types.NamespacedName

func NewScaledObject

func NewScaledObject(
	namespace string,
	name string,
	workloadRef v1alpha1.ScaleTargetRef,
	scalerAddress string,
	hosts []string,
	pathPrefixes []string,
	minReplicas *int32,
	maxReplicas *int32,
	cooldownPeriod *int32,
) *kedav1alpha1.ScaledObject

NewScaledObject creates a new ScaledObject in memory

func ObjectKind added in v0.5.0

func ObjectKind(obj runtime.Object) string

Types

type EndpointsCache added in v0.7.0

type EndpointsCache interface {
	json.Marshaler
	// Get gets the endpoints with the given name
	// in the given namespace from the cache.
	//
	// If the endpoints doesn't exist in the cache, it
	// will be requested from the backing store (most commonly
	// the Kubernetes API server)
	Get(namespace, name string) (v1.Endpoints, error)
	// Watch opens a watch stream for the endpoints with
	// the given name in the given namespace from the cache.
	//
	// If the endpoints don't exist in the cache, it
	// will be requested from the backing store (most commonly
	// the Kubernetes API server)
	Watch(namespace, name string) (watch.Interface, error)
}

EndpointsCache is a simple cache of endpoints. It allows callers to quickly get given endpoints in a given namespace, or watch for changes to specific endpoints, all without incurring the cost of issuing a network request to the Kubernetes API

type FakeEndpointsCache added in v0.7.0

type FakeEndpointsCache struct {
	json.Marshaler
	// contains filtered or unexported fields
}

FakeEndpointsCache is a fake implementation of EndpointsCache, suitable for testing interceptor-level logic, without requiring any real Kubernetes client or API interaction

func NewFakeEndpointsCache added in v0.7.0

func NewFakeEndpointsCache() *FakeEndpointsCache

func (*FakeEndpointsCache) Get added in v0.7.0

func (f *FakeEndpointsCache) Get(ns string, name string) (v1.Endpoints, error)

func (*FakeEndpointsCache) GetWatcher added in v0.7.0

func (f *FakeEndpointsCache) GetWatcher(ns, name string) *watch.RaceFreeFakeWatcher

GetWatcher gets the watcher for the given namespace and name, or nil if there wasn't one registered.

Watchers are registered by the .Watch() method

func (*FakeEndpointsCache) MarshalJSON added in v0.7.0

func (f *FakeEndpointsCache) MarshalJSON() ([]byte, error)

func (*FakeEndpointsCache) Set added in v0.7.0

func (f *FakeEndpointsCache) Set(endp v1.Endpoints)

Set adds a endpoints to the current in-memory cache without sending an event to any of the watchers

func (*FakeEndpointsCache) SetSubsets added in v0.7.0

func (f *FakeEndpointsCache) SetSubsets(ns, name string, num int) error

func (*FakeEndpointsCache) SetWatcher added in v0.7.0

func (f *FakeEndpointsCache) SetWatcher(ns, name string) *watch.RaceFreeFakeWatcher

SetWatcher creates a new race-free fake watcher and sets it into the internal watchers map. After this call, a call to Watch() with the same namespace and name values will return a valid watcher

func (*FakeEndpointsCache) Watch added in v0.7.0

func (f *FakeEndpointsCache) Watch(ns, name string) (watch.Interface, error)

type GetEndpointsFunc added in v0.2.0

type GetEndpointsFunc func(
	ctx context.Context,
	namespace,
	serviceName string,
) (*v1.Endpoints, error)

GetEndpointsFunc is a type that represents a function that can fetch endpoints

func EndpointsFuncForControllerClient added in v0.2.0

func EndpointsFuncForControllerClient(
	cl client.Client,
) GetEndpointsFunc

EndpointsFuncForControllerClient returns a new GetEndpointsFunc that uses the controller-runtime client.Client to fetch endpoints

func EndpointsFuncForK8sClientset added in v0.2.0

func EndpointsFuncForK8sClientset(
	cl *kubernetes.Clientset,
) GetEndpointsFunc

type InformerBackedEndpointsCache added in v0.7.0

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

func NewInformerBackedEndpointsCache added in v0.7.0

func NewInformerBackedEndpointsCache(
	lggr logr.Logger,
	cl kubernetes.Interface,
	defaultResync time.Duration,
) *InformerBackedEndpointsCache

func (*InformerBackedEndpointsCache) Get added in v0.7.0

func (i *InformerBackedEndpointsCache) Get(
	ns,
	name string,
) (v1.Endpoints, error)

func (*InformerBackedEndpointsCache) MarshalJSON added in v0.7.0

func (i *InformerBackedEndpointsCache) MarshalJSON() ([]byte, error)

func (*InformerBackedEndpointsCache) Start added in v0.7.0

func (*InformerBackedEndpointsCache) Watch added in v0.7.0

func (i *InformerBackedEndpointsCache) Watch(
	ns,
	name string,
) (watch.Interface, error)

Jump to

Keyboard shortcuts

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