Skip to content

Commit e937360

Browse files
authored
fix!: Move service_external_traffic_policy from ListenerSpec to ListenerClassSpec (#789)
* fix!: Move service_external_traffic_policy from ListenerSpec to ListenerClassSpec * changelog
1 parent c20bdce commit e937360

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

crates/stackable-operator/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7-
- Support specifying externalTrafficPolicy in Services created by listener-operator ([#773]).
7+
- Support specifying externalTrafficPolicy in Services created by listener-operator ([#773], [#789]).
88
- BREAKING: Rename `commons::listener::ServiceType` to `commons::listener::KubernetesServiceType` ([#773]).
99

1010
[#773]: https://github.com/stackabletech/operator-rs/pull/773
11+
[#789]: https://github.com/stackabletech/operator-rs/pull/789
1112

1213
## [0.67.1] - 2024-05-08
1314

crates/stackable-operator/src/commons/listener.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
2828
use std::collections::BTreeMap;
2929

30-
use derivative::Derivative;
3130
use kube::CustomResource;
3231
use schemars::JsonSchema;
3332
use serde::{Deserialize, Serialize};
@@ -56,6 +55,20 @@ pub struct ListenerClassSpec {
5655
/// Annotations that should be added to the Service object.
5756
#[serde(default)]
5857
pub service_annotations: BTreeMap<String, String>,
58+
59+
/// `externalTrafficPolicy` that should be set on the created [`Service`] objects.
60+
///
61+
/// The default is `Local` (in contrast to `Cluster`), as we aim to direct traffic to a node running the workload
62+
/// and we should keep testing that as the primary configuration. Cluster is a fallback option for providers that
63+
/// break Local mode (IONOS so far).
64+
#[serde(default = "ListenerClassSpec::default_service_external_traffic_policy")]
65+
pub service_external_traffic_policy: KubernetesTrafficPolicy,
66+
}
67+
68+
impl ListenerClassSpec {
69+
const fn default_service_external_traffic_policy() -> KubernetesTrafficPolicy {
70+
KubernetesTrafficPolicy::Local
71+
}
5972
}
6073

6174
/// The method used to access the services.
@@ -100,9 +113,8 @@ pub enum KubernetesTrafficPolicy {
100113
///
101114
/// Learn more in the [Listener documentation](DOCS_BASE_URL_PLACEHOLDER/listener-operator/listener).
102115
#[derive(
103-
CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq, Eq, Derivative,
116+
CustomResource, Serialize, Deserialize, Default, Clone, Debug, JsonSchema, PartialEq, Eq,
104117
)]
105-
#[derivative(Default)]
106118
#[kube(
107119
group = "listeners.stackable.tech",
108120
version = "v1alpha1",
@@ -125,25 +137,12 @@ pub struct ListenerSpec {
125137
/// Whether incoming traffic should also be directed to Pods that are not `Ready`.
126138
#[serde(default = "ListenerSpec::default_publish_not_ready_addresses")]
127139
pub publish_not_ready_addresses: Option<bool>,
128-
129-
/// `externalTrafficPolicy` that should be set on the [`Service`] object.
130-
///
131-
/// The default is `Local` (in contrast to `Cluster`), as we aim to direct traffic to a node running the workload
132-
/// and we should keep testing that as the primary configuration. Cluster is a fallback option for providers that
133-
/// break Local mode (IONOS so far).
134-
#[derivative(Default(value = "ListenerSpec::default_service_external_traffic_policy()"))]
135-
#[serde(default = "ListenerSpec::default_service_external_traffic_policy")]
136-
pub service_external_traffic_policy: KubernetesTrafficPolicy,
137140
}
138141

139142
impl ListenerSpec {
140143
const fn default_publish_not_ready_addresses() -> Option<bool> {
141144
Some(true)
142145
}
143-
144-
const fn default_service_external_traffic_policy() -> KubernetesTrafficPolicy {
145-
KubernetesTrafficPolicy::Local
146-
}
147146
}
148147

149148
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq, Eq)]

0 commit comments

Comments
 (0)