Documentation
¶
Index ¶
- Constants
- func AddFinalizer(ctx context.Context, c client.Client, pf *networkingv1alpha1.PortForwarding) error
- func ContainsFinalizer(pf *networkingv1alpha1.PortForwarding) bool
- func FindEndpointSlicePort(target intstr.IntOrString, endpointSlices []*discoveryv1.EndpointSlice) *discoveryv1.EndpointPort
- func FindServicePort(svc *corev1.Service, target intstr.IntOrString, ...) (corev1.ServicePort, bool)
- func RegisterFieldIndexes(ctx context.Context, indexer client.FieldIndexer) error
- func RemoveFinalizer(ctx context.Context, c client.Client, pf *networkingv1alpha1.PortForwarding) (bool, error)
- func ServiceObjectKey(pf *networkingv1alpha1.PortForwarding) types.NamespacedName
- func SyncForwardingPorts(pf *networkingv1alpha1.PortForwarding, svc *corev1.Service, ...) (ForwardedPorts, ForwardedPorts, ForwardedPorts, ForwardedPorts)
- type ForwardedPorts
- type StatusUpdater
Constants ¶
const ( // FinalizerName is the name of the finalizer added to PortForwarding resources // to ensure proper cleanup before deletion FinalizerName = "networking.kertical.com/portforwarding" )
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 ¶
func AddFinalizer(ctx context.Context, c client.Client, pf *networkingv1alpha1.PortForwarding) error
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 ¶
func ServiceObjectKey(pf *networkingv1alpha1.PortForwarding) types.NamespacedName
ServiceObjectKey extracts the namespaced name of the referenced service from a *networkingv1alpha1.PortForwarding resource
func SyncForwardingPorts ¶
func SyncForwardingPorts(pf *networkingv1alpha1.PortForwarding, svc *corev1.Service, endpointSlices []*discoveryv1.EndpointSlice) ( ForwardedPorts, ForwardedPorts, ForwardedPorts, ForwardedPorts, )
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.