Skip to content

Commit d20565c

Browse files
committed
adapt to op-rs 0.79.0
1 parent ddeeabc commit d20565c

File tree

7 files changed

+49
-16
lines changed

7 files changed

+49
-16
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ All notable changes to this project will be documented in this file.
77
### Added
88

99
- Support version `3.8.0` ([#753]).
10+
- The operator can now run on Kubernetes clusters using a non-default cluster domain. It should automatically detect the
11+
correct domain to use, but you can also use the env var `KUBERNETES_CLUSTER_DOMAIN` to set the domain explicitly
12+
or use the helm-chart property `kubernetesClusterDomain` ([#xxx]).
1013

1114
### Changed
1215

@@ -32,6 +35,7 @@ All notable changes to this project will be documented in this file.
3235
[#741]: https://github.com/stackabletech/kafka-operator/pull/741
3336
[#750]: https://github.com/stackabletech/kafka-operator/pull/750
3437
[#753]: https://github.com/stackabletech/kafka-operator/pull/753
38+
[#xxx]: https://github.com/stackabletech/kafka-operator/pull/xxx
3539

3640
## [24.7.0] - 2024-07-24
3741

Cargo.lock

Lines changed: 16 additions & 3 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.78.0" }
25+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.79.0" }
2626
strum = { version = "0.26", features = ["derive"] }
2727
tokio = { version = "1.40", features = ["full"] }
2828
tracing = "0.1"

deploy/helm/kafka-operator/values.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,8 @@ nodeSelector: {}
4747
tolerations: []
4848

4949
affinity: {}
50+
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
54+
# kubernetesClusterDomain: my-cluster.local

rust/crd/src/lib.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ use stackable_operator::{
2222
PvcConfig, PvcConfigFragment, Resources, ResourcesFragment,
2323
},
2424
},
25-
config::fragment::{self, Fragment, ValidationError},
26-
config::merge::Merge,
25+
config::{
26+
fragment::{self, Fragment, ValidationError},
27+
merge::Merge,
28+
},
2729
k8s_openapi::{
2830
api::core::v1::PersistentVolumeClaim, apimachinery::pkg::api::resource::Quantity,
2931
},
@@ -34,6 +36,7 @@ use stackable_operator::{
3436
schemars::{self, JsonSchema},
3537
status::condition::{ClusterCondition, HasStatusCondition},
3638
time::Duration,
39+
utils::cluster_domain::KUBERNETES_CLUSTER_DOMAIN,
3740
};
3841
use std::{collections::BTreeMap, str::FromStr};
3942
use strum::{Display, EnumIter, EnumString, IntoEnumIterator};
@@ -283,9 +286,12 @@ pub struct KafkaPodRef {
283286

284287
impl KafkaPodRef {
285288
pub fn fqdn(&self) -> String {
289+
let cluster_domain = KUBERNETES_CLUSTER_DOMAIN
290+
.get()
291+
.expect("KUBERNETES_CLUSTER_DOMAIN must first be set by calling initialize_operator");
286292
format!(
287-
"{}.{}.{}.svc.cluster.local",
288-
self.pod_name, self.role_group_service_name, self.namespace
293+
"{}.{}.{}.svc.{}",
294+
self.pod_name, self.role_group_service_name, self.namespace, cluster_domain
289295
)
290296
}
291297
}

rust/crd/src/listener.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
use crate::{KafkaCluster, STACKABLE_LISTENER_BROKER_DIR};
2-
3-
use crate::security::KafkaTlsSecurity;
4-
use snafu::{OptionExt, Snafu};
5-
use stackable_operator::kube::ResourceExt;
61
use std::collections::BTreeMap;
72
use std::fmt::{Display, Formatter};
3+
4+
use snafu::{OptionExt, Snafu};
5+
use stackable_operator::{kube::ResourceExt, utils::cluster_domain::KUBERNETES_CLUSTER_DOMAIN};
86
use strum::{EnumDiscriminants, EnumString};
97

8+
use crate::security::KafkaTlsSecurity;
9+
use crate::{KafkaCluster, STACKABLE_LISTENER_BROKER_DIR};
10+
1011
const LISTENER_LOCAL_ADDRESS: &str = "0.0.0.0";
1112

1213
#[derive(Snafu, Debug, EnumDiscriminants)]
@@ -197,10 +198,14 @@ fn node_port_cmd(directory: &str, port_name: &str) -> String {
197198
}
198199

199200
fn pod_fqdn(kafka: &KafkaCluster, object_name: &str) -> Result<String, KafkaListenerError> {
201+
let cluster_domain = KUBERNETES_CLUSTER_DOMAIN
202+
.get()
203+
.expect("KUBERNETES_CLUSTER_DOMAIN must first be set by calling initialize_operator");
200204
Ok(format!(
201-
"$POD_NAME.{}.{}.svc.cluster.local",
205+
"$POD_NAME.{}.{}.svc.{}",
202206
object_name,
203-
kafka.namespace().context(ObjectHasNoNamespaceSnafu)?
207+
kafka.namespace().context(ObjectHasNoNamespaceSnafu)?,
208+
cluster_domain
204209
))
205210
}
206211

rust/operator-binary/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ async fn main() -> anyhow::Result<()> {
7878
"deploy/config-spec/properties.yaml",
7979
"/etc/stackable/kafka-operator/config-spec/properties.yaml",
8080
])?;
81-
let client = client::create_client(Some(OPERATOR_NAME.to_string())).await?;
81+
let client = client::initialize_operator(Some(OPERATOR_NAME.to_string())).await?;
8282
create_controller(client, product_config, watch_namespace).await;
8383
}
8484
};

0 commit comments

Comments
 (0)