k8s

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultNamespace added in v1.7.0

func DefaultNamespace(ns string) func(name *types.NamespacedName)

DefaultNamespace can be used with NamespacedNameFrom to set the default namespace for a resource name that may not be qualified by a namespace.

func InitLogging added in v1.9.0

func InitLogging(options ...LogOption)

InitLogging initializes the Kubernetes client-go logging subsystem.

func IsObjectEqual added in v1.25.0

func IsObjectEqual(oldObj, newObj client.Object) (bool, error)

IsObjectEqual checks if objects received during update are equal.

Make an attempt to avoid comparing full objects since it can be very CPU intensive. Prefer comparing Generation when only interested in spec changes.

func KindOf added in v1.1.0

func KindOf(obj any) string

KindOf returns the kind string for the given Kubernetes object.

The API machinery doesn't populate the meta_v1.TypeMeta field for objects, so we have to use a type assertion to detect kinds that we care about.

func NamespacedNameFrom added in v1.7.0

func NamespacedNameFrom(nameStr string, opts ...func(*types.NamespacedName)) types.NamespacedName

NamespacedNameFrom parses a resource name string into a fully qualified NamespacedName.

func NamespacedNameOf added in v1.7.0

func NamespacedNameOf(obj meta_v1.Object) types.NamespacedName

NamespacedNameOf returns the NamespacedName of any given Kubernetes object.

func NewContourScheme added in v1.10.0

func NewContourScheme() (*runtime.Scheme, error)

NewContourScheme returns a scheme that includes all the API types that Contour supports as well as the core Kubernetes API types from the default scheme.

func NewCoreClient added in v1.20.0

func NewCoreClient(kubeconfig string, inCluster bool) (*kubernetes.Clientset, error)

NewCoreClient returns a new Kubernetes core API client using the supplied kubeconfig path, or the cluster environment variables if inCluster is true.

func NewNamespaceFilter added in v1.10.0

func NewNamespaceFilter(
	namespaces []string,
	next cache.ResourceEventHandler,
) cache.ResourceEventHandler

NewNamespaceFilter returns a cache.ResourceEventHandler that accepts only objects whose namespaces are included in the given slice of namespaces. Objects with matching namespaces are passed to the next handler.

func NewRestConfig added in v1.20.0

func NewRestConfig(kubeconfig string, inCluster bool, opts ...func(*rest.Config)) (*rest.Config, error)

NewRestConfig returns a *rest.Config for the supplied kubeconfig path, or the cluster environment variables if inCluster is true.

func OptSetBurst added in v1.24.0

func OptSetBurst(burst int) func(*rest.Config)

OptSetBurst returns an option function that sets Burst on a *rest.Config.

func OptSetQPS added in v1.24.0

func OptSetQPS(qps float32) func(*rest.Config)

OptSetQPS returns an option function that sets QPS on a *rest.Config.

func TLSCertAnnotationNamespace added in v1.20.0

func TLSCertAnnotationNamespace(ing *networking_v1.Ingress) func(name *types.NamespacedName)

TLSCertAnnotationNamespace can be used with NamespacedNameFrom to set the secret namespace from the "projectcontour.io/tls-cert-namespace" annotation

func VersionOf added in v1.8.0

func VersionOf(obj any) string

VersionOf returns the GroupVersion string for the given Kubernetes object.

Types

type LogOption added in v1.9.0

type LogOption func(*logParams)

func LogLevelOption added in v1.9.0

func LogLevelOption(level int) LogOption

LogLevelOption creates an option to set the Kubernetes verbose log level (1 - 10 is the standard range).

func LogWriterOption added in v1.9.0

func LogWriterOption(log *logrus.Entry) LogOption

LogWriterOption creates an option to set the Kubernetes logging output.

type ServiceStatusLoadBalancerWatcher added in v1.4.0

type ServiceStatusLoadBalancerWatcher struct {
	ServiceName string
	LBStatus    chan core_v1.LoadBalancerStatus
	Log         logrus.FieldLogger
}

ServiceStatusLoadBalancerWatcher implements ResourceEventHandler and watches for changes to the status.loadbalancer field Note that we specifically *don't* inspect inside the struct, as sending empty values is desirable to clear the status.

func (*ServiceStatusLoadBalancerWatcher) OnAdd added in v1.4.0

func (s *ServiceStatusLoadBalancerWatcher) OnAdd(obj any, _ bool)

func (*ServiceStatusLoadBalancerWatcher) OnDelete added in v1.4.0

func (s *ServiceStatusLoadBalancerWatcher) OnDelete(obj any)

func (*ServiceStatusLoadBalancerWatcher) OnUpdate added in v1.4.0

func (s *ServiceStatusLoadBalancerWatcher) OnUpdate(_, newObj any)

type StatusAddressUpdater added in v1.5.0

type StatusAddressUpdater struct {
	Logger            logrus.FieldLogger
	Cache             cache.Cache
	LBStatus          core_v1.LoadBalancerStatus
	IngressClassNames []string
	GatewayRef        *types.NamespacedName
	StatusUpdater     StatusUpdater
	// contains filtered or unexported fields
}

