Skip to content

Commit d292f1e

Browse files
feat: Watch all deployed resources (#103)
1 parent f7890c9 commit d292f1e

1 file changed

Lines changed: 60 additions & 35 deletions

File tree

rust/operator-binary/src/main.rs

Lines changed: 60 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ use snafu::{ResultExt as _, Snafu};
88
use stackable_operator::{
99
YamlSchema as _,
1010
cli::{Command, RunArguments},
11+
crd::listener,
1112
eos::EndOfSupportChecker,
12-
k8s_openapi::api::{apps::v1::StatefulSet, core::v1::Service},
13+
k8s_openapi::api::{
14+
apps::v1::StatefulSet,
15+
core::v1::{ConfigMap, Service, ServiceAccount},
16+
policy::v1::PodDisruptionBudget,
17+
rbac::v1::RoleBinding,
18+
},
1319
kube::{
1420
core::DeserializeGuard,
1521
runtime::{
@@ -133,40 +139,59 @@ async fn main() -> Result<()> {
133139
let controller = Controller::new(
134140
watch_namespace.get_api::<DeserializeGuard<v1alpha1::OpenSearchCluster>>(&client),
135141
watcher::Config::default(),
136-
);
137-
let controller = controller
138-
.owns(
139-
watch_namespace.get_api::<Service>(&client),
140-
watcher::Config::default(),
141-
)
142-
.owns(
143-
watch_namespace.get_api::<StatefulSet>(&client),
144-
watcher::Config::default(),
145-
)
146-
.shutdown_on_signal()
147-
.run(
148-
controller::reconcile,
149-
controller::error_policy,
150-
Arc::new(controller_context),
151-
)
152-
.for_each_concurrent(
153-
16, // concurrency limit
154-
|result| {
155-
// The event_recorder needs to be shared across all invocations, so that
156-
// events are correctly aggregated
157-
let event_recorder = event_recorder.clone();
158-
let full_controller_name = full_controller_name.clone();
159-
async move {
160-
report_controller_reconciled(
161-
&event_recorder,
162-
&full_controller_name,
163-
&result,
164-
)
165-
.await;
166-
}
167-
},
168-
)
169-
.map(Ok);
142+
)
143+
.owns(
144+
watch_namespace.get_api::<DeserializeGuard<ConfigMap>>(&client),
145+
watcher::Config::default(),
146+
)
147+
.owns(
148+
watch_namespace.get_api::<DeserializeGuard<listener::v1alpha1::Listener>>(&client),
149+
watcher::Config::default(),
150+
)
151+
.owns(
152+
watch_namespace.get_api::<DeserializeGuard<RoleBinding>>(&client),
153+
watcher::Config::default(),
154+
)
155+
.owns(
156+
watch_namespace.get_api::<DeserializeGuard<PodDisruptionBudget>>(&client),
157+
watcher::Config::default(),
158+
)
159+
.owns(
160+
watch_namespace.get_api::<DeserializeGuard<Service>>(&client),
161+
watcher::Config::default(),
162+
)
163+
.owns(
164+
watch_namespace.get_api::<DeserializeGuard<ServiceAccount>>(&client),
165+
watcher::Config::default(),
166+
)
167+
.owns(
168+
watch_namespace.get_api::<DeserializeGuard<StatefulSet>>(&client),
169+
watcher::Config::default(),
170+
)
171+
.shutdown_on_signal()
172+
.run(
173+
controller::reconcile,
174+
controller::error_policy,
175+
Arc::new(controller_context),
176+
)
177+
.for_each_concurrent(
178+
16, // concurrency limit
179+
|result| {
180+
// The event_recorder needs to be shared across all invocations, so that
181+
// events are correctly aggregated
182+
let event_recorder = event_recorder.clone();
183+
let full_controller_name = full_controller_name.clone();
184+
async move {
185+
report_controller_reconciled(
186+
&event_recorder,
187+
&full_controller_name,
188+
&result,
189+
)
190+
.await;
191+
}
192+
},
193+
)
194+
.map(Ok);
170195

171196
futures::try_join!(controller, eos_checker)?;
172197
}

0 commit comments

Comments
 (0)