From 417b7da88a4dea1c6464fe8d98916710371b12e5 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Mon, 6 May 2024 18:57:20 +0200 Subject: [PATCH 01/13] Support specifying externalTrafficPolicy in Services created by listener-operator --- crates/stackable-operator/CHANGELOG.md | 2 ++ .../src/cluster_resources.rs | 3 ++ .../src/commons/listener.rs | 32 +++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/crates/stackable-operator/CHANGELOG.md b/crates/stackable-operator/CHANGELOG.md index f6b3a8d4..002d8c4b 100644 --- a/crates/stackable-operator/CHANGELOG.md +++ b/crates/stackable-operator/CHANGELOG.md @@ -8,7 +8,9 @@ All notable changes to this project will be documented in this file. - Bump GitHub workflow actions ([#772]). - Revert `zeroize` version bump ([#772]). +- Support specifying externalTrafficPolicy in Services created by listener-operator ([#562]). +[#562]: https://github.com/stackabletech/operator-rs/pull/562 [#772]: https://github.com/stackabletech/operator-rs/pull/772 ## [0.67.0] - 2024-04-25 diff --git a/crates/stackable-operator/src/cluster_resources.rs b/crates/stackable-operator/src/cluster_resources.rs index e39ea1c3..65a804d4 100644 --- a/crates/stackable-operator/src/cluster_resources.rs +++ b/crates/stackable-operator/src/cluster_resources.rs @@ -4,6 +4,7 @@ use crate::{ client::{Client, GetApi}, commons::{ cluster_operation::ClusterOperation, + listener::Listener, resources::{ ComputeResource, ResourceRequirementsExt, ResourceRequirementsType, LIMIT_REQUEST_RATIO_CPU, LIMIT_REQUEST_RATIO_MEMORY, @@ -203,6 +204,7 @@ impl ClusterResource for Service {} impl ClusterResource for ServiceAccount {} impl ClusterResource for RoleBinding {} impl ClusterResource for PodDisruptionBudget {} +impl ClusterResource for Listener {} impl ClusterResource for Job { fn pod_spec(&self) -> Option<&PodSpec> { @@ -612,6 +614,7 @@ impl ClusterResources { self.delete_orphaned_resources_of_kind::(client), self.delete_orphaned_resources_of_kind::(client), self.delete_orphaned_resources_of_kind::(client), + self.delete_orphaned_resources_of_kind::(client), )?; Ok(()) diff --git a/crates/stackable-operator/src/commons/listener.rs b/crates/stackable-operator/src/commons/listener.rs index fca90059..d4db384c 100644 --- a/crates/stackable-operator/src/commons/listener.rs +++ b/crates/stackable-operator/src/commons/listener.rs @@ -68,6 +68,34 @@ pub enum ServiceType { ClusterIP, } +impl ServiceType { + pub fn to_kubernetes_literal(&self) -> String { + match self { + ServiceType::NodePort => "NodePort".to_owned(), + ServiceType::LoadBalancer => "LoadBalancer".to_owned(), + ServiceType::ClusterIP => "ClusterIP".to_owned(), + } + } +} + +#[derive(Serialize, Deserialize, Clone, Debug, Default, JsonSchema, PartialEq, Eq)] +pub enum TrafficPolicy { + /// Obscures the client source IP and may cause a second hop to another node, but allows Kubernetes to spread the load between all nodes. + #[default] + Cluster, + /// Preserves the client source IP and avoid a second hop for LoadBalancer and NodePort type Services, but makes clients responsible for spreading the load. + Local, +} + +impl TrafficPolicy { + pub fn to_kubernetes_literal(&self) -> String { + match self { + TrafficPolicy::Cluster => "Cluster".to_string(), + TrafficPolicy::Local => "Local".to_string(), + } + } +} + /// Exposes a set of pods to the outside world. /// /// Essentially a Stackable extension of a Kubernetes Service. Compared to a Service, a Listener changes three things: @@ -102,6 +130,10 @@ pub struct ListenerSpec { /// Whether incoming traffic should also be directed to Pods that are not `Ready`. #[schemars(default = "Self::default_publish_not_ready_addresses")] pub publish_not_ready_addresses: Option, + + /// `externalTrafficPolicy` that should be set on the [`Service`] object. + #[serde(default)] + pub service_external_traffic_policy: TrafficPolicy, } impl ListenerSpec { From d1e94feb07106245c67e363256799b93141da336 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Tue, 7 May 2024 07:44:38 +0200 Subject: [PATCH 02/13] Update crates/stackable-operator/src/commons/listener.rs Co-authored-by: Nick --- crates/stackable-operator/src/commons/listener.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/stackable-operator/src/commons/listener.rs b/crates/stackable-operator/src/commons/listener.rs index d4db384c..a8a5c3f1 100644 --- a/crates/stackable-operator/src/commons/listener.rs +++ b/crates/stackable-operator/src/commons/listener.rs @@ -83,6 +83,7 @@ pub enum TrafficPolicy { /// Obscures the client source IP and may cause a second hop to another node, but allows Kubernetes to spread the load between all nodes. #[default] Cluster, + /// Preserves the client source IP and avoid a second hop for LoadBalancer and NodePort type Services, but makes clients responsible for spreading the load. Local, } From 1e8571c75413065cb9ed95a75f71a9a591ae70c5 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Tue, 7 May 2024 07:57:29 +0200 Subject: [PATCH 03/13] Use strum::Display --- .../src/commons/listener.rs | 43 ++++++++----------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/crates/stackable-operator/src/commons/listener.rs b/crates/stackable-operator/src/commons/listener.rs index a8a5c3f1..71cff85e 100644 --- a/crates/stackable-operator/src/commons/listener.rs +++ b/crates/stackable-operator/src/commons/listener.rs @@ -50,7 +50,7 @@ use crate::builder::pod::volume::ListenerOperatorVolumeSourceBuilder; )] #[serde(rename_all = "camelCase")] pub struct ListenerClassSpec { - pub service_type: ServiceType, + pub service_type: KubernetesServiceType, /// Annotations that should be added to the Service object. #[serde(default)] @@ -58,8 +58,11 @@ pub struct ListenerClassSpec { } /// The method used to access the services. -#[derive(Serialize, Deserialize, Clone, Copy, Debug, JsonSchema, PartialEq, Eq)] -pub enum ServiceType { +// +// Please note that this represents a Kubernetes type, so the name of the enum variant needs to exactly match the +// Kubernetes service type. +#[derive(Serialize, Deserialize, Clone, Copy, Debug, JsonSchema, PartialEq, Eq, strum::Display)] +pub enum KubernetesServiceType { /// Reserve a port on each node. NodePort, /// Provision a dedicated load balancer. @@ -68,18 +71,17 @@ pub enum ServiceType { ClusterIP, } -impl ServiceType { - pub fn to_kubernetes_literal(&self) -> String { - match self { - ServiceType::NodePort => "NodePort".to_owned(), - ServiceType::LoadBalancer => "LoadBalancer".to_owned(), - ServiceType::ClusterIP => "ClusterIP".to_owned(), - } - } -} - -#[derive(Serialize, Deserialize, Clone, Debug, Default, JsonSchema, PartialEq, Eq)] -pub enum TrafficPolicy { +/// Service Internal Traffic Policy enables internal traffic restrictions to only route internal traffic to endpoints +/// within the node the traffic originated from. The "internal" traffic here refers to traffic originated from Pods in +/// the current cluster. This can help to reduce costs and improve performance. +/// See [Kubernetes docs](https://kubernetes.io/docs/concepts/services-networking/service-traffic-policy/). +// +// Please note that this represents a Kubernetes type, so the name of the enum variant needs to exactly match the +// Kubernetes traffic policy. +#[derive( + Serialize, Deserialize, Clone, Debug, Default, JsonSchema, PartialEq, Eq, strum::Display, +)] +pub enum KubernetesTrafficPolicy { /// Obscures the client source IP and may cause a second hop to another node, but allows Kubernetes to spread the load between all nodes. #[default] Cluster, @@ -88,15 +90,6 @@ pub enum TrafficPolicy { Local, } -impl TrafficPolicy { - pub fn to_kubernetes_literal(&self) -> String { - match self { - TrafficPolicy::Cluster => "Cluster".to_string(), - TrafficPolicy::Local => "Local".to_string(), - } - } -} - /// Exposes a set of pods to the outside world. /// /// Essentially a Stackable extension of a Kubernetes Service. Compared to a Service, a Listener changes three things: @@ -134,7 +127,7 @@ pub struct ListenerSpec { /// `externalTrafficPolicy` that should be set on the [`Service`] object. #[serde(default)] - pub service_external_traffic_policy: TrafficPolicy, + pub service_external_traffic_policy: KubernetesTrafficPolicy, } impl ListenerSpec { From 6099fd90cca8e224c9612294d83346818608d54b Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Tue, 7 May 2024 08:07:42 +0200 Subject: [PATCH 04/13] changelog --- crates/stackable-operator/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/stackable-operator/CHANGELOG.md b/crates/stackable-operator/CHANGELOG.md index 002d8c4b..cd025341 100644 --- a/crates/stackable-operator/CHANGELOG.md +++ b/crates/stackable-operator/CHANGELOG.md @@ -8,10 +8,10 @@ All notable changes to this project will be documented in this file. - Bump GitHub workflow actions ([#772]). - Revert `zeroize` version bump ([#772]). -- Support specifying externalTrafficPolicy in Services created by listener-operator ([#562]). +- Support specifying externalTrafficPolicy in Services created by listener-operator ([#773]). -[#562]: https://github.com/stackabletech/operator-rs/pull/562 [#772]: https://github.com/stackabletech/operator-rs/pull/772 +[#773]: https://github.com/stackabletech/operator-rs/pull/773 ## [0.67.0] - 2024-04-25 From 5e6453795b9945d7e3fd8b54fa7f9a6ab0442bc5 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Tue, 7 May 2024 16:22:57 +0200 Subject: [PATCH 05/13] add newlines --- crates/stackable-operator/src/commons/listener.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/stackable-operator/src/commons/listener.rs b/crates/stackable-operator/src/commons/listener.rs index 71cff85e..8a431ed7 100644 --- a/crates/stackable-operator/src/commons/listener.rs +++ b/crates/stackable-operator/src/commons/listener.rs @@ -65,8 +65,10 @@ pub struct ListenerClassSpec { pub enum KubernetesServiceType { /// Reserve a port on each node. NodePort, + /// Provision a dedicated load balancer. LoadBalancer, + /// Assigns an IP address from a pool of IP addresses that your cluster has reserved for that purpose. ClusterIP, } From 1060548c728ef78e6b98030243b8e1965e0fc72c Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Mon, 13 May 2024 10:25:32 +0200 Subject: [PATCH 06/13] Remove KubernetesTrafficPolicy::default(), switch to serde(default) --- .../stackable-operator/src/commons/listener.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/crates/stackable-operator/src/commons/listener.rs b/crates/stackable-operator/src/commons/listener.rs index 8a431ed7..f6f69d1c 100644 --- a/crates/stackable-operator/src/commons/listener.rs +++ b/crates/stackable-operator/src/commons/listener.rs @@ -80,12 +80,9 @@ pub enum KubernetesServiceType { // // Please note that this represents a Kubernetes type, so the name of the enum variant needs to exactly match the // Kubernetes traffic policy. -#[derive( - Serialize, Deserialize, Clone, Debug, Default, JsonSchema, PartialEq, Eq, strum::Display, -)] +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq, Eq, strum::Display)] pub enum KubernetesTrafficPolicy { /// Obscures the client source IP and may cause a second hop to another node, but allows Kubernetes to spread the load between all nodes. - #[default] Cluster, /// Preserves the client source IP and avoid a second hop for LoadBalancer and NodePort type Services, but makes clients responsible for spreading the load. @@ -101,9 +98,7 @@ pub enum KubernetesTrafficPolicy { /// ["sticky" scheduling](DOCS_BASE_URL_PLACEHOLDER/listener-operator/listener#_sticky_scheduling). /// /// Learn more in the [Listener documentation](DOCS_BASE_URL_PLACEHOLDER/listener-operator/listener). -#[derive( - CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq, Eq, -)] +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq, Eq)] #[kube( group = "listeners.stackable.tech", version = "v1alpha1", @@ -128,10 +123,16 @@ pub struct ListenerSpec { pub publish_not_ready_addresses: Option, /// `externalTrafficPolicy` that should be set on the [`Service`] object. - #[serde(default)] + #[serde(default = "default_service_external_traffic_policy")] pub service_external_traffic_policy: KubernetesTrafficPolicy, } +/// We try pretty hard to shove traffic onto the right node, and we should keep testing that as the primary +/// configuration. Cluster is a fallback option for providers that break Local mode (IONOS so far). +fn default_service_external_traffic_policy() -> KubernetesTrafficPolicy { + KubernetesTrafficPolicy::Local +} + impl ListenerSpec { const fn default_publish_not_ready_addresses() -> Option { Some(true) From 3fca626a05d8acfe9fe6e621d55bb00914ab36eb Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Mon, 13 May 2024 10:27:14 +0200 Subject: [PATCH 07/13] changelog --- crates/stackable-operator/CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/stackable-operator/CHANGELOG.md b/crates/stackable-operator/CHANGELOG.md index 9da5bf44..48d5efdc 100644 --- a/crates/stackable-operator/CHANGELOG.md +++ b/crates/stackable-operator/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +- Support specifying externalTrafficPolicy in Services created by listener-operator ([#773]). +- BREAKING: Remove `Default` impl for `ListenerSpec` ([#773]). + +[#773]: https://github.com/stackabletech/operator-rs/pull/773 + ## [0.67.1] - 2024-05-08 ### Added From 860ec981098fbb1eb75aba2072a44aa4f10cbb59 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Mon, 13 May 2024 11:07:01 +0200 Subject: [PATCH 08/13] Use serde(default) --- .../stackable-operator/src/commons/listener.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/stackable-operator/src/commons/listener.rs b/crates/stackable-operator/src/commons/listener.rs index f6f69d1c..0a425bff 100644 --- a/crates/stackable-operator/src/commons/listener.rs +++ b/crates/stackable-operator/src/commons/listener.rs @@ -119,24 +119,24 @@ pub struct ListenerSpec { pub ports: Option>, /// Whether incoming traffic should also be directed to Pods that are not `Ready`. - #[schemars(default = "Self::default_publish_not_ready_addresses")] + #[serde(default = "ListenerSpec::default_publish_not_ready_addresses")] pub publish_not_ready_addresses: Option, /// `externalTrafficPolicy` that should be set on the [`Service`] object. - #[serde(default = "default_service_external_traffic_policy")] + #[serde(default = "ListenerSpec::default_service_external_traffic_policy")] pub service_external_traffic_policy: KubernetesTrafficPolicy, } -/// We try pretty hard to shove traffic onto the right node, and we should keep testing that as the primary -/// configuration. Cluster is a fallback option for providers that break Local mode (IONOS so far). -fn default_service_external_traffic_policy() -> KubernetesTrafficPolicy { - KubernetesTrafficPolicy::Local -} - impl ListenerSpec { const fn default_publish_not_ready_addresses() -> Option { Some(true) } + + /// We try pretty hard to shove traffic onto the right node, and we should keep testing that as the primary + /// configuration. Cluster is a fallback option for providers that break Local mode (IONOS so far). + fn default_service_external_traffic_policy() -> KubernetesTrafficPolicy { + KubernetesTrafficPolicy::Local + } } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq, Eq)] From 51a46faa8b0c7bbf72604b9665cc4411065bebd9 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Tue, 14 May 2024 09:00:15 +0200 Subject: [PATCH 09/13] Impl Default for ListenerSpec again --- crates/stackable-operator/CHANGELOG.md | 2 +- .../stackable-operator/src/commons/listener.rs | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/crates/stackable-operator/CHANGELOG.md b/crates/stackable-operator/CHANGELOG.md index 48d5efdc..c41ae378 100644 --- a/crates/stackable-operator/CHANGELOG.md +++ b/crates/stackable-operator/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. ## [Unreleased] - Support specifying externalTrafficPolicy in Services created by listener-operator ([#773]). -- BREAKING: Remove `Default` impl for `ListenerSpec` ([#773]). +- BREAKING: Rename `commons::listener::ServiceType` to `commons::listener::KubernetesServiceType` ([#773]). [#773]: https://github.com/stackabletech/operator-rs/pull/773 diff --git a/crates/stackable-operator/src/commons/listener.rs b/crates/stackable-operator/src/commons/listener.rs index 0a425bff..30dd5ed8 100644 --- a/crates/stackable-operator/src/commons/listener.rs +++ b/crates/stackable-operator/src/commons/listener.rs @@ -27,6 +27,7 @@ use std::collections::BTreeMap; +use derivative::Derivative; use kube::CustomResource; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -98,7 +99,10 @@ pub enum KubernetesTrafficPolicy { /// ["sticky" scheduling](DOCS_BASE_URL_PLACEHOLDER/listener-operator/listener#_sticky_scheduling). /// /// Learn more in the [Listener documentation](DOCS_BASE_URL_PLACEHOLDER/listener-operator/listener). -#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq, Eq)] +#[derive( + CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq, Eq, Derivative, +)] +#[derivative(Default)] #[kube( group = "listeners.stackable.tech", version = "v1alpha1", @@ -123,6 +127,11 @@ pub struct ListenerSpec { pub publish_not_ready_addresses: Option, /// `externalTrafficPolicy` that should be set on the [`Service`] object. + /// + /// The default is `Local` (in contrast to `Cluster`), as we try pretty hard to shove traffic onto the right node, + /// and we should keep testing that as the primary configuration. Cluster is a fallback option for providers that + /// break Local mode (IONOS so far). + #[derivative(Default(value = "KubernetesTrafficPolicy::Local"))] #[serde(default = "ListenerSpec::default_service_external_traffic_policy")] pub service_external_traffic_policy: KubernetesTrafficPolicy, } @@ -132,10 +141,9 @@ impl ListenerSpec { Some(true) } - /// We try pretty hard to shove traffic onto the right node, and we should keep testing that as the primary - /// configuration. Cluster is a fallback option for providers that break Local mode (IONOS so far). + // `#[serde(default)]`` only supports functions, so we need to wrap the literal in a function :) fn default_service_external_traffic_policy() -> KubernetesTrafficPolicy { - KubernetesTrafficPolicy::Local + Self::default().service_external_traffic_policy } } From f553865ea99f0fa57e4074924f88f40b53027c49 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Tue, 14 May 2024 09:34:17 +0200 Subject: [PATCH 10/13] typo --- crates/stackable-operator/src/commons/listener.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/stackable-operator/src/commons/listener.rs b/crates/stackable-operator/src/commons/listener.rs index 30dd5ed8..f68a3940 100644 --- a/crates/stackable-operator/src/commons/listener.rs +++ b/crates/stackable-operator/src/commons/listener.rs @@ -141,7 +141,7 @@ impl ListenerSpec { Some(true) } - // `#[serde(default)]`` only supports functions, so we need to wrap the literal in a function :) + // `#[serde(default)]` only supports functions, so we need to wrap the literal in a function :) fn default_service_external_traffic_policy() -> KubernetesTrafficPolicy { Self::default().service_external_traffic_policy } From 56566f78b8a2e0abfb2d0a7db55125109cc284cc Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Tue, 14 May 2024 09:35:51 +0200 Subject: [PATCH 11/13] fix changelog --- crates/stackable-operator/CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/stackable-operator/CHANGELOG.md b/crates/stackable-operator/CHANGELOG.md index c41ae378..22a4f724 100644 --- a/crates/stackable-operator/CHANGELOG.md +++ b/crates/stackable-operator/CHANGELOG.md @@ -21,10 +21,8 @@ All notable changes to this project will be documented in this file. - Bump Rust dependencies and GitHub Actions ([#782]). - Bump GitHub workflow actions ([#772]). - Revert `zeroize` version bump ([#772]). -- Support specifying externalTrafficPolicy in Services created by listener-operator ([#773]). [#772]: https://github.com/stackabletech/operator-rs/pull/772 -[#773]: https://github.com/stackabletech/operator-rs/pull/773 [#782]: https://github.com/stackabletech/operator-rs/pull/782 ## [0.67.0] - 2024-04-25 From f59ff2dfe796d91e5dd18fe747faf31266d2930b Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Thu, 16 May 2024 11:21:22 +0200 Subject: [PATCH 12/13] docs: Improve wording --- crates/stackable-operator/src/commons/listener.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/stackable-operator/src/commons/listener.rs b/crates/stackable-operator/src/commons/listener.rs index f68a3940..1c02cd82 100644 --- a/crates/stackable-operator/src/commons/listener.rs +++ b/crates/stackable-operator/src/commons/listener.rs @@ -128,7 +128,7 @@ pub struct ListenerSpec { /// `externalTrafficPolicy` that should be set on the [`Service`] object. /// - /// The default is `Local` (in contrast to `Cluster`), as we try pretty hard to shove traffic onto the right node, + /// The default is `Local` (in contrast to `Cluster`), as we aim to direct traffic to a node running the workload /// and we should keep testing that as the primary configuration. Cluster is a fallback option for providers that /// break Local mode (IONOS so far). #[derivative(Default(value = "KubernetesTrafficPolicy::Local"))] From 0ff36cf01fb3e6c23419d5491f3015310fb27fd3 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Thu, 16 May 2024 11:25:45 +0200 Subject: [PATCH 13/13] Move default into ListenerSpec::default_service_external_traffic_policy --- crates/stackable-operator/src/commons/listener.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/stackable-operator/src/commons/listener.rs b/crates/stackable-operator/src/commons/listener.rs index 1c02cd82..84a0b4ad 100644 --- a/crates/stackable-operator/src/commons/listener.rs +++ b/crates/stackable-operator/src/commons/listener.rs @@ -131,7 +131,7 @@ pub struct ListenerSpec { /// The default is `Local` (in contrast to `Cluster`), as we aim to direct traffic to a node running the workload /// and we should keep testing that as the primary configuration. Cluster is a fallback option for providers that /// break Local mode (IONOS so far). - #[derivative(Default(value = "KubernetesTrafficPolicy::Local"))] + #[derivative(Default(value = "ListenerSpec::default_service_external_traffic_policy()"))] #[serde(default = "ListenerSpec::default_service_external_traffic_policy")] pub service_external_traffic_policy: KubernetesTrafficPolicy, } @@ -141,9 +141,8 @@ impl ListenerSpec { Some(true) } - // `#[serde(default)]` only supports functions, so we need to wrap the literal in a function :) - fn default_service_external_traffic_policy() -> KubernetesTrafficPolicy { - Self::default().service_external_traffic_policy + const fn default_service_external_traffic_policy() -> KubernetesTrafficPolicy { + KubernetesTrafficPolicy::Local } }