Help us shape the future of Go! Take the 2026 Go Developer Survey

networkpolicy

package
v1.154.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 44 Imported by: 1

Documentation

Index

Constants

View Source
const ControllerName = "networkpolicy"

ControllerName is the name of the controller.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reconciler

type Reconciler struct {
	TargetClient client.Client
	Config       resourcemanagerconfigv1alpha1.NetworkPolicyControllerConfig
	Recorder     events.EventRecorder
	CacheSynced  bool
	// contains filtered or unexported fields
}

Reconciler reconciles Service objects and creates NetworkPolicy objects.

func (*Reconciler) AddToManager

func (r *Reconciler) AddToManager(ctx context.Context, mgr manager.Manager, targetCluster cluster.Cluster) error

AddToManager adds Reconciler to the given manager.

func (*Reconciler) EventHandlerForNamespace

func (r *Reconciler) EventHandlerForNamespace(log logr.Logger) handler.EventHandler

EventHandlerForNamespace returns an EventHandler that enqueues reconcile requests for Services associated with the given Namespace object.

func (*Reconciler) EventHandlerForPod

func (r *Reconciler) EventHandlerForPod(log logr.Logger) handler.EventHandler

EventHandlerForPod returns an EventHandler that tracks seen network policy label keys per namespace, only enqueueing services when a namespace's key coverage changes. This avoids redundant lookups during cache warmup where many pods per namespace would trigger identical service mappings (cf. https://github.com/kubernetes-sigs/controller-runtime/issues/3466). The event handler functions are called sequentially by the informer's processorListener goroutine (cf. https://github.com/kubernetes/client-go/blob/v0.35.3/tools/cache/shared_informer.go), so no synchronization is needed for the tracking map.

func (*Reconciler) IngressPredicate added in v1.67.0

func (r *Reconciler) IngressPredicate() predicate.Predicate

IngressPredicate returns a predicate which filters UPDATE events on Ingresses such that only updates to the rules are relevant.

func (*Reconciler) MapIngressToServices added in v1.67.0

func (r *Reconciler) MapIngressToServices(_ context.Context, obj client.Object) []reconcile.Request

MapIngressToServices is a handler.MapFunc for mapping a Ingresses to all referenced services.

func (*Reconciler) MapNetworkPolicyToService added in v1.67.0

func (r *Reconciler) MapNetworkPolicyToService(_ context.Context, obj client.Object) []reconcile.Request

MapNetworkPolicyToService is a handler.MapFunc for mapping a NetworkPolicy to the referenced service.

func (*Reconciler) MapVirtualServiceToServices

func (r *Reconciler) MapVirtualServiceToServices(_ context.Context, obj client.Object) []reconcile.Request

MapVirtualServiceToServices is a handler.MapFunc for mapping a VirtualService to all referenced services in its routes.

func (*Reconciler) PodPredicate

func (r *Reconciler) PodPredicate() predicate.Predicate

PodPredicate returns a predicate which filters for pods with `networking.resources.gardener.cloud/to-*` labels.

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error)

Reconcile performs the main reconciliation logic.

func (*Reconciler) ServicePredicate

func (r *Reconciler) ServicePredicate() predicate.Predicate

ServicePredicate returns a predicate which filters UPDATE events on services such that only updates to the deletion timestamp, the port list, the pod label selector, or well-known annotations are relevant.

func (*Reconciler) VirtualServicePredicate

func (r *Reconciler) VirtualServicePredicate() predicate.Predicate

VirtualServicePredicate returns a predicate which filters UPDATE events on VirtualServices such that only updates to the hosts, gateways, http, TLS or TCP routes are relevant.

Jump to

Keyboard shortcuts

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