From 5c6f2ddb129d55983c5372397beaa6e5100b776b Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Wed, 23 Oct 2024 14:34:05 +0200 Subject: [PATCH] feat: Support non-default cluster domain (#574) * feat: Support non-default cluster domain * changelog * docs * Update deploy/helm/hbase-operator/values.yaml Co-authored-by: Malte Sander * cargo +nightly update --breaking -Z unstable-options * Capture in variable * bump to op-rs 0.80.0 * changelog * fixup --------- Co-authored-by: Malte Sander --- CHANGELOG.md | 6 + Cargo.lock | 214 ++++++++++++------- Cargo.toml | 4 +- deploy/helm/hbase-operator/values.yaml | 4 + rust/operator-binary/src/discovery.rs | 8 +- rust/operator-binary/src/hbase_controller.rs | 97 ++++++--- rust/operator-binary/src/kerberos.rs | 50 +++-- rust/operator-binary/src/main.rs | 8 +- 8 files changed, 258 insertions(+), 133 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42ba8b7c..4a6fb6ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## [Unreleased] +### Added + +- The operator can now run on Kubernetes clusters using a non-default cluster domain. + Use the env var `KUBERNETES_CLUSTER_DOMAIN` or the operator Helm chart property `kubernetesClusterDomain` to set a non-default cluster domain ([#574]). + ### Changed - Reduce CRD size from `1.4MB` to `96KB` by accepting arbitrary YAML input instead of the underlying schema for the following fields ([#548]): @@ -22,6 +27,7 @@ [#550]: https://github.com/stackabletech/hbase-operator/pull/550 [#556]: https://github.com/stackabletech/hbase-operator/pull/556 [#558]: https://github.com/stackabletech/hbase-operator/pull/558 +[#574]: https://github.com/stackabletech/hbase-operator/pull/574 ## [24.7.0] - 2024-07-24 diff --git a/Cargo.lock b/Cargo.lock index 62085c4f..93f88c98 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -111,9 +111,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.89" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" +checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" [[package]] name = "async-broadcast" @@ -146,7 +146,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -157,7 +157,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -242,9 +242,9 @@ dependencies = [ [[package]] name = "built" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "236e6289eda5a812bc6b53c3b024039382a2895fbbeef2d748b2931546d392c4" +checksum = "c360505aed52b7ec96a3636c3f039d99103c37d1d9b4f7a8c743d3ea9ffcd03b" dependencies = [ "chrono", "git2", @@ -264,15 +264,15 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.2" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" [[package]] name = "cc" -version = "1.1.30" +version = "1.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16803a61b81d9eabb7eae2588776c4c1e584b738ede45fdbb4c972cec1e9945" +checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" dependencies = [ "jobserver", "libc", @@ -329,7 +329,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -444,7 +444,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -455,7 +455,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -466,7 +466,7 @@ checksum = "bc2323e10c92e1cf4d86e11538512e6dc03ceb586842970b6332af3d4046a046" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -525,6 +525,18 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" +[[package]] +name = "educe" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7bc049e1bd8cdeb31b68bbd586a9464ecf9f3944af3958a7a9d0f8b9799417" +dependencies = [ + "enum-ordinalize", + "proc-macro2", + "quote", + "syn 2.0.82", +] + [[package]] name = "either" version = "1.13.0" @@ -549,6 +561,26 @@ dependencies = [ "thiserror", ] +[[package]] +name = "enum-ordinalize" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea0dcfa4e54eeb516fe454635a95753ddd39acda650ce703031c6973e315dd5" +dependencies = [ + "enum-ordinalize-derive", +] + +[[package]] +name = "enum-ordinalize-derive" +version = "4.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d28318a75d4aead5c4db25382e8ef717932d0346600cacae6357eb5941bc5ff" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.82", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -673,7 +705,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -1121,9 +1153,9 @@ dependencies = [ [[package]] name = "kube" -version = "0.95.0" +version = "0.96.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa21063c854820a77c5d7f8deeb7ffa55246d8304e4bcd8cce2956752c6604f8" +checksum = "efffeb3df0bd4ef3e5d65044573499c0e4889b988070b08c50b25b1329289a1f" dependencies = [ "k8s-openapi", "kube-client", @@ -1134,9 +1166,9 @@ dependencies = [ [[package]] name = "kube-client" -version = "0.95.0" +version = "0.96.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c2355f5c9d8a11900e71a6fe1e47abd5ec45bf971eb4b162ffe97b46db9bb7" +checksum = "8bf471ece8ff8d24735ce78dac4d091e9fcb8d74811aeb6b75de4d1c3f5de0f1" dependencies = [ "base64 0.22.1", "bytes", @@ -1172,9 +1204,9 @@ dependencies = [ [[package]] name = "kube-core" -version = "0.95.0" +version = "0.96.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3030bd91c9db544a50247e7d48d7db9cf633c172732dce13351854526b1e666" +checksum = "f42346d30bb34d1d7adc5c549b691bce7aa3a1e60254e68fab7e2d7b26fe3d77" dependencies = [ "chrono", "form_urlencoded", @@ -1190,29 +1222,29 @@ dependencies = [ [[package]] name = "kube-derive" -version = "0.95.0" +version = "0.96.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa98be978eddd70a773aa8e86346075365bfb7eb48783410852dbf7cb57f0c27" +checksum = "f9364e04cc5e0482136c6ee8b7fb7551812da25802249f35b3def7aaa31e82ad" dependencies = [ "darling", "proc-macro2", "quote", "serde_json", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] name = "kube-runtime" -version = "0.95.0" +version = "0.96.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5895cb8aa641ac922408f128b935652b34c2995f16ad7db0984f6caa50217914" +checksum = "d3fbf1f6ffa98e65f1d2a9a69338bb60605d46be7edf00237784b89e62c9bd44" dependencies = [ "ahash", "async-broadcast", "async-stream", "async-trait", "backoff", - "derivative", + "educe", "futures 0.3.31", "hashbrown 0.14.5", "json-patch", @@ -1237,9 +1269,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.159" +version = "0.2.161" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "libgit2-sys" @@ -1429,7 +1461,7 @@ dependencies = [ "lazy_static", "once_cell", "opentelemetry", - "ordered-float 4.3.0", + "ordered-float 4.4.0", "percent-encoding", "rand", "thiserror", @@ -1448,9 +1480,9 @@ dependencies = [ [[package]] name = "ordered-float" -version = "4.3.0" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d501f1a72f71d3c063a6bbc8f7271fa73aa09fe5d6283b6571e2ed176a2537" +checksum = "83e7ccb95e240b7c9506a3d544f10d935e142cc90b0a1d56954fb44d89ad6b97" dependencies = [ "num-traits", ] @@ -1537,7 +1569,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -1568,7 +1600,7 @@ checksum = "a4502d8515ca9f32f1fb543d987f63d95a14934883db45bdb48060b6b69257f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -1615,9 +1647,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.87" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] @@ -1753,9 +1785,9 @@ dependencies = [ [[package]] name = "rstest" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b423f0e62bdd61734b67cd21ff50871dfaeb9cc74f869dcd6af974fbcb19936" +checksum = "0a2c585be59b6b5dd66a9d2084aa1d8bd52fbdb806eafdeffb52791147862035" dependencies = [ "futures 0.3.31", "futures-timer", @@ -1765,9 +1797,9 @@ dependencies = [ [[package]] name = "rstest_macros" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e1711e7d14f74b12a58411c542185ef7fb7f2e7f8ee6e2940a883628522b42" +checksum = "825ea780781b15345a146be27eaefb05085e337e869bff01b4306a4fd4a9ad5a" dependencies = [ "cfg-if", "glob", @@ -1777,7 +1809,7 @@ dependencies = [ "regex", "relative-path", "rustc_version", - "syn 2.0.79", + "syn 2.0.82", "unicode-ident", ] @@ -1798,9 +1830,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.14" +version = "0.23.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "415d9944693cb90382053259f89fbb077ea730ad7273047ec63b19bc9b160ba8" +checksum = "5fbb44d7acc4e873d613422379f69f237a1b141928c02f6bc6ccfddddc2d7993" dependencies = [ "log", "once_cell", @@ -1906,7 +1938,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -1917,11 +1949,10 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "secrecy" -version = "0.8.0" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bd1c54ea06cfd2f6b63219704de0b9b4f72dcc2b8fdef820be6cd799780e91e" +checksum = "e891af845473308773346dc847b2c23ee78fe442e0472ac50e22a18a93d3ae5a" dependencies = [ - "serde", "zeroize", ] @@ -1956,9 +1987,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.210" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" dependencies = [ "serde_derive", ] @@ -1975,13 +2006,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -1992,14 +2023,14 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "itoa", "memchr", @@ -2120,7 +2151,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -2179,8 +2210,8 @@ dependencies = [ [[package]] name = "stackable-operator" -version = "0.76.0" -source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.76.0#a7e70f174fb043a1766e0a80de95834cb4f7513d" +version = "0.80.0" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.80.0#6fbe32300b60f95e0baa2ab0ff2daf961b06531c" dependencies = [ "chrono", "clap", @@ -2190,6 +2221,7 @@ dependencies = [ "dockerfile-parser", "either", "futures 0.3.31", + "indexmap", "json-patch", "k8s-openapi", "kube", @@ -2204,6 +2236,7 @@ dependencies = [ "serde_yaml", "snafu 0.8.5", "stackable-operator-derive", + "stackable-shared", "strum", "tokio", "tracing", @@ -2216,12 +2249,24 @@ dependencies = [ [[package]] name = "stackable-operator-derive" version = "0.3.1" -source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.76.0#a7e70f174fb043a1766e0a80de95834cb4f7513d" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.80.0#6fbe32300b60f95e0baa2ab0ff2daf961b06531c" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", +] + +[[package]] +name = "stackable-shared" +version = "0.0.1" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.80.0#6fbe32300b60f95e0baa2ab0ff2daf961b06531c" +dependencies = [ + "kube", + "semver", + "serde", + "serde_yaml", + "snafu 0.8.5", ] [[package]] @@ -2249,7 +2294,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -2271,33 +2316,39 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.79" +version = "2.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +checksum = "83540f837a8afc019423a8edb95b52a8effe46957ee402287f4292fae35be021" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + [[package]] name = "thiserror" -version = "1.0.64" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" +checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.64" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" +checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -2380,9 +2431,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.40.0" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" dependencies = [ "backtrace", "bytes", @@ -2404,7 +2455,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -2462,14 +2513,14 @@ dependencies = [ [[package]] name = "tower" -version = "0.4.13" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" dependencies = [ "futures-core", "futures-util", - "pin-project", "pin-project-lite", + "sync_wrapper", "tokio", "tokio-util", "tower-layer", @@ -2479,16 +2530,15 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.5.2" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" +checksum = "8437150ab6bbc8c5f0f519e3d5ed4aa883a83dd4cdd3d1b21f9482936046cb97" dependencies = [ - "base64 0.21.7", + "base64 0.22.1", "bitflags 2.6.0", "bytes", "http", "http-body", - "http-body-util", "mime", "pin-project-lite", "tower-layer", @@ -2540,7 +2590,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -2743,7 +2793,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", "wasm-bindgen-shared", ] @@ -2765,7 +2815,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2932,7 +2982,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index a897f099..ee6a214d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,12 +16,12 @@ clap = "4.5" fnv = "1.0" futures = { version = "0.3", features = ["compat"] } indoc = "2.0" -rstest = "0.22" +rstest = "0.23" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" serde_yaml = "0.9" snafu = "0.8" -stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.76.0" } +stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.80.0" } product-config = { git = "https://github.com/stackabletech/product-config.git", tag = "0.7.0" } strum = { version = "0.26", features = ["derive"] } tokio = { version = "1.40", features = ["full"] } diff --git a/deploy/helm/hbase-operator/values.yaml b/deploy/helm/hbase-operator/values.yaml index bf423d72..7d14bf15 100644 --- a/deploy/helm/hbase-operator/values.yaml +++ b/deploy/helm/hbase-operator/values.yaml @@ -47,3 +47,7 @@ nodeSelector: {} tolerations: [] affinity: {} + +# When running on a non-default Kubernetes cluster domain, the cluster domain can be configured here. +# See the https://docs.stackable.tech/home/stable/guides/kubernetes-cluster-domain guide for details. +# kubernetesClusterDomain: my-cluster.local diff --git a/rust/operator-binary/src/discovery.rs b/rust/operator-binary/src/discovery.rs index c3dac370..f5c9e8a4 100644 --- a/rust/operator-binary/src/discovery.rs +++ b/rust/operator-binary/src/discovery.rs @@ -8,6 +8,7 @@ use stackable_operator::{ commons::product_image_selection::ResolvedProductImage, k8s_openapi::api::core::v1::ConfigMap, kube::runtime::reflector::ObjectRef, + utils::cluster_info::KubernetesClusterInfo, }; use crate::{ @@ -43,12 +44,15 @@ pub enum Error { /// Creates a discovery config map containing the `hbase-site.xml` for clients. pub fn build_discovery_configmap( hbase: &HbaseCluster, + cluster_info: &KubernetesClusterInfo, zookeeper_connection_information: &ZookeeperConnectionInformation, resolved_product_image: &ResolvedProductImage, ) -> Result { let mut hbase_site = zookeeper_connection_information.as_hbase_settings(); - hbase_site - .extend(kerberos_discovery_config_properties(hbase).context(AddKerberosDiscoverySnafu)?); + hbase_site.extend( + kerberos_discovery_config_properties(hbase, cluster_info) + .context(AddKerberosDiscoverySnafu)?, + ); ConfigMapBuilder::new() .metadata( diff --git a/rust/operator-binary/src/hbase_controller.rs b/rust/operator-binary/src/hbase_controller.rs index 62736c04..5e62d57e 100644 --- a/rust/operator-binary/src/hbase_controller.rs +++ b/rust/operator-binary/src/hbase_controller.rs @@ -15,6 +15,7 @@ use product_config::{ use snafu::{OptionExt, ResultExt, Snafu}; use stackable_operator::{ builder::{ + self, configmap::ConfigMapBuilder, meta::ObjectMetaBuilder, pod::{ @@ -46,7 +47,9 @@ use stackable_operator::{ product_config_utils::{transform_all_roles_to_config, validate_all_roles_and_groups_config}, product_logging::{ self, - framework::{create_vector_shutdown_file_command, remove_vector_shutdown_file_command}, + framework::{ + create_vector_shutdown_file_command, remove_vector_shutdown_file_command, LoggingError, + }, spec::{ ConfigMapLogConfig, ContainerLogConfig, ContainerLogConfigChoice, CustomContainerLogConfig, @@ -58,7 +61,7 @@ use stackable_operator::{ statefulset::StatefulSetConditionBuilder, }, time::Duration, - utils::COMMON_BASH_TRAP_FUNCTIONS, + utils::{cluster_info::KubernetesClusterInfo, COMMON_BASH_TRAP_FUNCTIONS}, }; use strum::{EnumDiscriminants, IntoStaticStr, ParseError}; @@ -293,6 +296,17 @@ pub enum Error { #[snafu(display("authorization is only supported from HBase 2.6 onwards"))] AuthorizationNotSupported, + #[snafu(display("failed to configure logging"))] + ConfigureLogging { source: LoggingError }, + + #[snafu(display("failed to add needed volume"))] + AddVolume { source: builder::pod::Error }, + + #[snafu(display("failed to add needed volumeMount"))] + AddVolumeMount { + source: builder::pod::container::Error, + }, + #[snafu(display("HBaseCluster object is invalid"))] InvalidHBaseCluster { source: error_boundary::InvalidObject, @@ -374,6 +388,7 @@ pub async fn reconcile_hbase( // discovery config map let discovery_cm = build_discovery_configmap( hbase, + &client.kubernetes_cluster_info, &zookeeper_connection_information, &resolved_product_image, ) @@ -421,6 +436,7 @@ pub async fn reconcile_hbase( build_rolegroup_service(hbase, &hbase_role, &rolegroup, &resolved_product_image)?; let rg_configmap = build_rolegroup_config_map( hbase, + &client.kubernetes_cluster_info, &rolegroup, rolegroup_config, &zookeeper_connection_information, @@ -546,6 +562,7 @@ pub fn build_region_server_role_service( #[allow(clippy::too_many_arguments)] fn build_rolegroup_config_map( hbase: &HbaseCluster, + cluster_info: &KubernetesClusterInfo, rolegroup: &RoleGroupRef, rolegroup_config: &HashMap>, zookeeper_connection_information: &ZookeeperConnectionInformation, @@ -569,8 +586,10 @@ fn build_rolegroup_config_map( PropertyNameKind::File(file_name) if file_name == HBASE_SITE_XML => { let mut hbase_site_config = BTreeMap::new(); hbase_site_config.extend(zookeeper_connection_information.as_hbase_settings()); - hbase_site_config - .extend(kerberos_config_properties(hbase).context(AddKerberosConfigSnafu)?); + hbase_site_config.extend( + kerberos_config_properties(hbase, cluster_info) + .context(AddKerberosConfigSnafu)?, + ); hbase_site_config .extend(hbase_opa_config.map_or(vec![], |config| config.hbase_site_config())); @@ -870,9 +889,13 @@ fn build_rolegroup_statefulset( }]) .add_env_vars(merged_env) .add_volume_mount("hbase-config", HBASE_CONFIG_TMP_DIR) + .context(AddVolumeMountSnafu)? .add_volume_mount("hdfs-discovery", HDFS_DISCOVERY_TMP_DIR) + .context(AddVolumeMountSnafu)? .add_volume_mount("log-config", HBASE_LOG_CONFIG_TMP_DIR) + .context(AddVolumeMountSnafu)? .add_volume_mount("log", STACKABLE_LOG_DIR) + .context(AddVolumeMountSnafu)? .add_container_ports(ports) .resources(config.resources.clone().into()) .startup_probe(startup_probe) @@ -903,6 +926,7 @@ fn build_rolegroup_statefulset( }), ..Default::default() }) + .context(AddVolumeSnafu)? .add_volume(stackable_operator::k8s_openapi::api::core::v1::Volume { name: "hdfs-discovery".to_string(), config_map: Some(ConfigMapVolumeSource { @@ -911,12 +935,14 @@ fn build_rolegroup_statefulset( }), ..Default::default() }) + .context(AddVolumeSnafu)? .add_empty_dir_volume( "log", Some(product_logging::framework::calculate_log_volume_size_limit( &[MAX_HBASE_LOG_FILES_SIZE], )), ) + .context(AddVolumeSnafu)? .service_account_name(service_account_name(APP_NAME)) .security_context( PodSecurityContextBuilder::new() @@ -933,23 +959,27 @@ fn build_rolegroup_statefulset( })), }) = config.logging.containers.get(&Container::Hbase) { - pod_builder.add_volume(Volume { - name: "log-config".to_string(), - config_map: Some(ConfigMapVolumeSource { - name: config_map.into(), - ..ConfigMapVolumeSource::default() - }), - ..Volume::default() - }); + pod_builder + .add_volume(Volume { + name: "log-config".to_string(), + config_map: Some(ConfigMapVolumeSource { + name: config_map.into(), + ..ConfigMapVolumeSource::default() + }), + ..Volume::default() + }) + .context(AddVolumeSnafu)?; } else { - pod_builder.add_volume(Volume { - name: "log-config".to_string(), - config_map: Some(ConfigMapVolumeSource { - name: rolegroup_ref.object_name(), - ..ConfigMapVolumeSource::default() - }), - ..Volume::default() - }); + pod_builder + .add_volume(Volume { + name: "log-config".to_string(), + config_map: Some(ConfigMapVolumeSource { + name: rolegroup_ref.object_name(), + ..ConfigMapVolumeSource::default() + }), + ..Volume::default() + }) + .context(AddVolumeSnafu)?; } add_graceful_shutdown_config(config, &mut pod_builder).context(GracefulShutdownSnafu)?; @@ -961,18 +991,21 @@ fn build_rolegroup_statefulset( // Vector sidecar shall be the last container in the list if config.logging.enable_vector_agent { - pod_builder.add_container(product_logging::framework::vector_container( - resolved_product_image, - "hbase-config", - "log", - config.logging.containers.get(&Container::Vector), - ResourceRequirementsBuilder::new() - .with_cpu_request("250m") - .with_cpu_limit("500m") - .with_memory_request("128Mi") - .with_memory_limit("128Mi") - .build(), - )); + pod_builder.add_container( + product_logging::framework::vector_container( + resolved_product_image, + "hbase-config", + "log", + config.logging.containers.get(&Container::Vector), + ResourceRequirementsBuilder::new() + .with_cpu_request("250m") + .with_cpu_limit("500m") + .with_memory_request("128Mi") + .with_memory_limit("128Mi") + .build(), + ) + .context(ConfigureLoggingSnafu)?, + ); } let mut pod_template = pod_builder.build_template(); diff --git a/rust/operator-binary/src/kerberos.rs b/rust/operator-binary/src/kerberos.rs index adbb4604..9bea6b8a 100644 --- a/rust/operator-binary/src/kerberos.rs +++ b/rust/operator-binary/src/kerberos.rs @@ -6,12 +6,16 @@ use stackable_hbase_crd::{ HbaseCluster, HbaseRole, TLS_STORE_DIR, TLS_STORE_PASSWORD, TLS_STORE_VOLUME_NAME, }; use stackable_operator::{ - builder::pod::{ - container::ContainerBuilder, - volume::{SecretFormat, SecretOperatorVolumeSourceBuilder, VolumeBuilder}, - PodBuilder, + builder::{ + self, + pod::{ + container::ContainerBuilder, + volume::{SecretFormat, SecretOperatorVolumeSourceBuilder, VolumeBuilder}, + PodBuilder, + }, }, kube::{runtime::reflector::ObjectRef, ResourceExt}, + utils::cluster_info::KubernetesClusterInfo, }; #[derive(Snafu, Debug)] @@ -28,14 +32,25 @@ pub enum Error { AddTlsSecretVolume { source: stackable_operator::builder::pod::volume::SecretOperatorVolumeSourceBuilderError, }, + + #[snafu(display("failed to add needed volume"))] + AddVolume { source: builder::pod::Error }, + + #[snafu(display("failed to add needed volumeMount"))] + AddVolumeMount { + source: builder::pod::container::Error, + }, } -pub fn kerberos_config_properties(hbase: &HbaseCluster) -> Result, Error> { +pub fn kerberos_config_properties( + hbase: &HbaseCluster, + cluster_info: &KubernetesClusterInfo, +) -> Result, Error> { if !hbase.has_kerberos_enabled() { return Ok(BTreeMap::new()); } - let principal_host_part = principal_host_part(hbase)?; + let principal_host_part = principal_host_part(hbase, cluster_info)?; Ok(BTreeMap::from([ // Kerberos settings @@ -122,12 +137,13 @@ pub fn kerberos_config_properties(hbase: &HbaseCluster) -> Result Result, Error> { if !hbase.has_kerberos_enabled() { return Ok(BTreeMap::new()); } - let principal_host_part = principal_host_part(hbase)?; + let principal_host_part = principal_host_part(hbase, cluster_info)?; Ok(BTreeMap::from([ ( @@ -230,8 +246,10 @@ pub fn add_kerberos_pod_config( VolumeBuilder::new("kerberos") .ephemeral(kerberos_secret_operator_volume) .build(), - ); - cb.add_volume_mount("kerberos", "/stackable/kerberos"); + ) + .context(AddVolumeSnafu)?; + cb.add_volume_mount("kerberos", "/stackable/kerberos") + .context(AddVolumeMountSnafu)?; // Needed env vars cb.add_env_var("KRB5_CONFIG", "/stackable/kerberos/krb5.conf"); @@ -256,8 +274,10 @@ pub fn add_kerberos_pod_config( .context(AddTlsSecretVolumeSnafu)?, ) .build(), - ); - cb.add_volume_mount(TLS_STORE_VOLUME_NAME, TLS_STORE_DIR); + ) + .context(AddVolumeSnafu)?; + cb.add_volume_mount(TLS_STORE_VOLUME_NAME, TLS_STORE_DIR) + .context(AddVolumeMountSnafu)?; } Ok(()) } @@ -272,12 +292,16 @@ pub fn kerberos_container_start_commands(hbase: &HbaseCluster) -> String { } } -fn principal_host_part(hbase: &HbaseCluster) -> Result { +fn principal_host_part( + hbase: &HbaseCluster, + cluster_info: &KubernetesClusterInfo, +) -> Result { let hbase_name = hbase.name_any(); let hbase_namespace = hbase.namespace().context(ObjectMissingNamespaceSnafu { hbase: ObjectRef::from_obj(hbase), })?; + let cluster_domain = &cluster_info.cluster_domain; Ok(format!( - "{hbase_name}.{hbase_namespace}.svc.cluster.local@${{env.KERBEROS_REALM}}" + "{hbase_name}.{hbase_namespace}.svc.{cluster_domain}@${{env.KERBEROS_REALM}}" )) } diff --git a/rust/operator-binary/src/main.rs b/rust/operator-binary/src/main.rs index a762b17e..ae00a15a 100644 --- a/rust/operator-binary/src/main.rs +++ b/rust/operator-binary/src/main.rs @@ -45,6 +45,7 @@ async fn main() -> anyhow::Result<()> { product_config, watch_namespace, tracing_target, + cluster_info_opts, }) => { stackable_operator::logging::initialize_logging( "HBASE_OPERATOR_LOG", @@ -63,8 +64,11 @@ async fn main() -> anyhow::Result<()> { "deploy/config-spec/properties.yaml", "/etc/stackable/hbase-operator/config-spec/properties.yaml", ])?; - let client = - stackable_operator::client::create_client(Some(OPERATOR_NAME.to_string())).await?; + let client = stackable_operator::client::initialize_operator( + Some(OPERATOR_NAME.to_string()), + &cluster_info_opts, + ) + .await?; Controller::new( watch_namespace.get_api::>(&client),