From eba818ca0facc6cfe96e33ae9ee152143cca33a7 Mon Sep 17 00:00:00 2001 From: whg517 Date: Tue, 24 Dec 2024 16:59:36 +0800 Subject: [PATCH] refactor(listener): add svc traffic policy and pref addr type to listener class (#294) --- pkg/apis/listeners/v1alpha1/listener_types.go | 4 ++++ pkg/apis/listeners/v1alpha1/listenerclass_types.go | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/pkg/apis/listeners/v1alpha1/listener_types.go b/pkg/apis/listeners/v1alpha1/listener_types.go index 6863b68..4690ad3 100644 --- a/pkg/apis/listeners/v1alpha1/listener_types.go +++ b/pkg/apis/listeners/v1alpha1/listener_types.go @@ -26,6 +26,10 @@ type AddressType string const ( AddressTypeHostname AddressType = "Hostname" AddressTypeIP AddressType = "IP" + // When preferredAddressType is set to HostnameConservative, the controller will + // attempt to use the ip only `ListenerClassSpec.ServiceType` is NodePort, + // otherwise it will use the hostname. + AddressTypeHostnameConservative AddressType = "HostnameConservative" ) // ListenerSpec defines the desired state of Listener diff --git a/pkg/apis/listeners/v1alpha1/listenerclass_types.go b/pkg/apis/listeners/v1alpha1/listenerclass_types.go index 2a29aca..a39b1f2 100644 --- a/pkg/apis/listeners/v1alpha1/listenerclass_types.go +++ b/pkg/apis/listeners/v1alpha1/listenerclass_types.go @@ -29,6 +29,19 @@ type ListenerClassSpec struct { // +kubebuilder:validation:Optional ServiceAnnotations map[string]string `json:"serviceAnnotations,omitempty"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default=Local + // +kubebuilder:validation:Enum=Local;Cluster + ServiceExternalTrafficPolicy corev1.ServiceExternalTrafficPolicyType `json:"serviceExternalTrafficPolicy,omitempty"` + + // When preferredAddressType is set to HostnameConservative, the controller will + // attempt to use the ip only `ListenerClassSpec.ServiceType` is NodePort, + // otherwise it will use the hostname. + // +kubebuilder:validation:Optional + // +kubebuilder:default=HostnameConservative + // +kubebuilder:validation:Enum=HostnameConservative;Hostname;IP + PreferredAddressType AddressType `json:"preferredAddressType,omitempty"` } // ListenerClassStatus defines the observed state of ListenerClass