StatusAddressUpdater observes informer OnAdd and OnUpdate events and updates the ingress.status.loadBalancer field on all Ingress objects that match the ingress class (if used). Note that this is intended to handle updating the status.loadBalancer struct only, not more general status updates. That's a job for the StatusUpdater.

func (*StatusAddressUpdater) OnAdd added in v1.5.0

func (s *StatusAddressUpdater) OnAdd(obj any, _ bool)

OnAdd updates the given Ingress/HTTPProxy/Gateway object with the current load balancer address. Note that this method can be called concurrently from an informer or from Contour itself.

func (*StatusAddressUpdater) OnDelete added in v1.5.0

func (s *StatusAddressUpdater) OnDelete(_ any)

func (*StatusAddressUpdater) OnUpdate added in v1.5.0

func (s *StatusAddressUpdater) OnUpdate(_, newObj any)

func (*StatusAddressUpdater) Set added in v1.10.0

Set updates the LBStatus field.

type StatusMetrics added in v1.26.0

type StatusMetrics interface {
	SetStatusUpdateTotal(kind string)
	SetStatusUpdateSuccess(kind string)
	SetStatusUpdateNoop(kind string)
	SetStatusUpdateFailed(kind string)
	SetStatusUpdateConflict(kind string)
	SetStatusUpdateDuration(duration time.Duration, kind string, onError bool)
}

type StatusMutator added in v1.5.0

type StatusMutator interface {
	Mutate(obj client.Object) client.Object
}

StatusMutator is an interface to hold mutator functions for status updates.

type StatusMutatorFunc added in v1.5.0

type StatusMutatorFunc func(client.Object) client.Object

StatusMutatorFunc is a function adaptor for StatusMutators.

func (StatusMutatorFunc) Mutate added in v1.5.0

Mutate adapts the StatusMutatorFunc to fit through the StatusMutator interface.

type StatusUpdate added in v1.5.0

type StatusUpdate struct {
	NamespacedName types.NamespacedName
	Resource       client.Object
	Mutator        StatusMutator
}

StatusUpdate contains an all the information needed to change an object's status to perform a specific update. Send down a channel to the goroutine that actually writes the changes back.

func NewStatusUpdate added in v1.9.0

func NewStatusUpdate(name, namespace string, resource client.Object, mutator StatusMutator) StatusUpdate

type StatusUpdateCacher added in v1.5.0

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

StatusUpdateCacher takes status updates and applies them to a cache, to be used for testing.

func (*StatusUpdateCacher) Add added in v1.9.0

func (suc *StatusUpdateCacher) Add(name, namespace string, obj client.Object) bool

func (*StatusUpdateCacher) Get added in v1.9.0

func (suc *StatusUpdateCacher) Get(objType, name, namespace string) any

Get allows retrieval of objects from the cache.

func (*StatusUpdateCacher) GetStatus added in v1.9.0

func (suc *StatusUpdateCacher) GetStatus(obj any) (*contour_v1.HTTPProxyStatus, error)

func (*StatusUpdateCacher) IsCacheable added in v1.9.0

func (suc *StatusUpdateCacher) IsCacheable(obj any) bool

IsCacheable returns whether this type of object can be stored in the status cache.

func (*StatusUpdateCacher) OnAdd added in v1.9.0

func (suc *StatusUpdateCacher) OnAdd(obj any)

OnAdd adds an object to the status cache.

func (*StatusUpdateCacher) OnDelete added in v1.9.0

func (suc *StatusUpdateCacher) OnDelete(obj any)

OnDelete removes an object from the status cache.

func (*StatusUpdateCacher) Send added in v1.9.0

func (suc *StatusUpdateCacher) Send(su StatusUpdate)

type StatusUpdateHandler added in v1.5.0

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

StatusUpdateHandler holds the details required to actually write an Update back to the referenced object.

func NewStatusUpdateHandler added in v1.20.0

func NewStatusUpdateHandler(log logrus.FieldLogger, client client.Client, metrics StatusMetrics) *StatusUpdateHandler

func (*StatusUpdateHandler) NeedLeaderElection added in v1.20.0

func (suh *StatusUpdateHandler) NeedLeaderElection() bool

func (*StatusUpdateHandler) Start added in v1.5.0

func (suh *StatusUpdateHandler) Start(ctx context.Context) error

Start runs the goroutine to perform status writes.

func (*StatusUpdateHandler) Writer added in v1.5.0

func (suh *StatusUpdateHandler) Writer() StatusUpdater

Writer retrieves the interface that should be used to write to the StatusUpdateHandler.

type StatusUpdateWriter added in v1.5.0

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

StatusUpdateWriter takes status updates and sends these to the StatusUpdateHandler via a channel.

func (*StatusUpdateWriter) Send added in v1.9.0

func (suw *StatusUpdateWriter) Send(update StatusUpdate)

Send sends the given StatusUpdate off to the update channel for writing by the StatusUpdateHandler.

type StatusUpdater added in v1.5.0

type StatusUpdater interface {
	Send(su StatusUpdate)
}

StatusUpdater describes an interface to send status updates somewhere.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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