portforwarding

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FinalizerName is the name of the finalizer added to PortForwarding resources
	// to ensure proper cleanup before deletion
	FinalizerName = "networking.kertical.com/portforwarding"
)
View Source
const (
	// IndexServiceOwnerReference is the index key for looking
	// up [discoveryv1.EndpointSlice] by their owning Service.
	IndexServiceOwnerReference = "metadata.labels.service-name"
)

Variables

This section is empty.

Functions

func AddFinalizer

AddFinalizer adds the PortForwarding finalizer to the resource if it doesn't already exist.

This ensures that cleanup operations can be performed before the resource is deleted.

func ContainsFinalizer

func ContainsFinalizer(pf *networkingv1alpha1.PortForwarding) bool

ContainsFinalizer checks if the given PortForwarding resource has our finalizer.

func FindEndpointSlicePort

func FindEndpointSlicePort(target intstr.IntOrString, endpointSlices []*discoveryv1.EndpointSlice) *discoveryv1.EndpointPort

FindEndpointSlicePort searches for a port with the specified name across all provided EndpointSlices.

If an EndpointSlice has only one port, it returns that port regardless of name. Returns nil if no matching port is found.

func FindServicePort

func FindServicePort(svc *corev1.Service, target intstr.IntOrString, endpointSlices []*discoveryv1.EndpointSlice) (corev1.ServicePort, bool)

FindServicePort searches for a port in a service that matches the target.

func RegisterFieldIndexes

func RegisterFieldIndexes(ctx context.Context, indexer client.FieldIndexer) error

RegisterFieldIndexes sets up custom field indexes in the Kubernetes client cache.

func RemoveFinalizer

func RemoveFinalizer(ctx context.Context, c client.Client, pf *networkingv1alpha1.PortForwarding) (bool, error)

RemoveFinalizer removes the PortForwarding finalizer from the resource if all forwarded ports have been cleaned up. This allows the resource to be deleted by the Kubernetes API.

func ServiceObjectKey

ServiceObjectKey extracts the namespaced name of the referenced service from a *networkingv1alpha1.PortForwarding resource

func SyncForwardingPorts

SyncForwardingPorts reconciles the current forwarded ports with the desired configuration

Returns three lists: ports to add, ports to delete, and unchanged ports

Types

type ForwardedPorts

type ForwardedPorts = []networkingv1alpha1.ForwardedPort

type StatusUpdater

type StatusUpdater interface {
	// PatchNodeForwardedStatus updates the forwarded port status for a specific node
	// in a [*networkingv1alpha1.PortForwarding] resource.
	PatchNodeForwardedStatus(context.Context, *networkingv1alpha1.PortForwarding, string, ForwardedPorts) error

	// UpdateCondition updates a condition in the PortForwarding resource's status.
	UpdateCondition(ctx context.Context, pf *networkingv1alpha1.PortForwarding, condition metav1.Condition) error
}

StatusUpdater defines an interface for updating the status of PortForwarding objects.

func NewStatusUpdater

func NewStatusUpdater(c client.Client) StatusUpdater

NewStatusUpdater creates a new instance of StatusUpdater with the provided client.

Jump to

Keyboard shortcuts

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