Skip to content

Commit 50e8f08

Browse files
committed
adapt to op-rs 0.79.0
1 parent aadaa3b commit 50e8f08

File tree

8 files changed

+59
-19
lines changed

8 files changed

+59
-19
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
- Add support for Hive `4.0.0` ([#508]).
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

@@ -22,6 +25,7 @@ All notable changes to this project will be documented in this file.
2225
[#505]: https://github.com/stackabletech/hive-operator/pull/505
2326
[#508]: https://github.com/stackabletech/hive-operator/pull/508
2427
[#518]: https://github.com/stackabletech/hive-operator/pull/518
28+
[#xxx]: https://github.com/stackabletech/hive-operator/pull/xxx
2529

2630
## [24.7.0] - 2024-07-24
2731

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
@@ -23,7 +23,7 @@ serde = { version = "1.0", features = ["derive"] }
2323
serde_json = "1.0"
2424
serde_yaml = "0.9"
2525
snafu = "0.8"
26-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.77.1" }
26+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.79.0" }
2727
product-config = { git = "https://github.com/stackabletech/product-config.git", tag = "0.7.0" }
2828
strum = { version = "0.26", features = ["derive"] }
2929
tokio = { version = "1.40", features = ["full"] }

deploy/helm/hive-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: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use stackable_operator::{
2727
schemars::{self, JsonSchema},
2828
status::condition::{ClusterCondition, HasStatusCondition},
2929
time::Duration,
30+
utils::cluster_domain::KUBERNETES_CLUSTER_DOMAIN,
3031
};
3132
use strum::{Display, EnumIter, EnumString, IntoEnumIterator};
3233

@@ -696,9 +697,12 @@ pub struct PodRef {
696697

697698
impl PodRef {
698699
pub fn fqdn(&self) -> String {
700+
let cluster_domain = KUBERNETES_CLUSTER_DOMAIN
701+
.get()
702+
.expect("KUBERNETES_CLUSTER_DOMAIN must first be set by calling initialize_operator");
699703
format!(
700-
"{}.{}.{}.svc.cluster.local",
701-
self.pod_name, self.role_group_service_name, self.namespace
704+
"{}.{}.{}.svc.{}",
705+
self.pod_name, self.role_group_service_name, self.namespace, cluster_domain
702706
)
703707
}
704708
}

rust/operator-binary/src/discovery.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::controller::build_recommended_labels;
33
use snafu::{OptionExt, ResultExt, Snafu};
44
use stackable_hive_crd::{HiveCluster, HiveRole, ServiceType, HIVE_PORT, HIVE_PORT_NAME};
55
use stackable_operator::commons::product_image_selection::ResolvedProductImage;
6+
use stackable_operator::utils::cluster_domain::KUBERNETES_CLUSTER_DOMAIN;
67
use stackable_operator::{
78
builder::{configmap::ConfigMapBuilder, meta::ObjectMetaBuilder},
89
k8s_openapi::api::core::v1::ConfigMap,
@@ -75,14 +76,19 @@ pub async fn build_discovery_configmaps(
7576
.namespace
7677
.as_deref()
7778
.context(NoNamespaceSnafu)?;
79+
let cluster_domain = KUBERNETES_CLUSTER_DOMAIN
80+
.get()
81+
.expect("KUBERNETES_CLUSTER_DOMAIN must first be set by calling initialize_operator");
7882
let mut discovery_configmaps = vec![build_discovery_configmap(
7983
name,
8084
owner,
8185
hive,
8286
resolved_product_image,
8387
chroot,
84-
// TODO: make domain configurable
85-
vec![(format!("{name}.{namespace}.svc.cluster.local"), HIVE_PORT)],
88+
vec![(
89+
format!("{name}.{namespace}.svc.{cluster_domain}"),
90+
HIVE_PORT,
91+
)],
8692
)?];
8793

8894
// TODO: Temporary solution until listener-operator is finished

rust/operator-binary/src/kerberos.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
use indoc::formatdoc;
22
use snafu::{ResultExt, Snafu};
33
use stackable_hive_crd::{HiveCluster, HiveRole, HIVE_SITE_XML, STACKABLE_CONFIG_DIR};
4-
use stackable_operator::builder::{
5-
self,
6-
pod::{
7-
container::ContainerBuilder,
8-
volume::{
9-
SecretOperatorVolumeSourceBuilder, SecretOperatorVolumeSourceBuilderError,
10-
VolumeBuilder,
4+
use stackable_operator::{
5+
builder::{
6+
self,
7+
pod::{
8+
container::ContainerBuilder,
9+
volume::{
10+
SecretOperatorVolumeSourceBuilder, SecretOperatorVolumeSourceBuilderError,
11+
VolumeBuilder,
12+
},
13+
PodBuilder,
1114
},
12-
PodBuilder,
1315
},
16+
kube::ResourceExt,
17+
utils::cluster_domain::KUBERNETES_CLUSTER_DOMAIN,
1418
};
15-
use stackable_operator::kube::ResourceExt;
1619
use std::collections::BTreeMap;
1720

1821
#[derive(Snafu, Debug)]
@@ -69,9 +72,13 @@ pub fn kerberos_config_properties(
6972
if !hive.has_kerberos_enabled() {
7073
return BTreeMap::new();
7174
}
75+
7276
let hive_name = hive.name_any();
77+
let cluster_domain = KUBERNETES_CLUSTER_DOMAIN
78+
.get()
79+
.expect("KUBERNETES_CLUSTER_DOMAIN must first be set by calling initialize_operator");
7380
let principal_host_part =
74-
format!("{hive_name}.{hive_namespace}.svc.cluster.local@${{env.KERBEROS_REALM}}");
81+
format!("{hive_name}.{hive_namespace}.svc.{cluster_domain}@${{env.KERBEROS_REALM}}");
7582

7683
BTreeMap::from([
7784
// Kerberos settings

rust/operator-binary/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ async fn main() -> anyhow::Result<()> {
6666
])?;
6767

6868
let client =
69-
stackable_operator::client::create_client(Some(OPERATOR_NAME.to_string())).await?;
69+
stackable_operator::client::initialize_operator(Some(OPERATOR_NAME.to_string()))
70+
.await?;
7071

7172
Controller::new(
7273
watch_namespace.get_api::<HiveCluster>(&client),

0 commit comments

Comments
 (0)