Skip to content

Commit 548d1aa

Browse files
sbernauerTechassi
andauthored
fix!: Default ListenerClass externalTrafficPolicy to null (#1107)
* chore!: Default ListenerClass externalTrafficPolicy to null * changelog * Update crates/stackable-operator/src/crd/listener/class/mod.rs Co-authored-by: Techassi <[email protected]> * Update crates/stackable-operator/src/crd/listener/core/mod.rs * Add dec comment of defaults * Use patched kube * Update kube branch * Update crates/stackable-operator/src/crd/listener/class/mod.rs Co-authored-by: Techassi <[email protected]> --------- Co-authored-by: Techassi <[email protected]>
1 parent 7cb637b commit 548d1aa

File tree

9 files changed

+46
-36
lines changed

9 files changed

+46
-36
lines changed

Cargo.lock

Lines changed: 5 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ json-patch = "4.0.0"
3737
k8s-openapi = { version = "0.26.0", default-features = false, features = ["schemars", "v1_34"] }
3838
# We use rustls instead of openssl for easier portability, e.g. so that we can build stackablectl without the need to vendor (build from source) openssl
3939
# We use ring instead of aws-lc-rs, as this currently fails to build in "make run-dev"
40-
kube = { version = "2.0.0", default-features = false, features = ["client", "jsonpatch", "runtime", "derive", "rustls-tls", "ring"] }
40+
# We pin the kube version, as we use a patch for 2.0.1 below
41+
kube = { version = "=2.0.1", default-features = false, features = ["client", "jsonpatch", "runtime", "derive", "rustls-tls", "ring"] }
4142
opentelemetry = "0.31.0"
4243
opentelemetry_sdk = { version = "0.31.0", features = ["rt-tokio"] }
4344
opentelemetry-appender-tracing = "0.31.0"
@@ -93,3 +94,6 @@ rsa.opt-level = 3
9394
[profile.dev.package]
9495
insta.opt-level = 3
9596
similar.opt-level = 3
97+
98+
[patch.crates-io]
99+
kube = { git = "https://github.com/stackabletech/kube-rs", branch = "2.0.1-fix-schema-hoisting" }

crates/stackable-operator/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Fixed
8+
9+
- BREAKING: Default ListenerClass `.spec.externalTrafficPolicy` to `null` so that LoadBalancers work everywhere ([#1107]).
10+
11+
[#1107]: https://github.com/stackabletech/operator-rs/pull/1107
12+
713
## [0.100.1] - 2025-10-23
814

915
### Changed

crates/stackable-operator/crds/AuthenticationClass.yaml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/stackable-operator/crds/DummyCluster.yaml

Lines changed: 2 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/stackable-operator/crds/ListenerClass.yaml

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/stackable-operator/src/crd/listener/class/mod.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,26 @@ pub mod versioned {
5050
#[serde(default)]
5151
pub service_annotations: BTreeMap<String, String>,
5252

53-
/// `externalTrafficPolicy` that should be set on the created [`Service`] objects.
53+
/// `externalTrafficPolicy` that should be set on the created Service objects.
5454
///
55-
/// The default is `Local` (in contrast to `Cluster`), as we aim to direct traffic to a node running the workload
56-
/// and we should keep testing that as the primary configuration. Cluster is a fallback option for providers that
57-
/// break Local mode (IONOS so far).
58-
#[serde(default = "ListenerClassSpec::default_service_external_traffic_policy")]
59-
pub service_external_traffic_policy: core_v1alpha1::KubernetesTrafficPolicy,
55+
/// It is a Kubernetes feature that controls how external traffic is routed to a Kubernetes
56+
/// Service.
57+
///
58+
/// * `Cluster`: Kubernetes default. Traffic is routed to any node in the Kubernetes cluster that
59+
/// has a pod running the service.
60+
/// * `Local`: Traffic is only routed to pods running on the same node as the Service.
61+
///
62+
/// The `Local` mode has better performance as it avoids a network hop, but requires a more
63+
/// sophisticated LoadBalancer, that respects what Pods run on which nodes and routes traffic only
64+
/// to these nodes accordingly. Some cloud providers or bare metal installations do not implement
65+
/// some of the required features.
66+
//
67+
// Please note that Option is used here instead of a different default traffic policy. This will be
68+
// deserialized as `None` and will thus forward the selection of the traffic policy to Kubernetes
69+
// (which currently defaults to `Cluster`). This should be the most sensible option in most cases.
70+
// There is the possibility Kubernetes will automatically choose `Local` if support for it on the
71+
// LoadBalancer has been detected.
72+
pub service_external_traffic_policy: Option<core_v1alpha1::KubernetesTrafficPolicy>,
6073

6174
/// Whether addresses should prefer using the IP address (`IP`) or the hostname (`Hostname`).
6275
/// Can also be set to `HostnameConservative`, which will use `IP` for `NodePort` service types, but `Hostname` for everything else.

crates/stackable-operator/src/crd/listener/class/v1alpha1_impl.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
use crate::crd::listener::{
22
class::v1alpha1::ListenerClassSpec,
3-
core::v1alpha1::{AddressType, KubernetesTrafficPolicy, PreferredAddressType},
3+
core::v1alpha1::{AddressType, PreferredAddressType},
44
};
55

66
impl ListenerClassSpec {
7-
pub(super) const fn default_service_external_traffic_policy() -> KubernetesTrafficPolicy {
8-
KubernetesTrafficPolicy::Local
9-
}
10-
117
pub(super) const fn default_preferred_address_type() -> PreferredAddressType {
128
PreferredAddressType::HostnameConservative
139
}

crates/stackable-operator/src/crd/listener/core/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ pub mod versioned {
4545

4646
/// Preserves the client source IP and avoid a second hop for LoadBalancer and NodePort type
4747
/// Services, but makes clients responsible for spreading the load.
48+
///
49+
/// Does not work on all Kubernetes installations.
4850
Local,
4951
}
5052

0 commit comments

Comments
 (0)