Skip to content

Commit 1f15a3a

Browse files
Fields discoveryServiceExposed and discoveryServiceListenerClass added to the CRD
1 parent a8c3699 commit 1f15a3a

8 files changed

Lines changed: 63 additions & 21 deletions

File tree

deploy/helm/opensearch-operator/crds/crds.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ spec:
246246
type: object
247247
x-kubernetes-preserve-unknown-fields: true
248248
type: object
249+
discoveryServiceExposed:
250+
description: Determines whether this role group is exposed in the discovery service.
251+
nullable: true
252+
type: boolean
249253
gracefulShutdownTimeout:
250254
description: |-
251255
Time period Pods have to gracefully shut down, e.g. `30m`, `1h` or `2d`. Consult the
@@ -520,11 +524,19 @@ spec:
520524
x-kubernetes-preserve-unknown-fields: true
521525
roleConfig:
522526
default:
527+
discoveryServiceListenerClass: cluster-internal
523528
podDisruptionBudget:
524529
enabled: true
525530
maxUnavailable: null
526531
description: This is a product-agnostic RoleConfig, which is sufficient for most of the products.
527532
properties:
533+
discoveryServiceListenerClass:
534+
default: cluster-internal
535+
description: The [ListenerClass](https://docs.stackable.tech/home/nightly/listener-operator/listenerclass.html) that is used for the discovery service.
536+
maxLength: 253
537+
minLength: 1
538+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
539+
type: string
528540
podDisruptionBudget:
529541
default:
530542
enabled: true
@@ -603,6 +615,10 @@ spec:
603615
type: object
604616
x-kubernetes-preserve-unknown-fields: true
605617
type: object
618+
discoveryServiceExposed:
619+
description: Determines whether this role group is exposed in the discovery service.
620+
nullable: true
621+
type: boolean
606622
gracefulShutdownTimeout:
607623
description: |-
608624
Time period Pods have to gracefully shut down, e.g. `30m`, `1h` or `2d`. Consult the

rust/operator-binary/src/controller.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use stackable_operator::{
2020
},
2121
kube::{Resource, api::ObjectMeta, core::DeserializeGuard, runtime::controller::Action},
2222
logging::controller::ReconcilerError,
23-
role_utils::GenericRoleConfig,
2423
shared::time::Duration,
2524
};
2625
use strum::{EnumDiscriminants, IntoStaticStr};
@@ -168,7 +167,7 @@ pub struct ValidatedCluster {
168167
pub name: ClusterName,
169168
pub namespace: NamespaceName,
170169
pub uid: Uid,
171-
pub role_config: GenericRoleConfig,
170+
pub role_config: v1alpha1::OpenSearchRoleConfig,
172171
pub role_group_configs: BTreeMap<RoleGroupName, OpenSearchRoleGroupConfig>,
173172
pub tls_config: v1alpha1::OpenSearchTls,
174173
pub keystores: Vec<v1alpha1::OpenSearchKeystore>,
@@ -182,7 +181,7 @@ impl ValidatedCluster {
182181
name: ClusterName,
183182
namespace: NamespaceName,
184183
uid: impl Into<Uid>,
185-
role_config: GenericRoleConfig,
184+
role_config: v1alpha1::OpenSearchRoleConfig,
186185
role_group_configs: BTreeMap<RoleGroupName, OpenSearchRoleGroupConfig>,
187186
tls_config: v1alpha1::OpenSearchTls,
188187
keystores: Vec<v1alpha1::OpenSearchKeystore>,
@@ -382,7 +381,6 @@ mod tests {
382381
k8s_openapi::api::core::v1::PodTemplateSpec,
383382
kvp::LabelValue,
384383
product_logging::spec::AutomaticContainerLogConfig,
385-
role_utils::GenericRoleConfig,
386384
shared::time::Duration,
387385
};
388386
use uuid::uuid;
@@ -475,7 +473,7 @@ mod tests {
475473
ClusterName::from_str_unsafe("my-opensearch"),
476474
NamespaceName::from_str_unsafe("default"),
477475
uuid!("e6ac237d-a6d4-43a1-8135-f36506110912"),
478-
GenericRoleConfig::default(),
476+
v1alpha1::OpenSearchRoleConfig::default(),
479477
[
480478
(
481479
RoleGroupName::from_str_unsafe("coordinating"),

rust/operator-binary/src/controller/build.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ mod tests {
6767
kube::Resource,
6868
kvp::LabelValue,
6969
product_logging::spec::AutomaticContainerLogConfig,
70-
role_utils::GenericRoleConfig,
7170
shared::time::Duration,
7271
};
7372
use uuid::uuid;
@@ -175,7 +174,7 @@ mod tests {
175174
ClusterName::from_str_unsafe("my-opensearch"),
176175
NamespaceName::from_str_unsafe("default"),
177176
uuid!("e6ac237d-a6d4-43a1-8135-f36506110912"),
178-
GenericRoleConfig::default(),
177+
v1alpha1::OpenSearchRoleConfig::default(),
179178
[
180179
(
181180
RoleGroupName::from_str_unsafe("coordinating"),

rust/operator-binary/src/controller/build/node_config.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,6 @@ mod tests {
436436
k8s_openapi::api::core::v1::PodTemplateSpec,
437437
kvp::LabelValue,
438438
product_logging::spec::AutomaticContainerLogConfig,
439-
role_utils::GenericRoleConfig,
440439
shared::time::Duration,
441440
};
442441
use uuid::uuid;
@@ -532,7 +531,7 @@ mod tests {
532531
ClusterName::from_str_unsafe("my-opensearch-cluster"),
533532
NamespaceName::from_str_unsafe("default"),
534533
uuid!("0b1e30e6-326e-4c1a-868d-ad6598b49e8b"),
535-
GenericRoleConfig::default(),
534+
v1alpha1::OpenSearchRoleConfig::default(),
536535
[(
537536
RoleGroupName::from_str_unsafe("default"),
538537
role_group_config.clone(),

rust/operator-binary/src/controller/build/role_builder.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl<'a> RoleBuilder<'a> {
146146

147147
/// Builds a [`PodDisruptionBudget`] used by all role-groups
148148
pub fn build_pdb(&self) -> Option<PodDisruptionBudget> {
149-
let pdb_config = &self.cluster.role_config.pod_disruption_budget;
149+
let pdb_config = &self.cluster.role_config.common.pod_disruption_budget;
150150

151151
if pdb_config.enabled {
152152
let max_unavailable = pdb_config
@@ -229,7 +229,6 @@ mod tests {
229229
k8s_openapi::api::core::v1::PodTemplateSpec,
230230
kvp::LabelValue,
231231
product_logging::spec::AutomaticContainerLogConfig,
232-
role_utils::GenericRoleConfig,
233232
shared::time::Duration,
234233
};
235234
use uuid::uuid;
@@ -308,7 +307,7 @@ mod tests {
308307
ClusterName::from_str_unsafe("my-opensearch-cluster"),
309308
NamespaceName::from_str_unsafe("default"),
310309
uuid!("0b1e30e6-326e-4c1a-868d-ad6598b49e8b"),
311-
GenericRoleConfig::default(),
310+
v1alpha1::OpenSearchRoleConfig::default(),
312311
[(
313312
RoleGroupName::from_str_unsafe("default"),
314313
role_group_config.clone(),

rust/operator-binary/src/controller/build/role_group_builder.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,6 @@ mod tests {
822822
k8s_openapi::api::core::v1::PodTemplateSpec,
823823
kvp::LabelValue,
824824
product_logging::spec::AutomaticContainerLogConfig,
825-
role_utils::GenericRoleConfig,
826825
shared::time::Duration,
827826
};
828827
use strum::IntoEnumIterator;
@@ -925,7 +924,7 @@ mod tests {
925924
ClusterName::from_str_unsafe("my-opensearch-cluster"),
926925
NamespaceName::from_str_unsafe("default"),
927926
uuid!("0b1e30e6-326e-4c1a-868d-ad6598b49e8b"),
928-
GenericRoleConfig::default(),
927+
v1alpha1::OpenSearchRoleConfig::default(),
929928
[(
930929
RoleGroupName::from_str_unsafe("default"),
931930
role_group_config.clone(),

rust/operator-binary/src/controller/validate.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ mod tests {
279279
ContainerLogConfigChoiceFragment, ContainerLogConfigFragment,
280280
CustomContainerLogConfigFragment, LogLevel, LoggerConfig, LoggingFragment,
281281
},
282-
role_utils::{CommonConfiguration, GenericRoleConfig, Role, RoleGroup},
282+
role_utils::{CommonConfiguration, Role, RoleGroup},
283283
shared::time::Duration,
284284
};
285285
use uuid::uuid;
@@ -332,7 +332,7 @@ mod tests {
332332
ClusterName::from_str_unsafe("my-opensearch"),
333333
NamespaceName::from_str_unsafe("default"),
334334
uuid!("e6ac237d-a6d4-43a1-8135-f36506110912"),
335-
GenericRoleConfig::default(),
335+
v1alpha1::OpenSearchRoleConfig::default(),
336336
[(
337337
RoleGroupName::from_str_unsafe("default"),
338338
RoleGroupConfig {
@@ -764,7 +764,7 @@ mod tests {
764764
product_specific_common_config: GenericProductSpecificCommonConfig::default(
765765
),
766766
},
767-
role_config: GenericRoleConfig::default(),
767+
role_config: v1alpha1::OpenSearchRoleConfig::default(),
768768
role_groups: [(
769769
"default".to_owned(),
770770
RoleGroup {

rust/operator-binary/src/crd/mod.rs

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ use crate::{
4141
},
4242
};
4343

44-
constant!(DEFAULT_LISTENER_CLASS: ListenerClassName = "cluster-internal");
44+
constant!(DEFAULT_ROLE_GROUP_LISTENER_CLASS: ListenerClassName = "cluster-internal");
45+
constant!(DEFAULT_DISCOVERY_SERVICE_LISTENER_CLASS: ListenerClassName = "cluster-internal");
4546
constant!(TLS_DEFAULT_SECRET_CLASS: SecretClassName = "tls");
4647

4748
#[versioned(
@@ -81,8 +82,11 @@ pub mod versioned {
8182
pub cluster_operation: ClusterOperation,
8283

8384
// no doc - docs in Role struct
84-
pub nodes:
85-
Role<OpenSearchConfigFragment, GenericRoleConfig, GenericProductSpecificCommonConfig>,
85+
pub nodes: Role<
86+
OpenSearchConfigFragment,
87+
OpenSearchRoleConfig,
88+
GenericProductSpecificCommonConfig,
89+
>,
8690
}
8791

8892
#[derive(Clone, Debug, Default, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
@@ -202,6 +206,9 @@ pub mod versioned {
202206
#[fragment_attrs(serde(default))]
203207
pub affinity: StackableAffinity,
204208

209+
/// Determines whether this role group is exposed in the discovery service.
210+
pub discovery_service_exposed: bool,
211+
205212
/// Time period Pods have to gracefully shut down, e.g. `30m`, `1h` or `2d`. Consult the
206213
/// operator documentation for details.
207214
#[fragment_attrs(serde(default))]
@@ -277,6 +284,17 @@ pub mod versioned {
277284
pub data: PvcConfig,
278285
}
279286

287+
#[derive(Clone, Debug, Deserialize, JsonSchema, PartialEq, Serialize)]
288+
#[serde(rename_all = "camelCase")]
289+
pub struct OpenSearchRoleConfig {
290+
#[serde(flatten)]
291+
pub common: GenericRoleConfig,
292+
293+
/// The [ListenerClass](https://docs.stackable.tech/home/nightly/listener-operator/listenerclass.html) that is used for the discovery service.
294+
#[serde(default = "discovery_service_listener_class_default")]
295+
pub discovery_service_listener_class: ListenerClassName,
296+
}
297+
280298
#[derive(Clone, Default, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
281299
#[serde(rename_all = "camelCase")]
282300
pub struct OpenSearchClusterStatus {
@@ -320,12 +338,13 @@ impl v1alpha1::OpenSearchConfig {
320338
node_affinity: None,
321339
node_selector: None,
322340
},
341+
discovery_service_exposed: Some(true),
323342
// Default taken from the Helm chart, see
324343
// https://github.com/opensearch-project/helm-charts/blob/opensearch-3.0.0/charts/opensearch/values.yaml#L364
325344
graceful_shutdown_timeout: Some(
326345
Duration::from_str("2m").expect("should be a valid duration"),
327346
),
328-
listener_class: Some(DEFAULT_LISTENER_CLASS.to_owned()),
347+
listener_class: Some(DEFAULT_ROLE_GROUP_LISTENER_CLASS.to_owned()),
329348
logging: product_logging::spec::default_logging(),
330349
// Defaults taken from the Helm chart, see
331350
// https://github.com/opensearch-project/helm-charts/blob/opensearch-3.0.0/charts/opensearch/values.yaml#L16-L20
@@ -384,6 +403,19 @@ fn internal_secret_class_default() -> SecretClassName {
384403
TLS_DEFAULT_SECRET_CLASS.to_owned()
385404
}
386405

406+
impl Default for v1alpha1::OpenSearchRoleConfig {
407+
fn default() -> Self {
408+
v1alpha1::OpenSearchRoleConfig {
409+
common: GenericRoleConfig::default(),
410+
discovery_service_listener_class: discovery_service_listener_class_default(),
411+
}
412+
}
413+
}
414+
415+
fn discovery_service_listener_class_default() -> ListenerClassName {
416+
DEFAULT_DISCOVERY_SERVICE_LISTENER_CLASS.to_owned()
417+
}
418+
387419
#[derive(Clone, Debug, Default, Deserialize, JsonSchema, PartialEq, Serialize)]
388420
pub struct NodeRoles(pub Vec<v1alpha1::NodeRole>);
389421

0 commit comments

Comments
 (0)