Skip to content

Commit 4e5a1d5

Browse files
committed
adapt to op-rs 0.80.0
1 parent 91379b7 commit 4e5a1d5

File tree

9 files changed

+123
-69
lines changed

9 files changed

+123
-69
lines changed

CHANGELOG.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ All notable changes to this project will be documented in this file.
66

77
### Added
88

9-
- The operator can now run on Kubernetes clusters using a non-default cluster domain. It should automatically detect the
10-
correct domain to use, but you can also use the env var `KUBERNETES_CLUSTER_DOMAIN` to set the domain explicitly
11-
or use the helm-chart property `kubernetesClusterDomain` ([#870]).
9+
- The operator can now run on Kubernetes clusters using a non-default cluster domain.
10+
Use the env var `KUBERNETES_CLUSTER_DOMAIN` or the operator Helm chart property `kubernetesClusterDomain` to set a non-default cluster domain ([#870]).
1211

1312
### Changed
1413

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ serde = { version = "1.0", features = ["derive"] }
2222
serde_json = "1.0"
2323
serde_yaml = "0.9"
2424
snafu = "0.8"
25-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.79.0" }
25+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.80.0" }
2626
product-config = { git = "https://github.com/stackabletech/product-config.git", tag = "0.7.0" }
2727
strum = { version = "0.26", features = ["derive"] }
2828
tokio = { version = "1.40", features = ["full"] }

deploy/helm/zookeeper-operator/values.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ tolerations: []
4848

4949
affinity: {}
5050

51-
# When running on a non-default Kubernetes cluster domain and the auto detection is not working correctly,
52-
# you can set your custom cluster domain here.
53-
# See the https://docs.stackable.tech/home/stable/guides/kubernetes-cluster-domain guide for details
51+
# When running on a non-default Kubernetes cluster domain, the cluster domain can be configured here.
52+
# See the https://docs.stackable.tech/home/stable/guides/kubernetes-cluster-domain guide for details.
5453
# kubernetesClusterDomain: my-cluster.local

rust/crd/src/lib.rs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use stackable_operator::{
2929
schemars::{self, JsonSchema},
3030
status::condition::{ClusterCondition, HasStatusCondition},
3131
time::Duration,
32-
utils::cluster_domain::KUBERNETES_CLUSTER_DOMAIN,
32+
utils::cluster_info::KubernetesClusterInfo,
3333
};
3434
use strum::{Display, EnumIter, EnumString, IntoEnumIterator};
3535

@@ -483,15 +483,12 @@ impl ZookeeperCluster {
483483
}
484484

485485
/// The fully-qualified domain name of the role-level load-balanced Kubernetes `Service`
486-
pub fn server_role_service_fqdn(&self) -> Option<String> {
487-
let cluster_domain = KUBERNETES_CLUSTER_DOMAIN
488-
.get()
489-
.expect("KUBERNETES_CLUSTER_DOMAIN must first be set by calling initialize_operator");
486+
pub fn server_role_service_fqdn(&self, cluster_info: &KubernetesClusterInfo) -> Option<String> {
490487
Some(format!(
491-
"{}.{}.svc.{}",
492-
self.server_role_service_name()?,
493-
self.metadata.namespace.as_ref()?,
494-
cluster_domain
488+
"{role_service_name}.{namespace}.svc.{cluster_domain}",
489+
role_service_name = self.server_role_service_name()?,
490+
namespace = self.metadata.namespace.as_ref()?,
491+
cluster_domain = cluster_info.cluster_domain
495492
))
496493
}
497494

@@ -671,13 +668,13 @@ pub struct ZookeeperPodRef {
671668
}
672669

673670
impl ZookeeperPodRef {
674-
pub fn fqdn(&self) -> String {
675-
let cluster_domain = KUBERNETES_CLUSTER_DOMAIN
676-
.get()
677-
.expect("Could not resolve the Kubernetes cluster domain!");
671+
pub fn fqdn(&self, cluster_info: &KubernetesClusterInfo) -> String {
678672
format!(
679-
"{}.{}.{}.svc.{}",
680-
self.pod_name, self.role_group_service_name, self.namespace, cluster_domain
673+
"{pod_name}.{service_name}.{namespace}.svc.{cluster_domain}",
674+
pod_name = self.pod_name,
675+
service_name = self.role_group_service_name,
676+
namespace = self.namespace,
677+
cluster_domain = cluster_info.cluster_domain
681678
)
682679
}
683680
}

rust/operator-binary/src/discovery.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use stackable_operator::{
66
commons::product_image_selection::ResolvedProductImage,
77
k8s_openapi::api::core::v1::{ConfigMap, Endpoints, Service},
88
kube::{runtime::reflector::ObjectRef, Resource, ResourceExt},
9+
utils::cluster_info::KubernetesClusterInfo,
910
};
1011
use stackable_zookeeper_crd::{security::ZookeeperSecurity, ZookeeperCluster, ZookeeperRole};
1112

@@ -84,7 +85,7 @@ pub async fn build_discovery_configmaps(
8485
&namespace,
8586
controller_name,
8687
chroot,
87-
pod_hosts(zk, zookeeper_security)?,
88+
pod_hosts(zk, zookeeper_security, &client.kubernetes_cluster_info)?,
8889
resolved_product_image,
8990
)?];
9091
if zk.spec.cluster_config.listener_class
@@ -171,11 +172,12 @@ fn build_discovery_configmap(
171172
fn pod_hosts<'a>(
172173
zk: &'a ZookeeperCluster,
173174
zookeeper_security: &'a ZookeeperSecurity,
175+
cluster_info: &'a KubernetesClusterInfo,
174176
) -> Result<impl IntoIterator<Item = (String, u16)> + 'a> {
175177
Ok(zk
176178
.pods()
177179
.context(ExpectedPodsSnafu)?
178-
.map(|pod_ref| (pod_ref.fqdn(), zookeeper_security.client_port())))
180+
.map(|pod_ref| (pod_ref.fqdn(cluster_info), zookeeper_security.client_port())))
179181
}
180182

181183
/// Lists all nodes currently hosting Pods participating in the [`Service`]

rust/operator-binary/src/main.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ async fn main() -> anyhow::Result<()> {
5454
product_config,
5555
watch_namespace,
5656
tracing_target,
57+
cluster_info_opts,
5758
}) => {
5859
stackable_operator::logging::initialize_logging(
5960
"ZOOKEEPER_OPERATOR_LOG",
@@ -72,9 +73,11 @@ async fn main() -> anyhow::Result<()> {
7273
"deploy/config-spec/properties.yaml",
7374
"/etc/stackable/zookeeper-operator/config-spec/properties.yaml",
7475
])?;
75-
let client =
76-
stackable_operator::client::initialize_operator(Some(OPERATOR_NAME.to_string()))
77-
.await?;
76+
let client = stackable_operator::client::initialize_operator(
77+
Some(OPERATOR_NAME.to_string()),
78+
&cluster_info_opts,
79+
)
80+
.await?;
7881

7982
let zk_controller_builder = Controller::new(
8083
watch_namespace.get_api::<DeserializeGuard<ZookeeperCluster>>(&client),

0 commit comments

Comments
 (0)