Skip to content

Commit 650ac95

Browse files
razvansbernauer
andauthored
feat: Add Deployments to ClusterResources (#992)
* feat: add support for Deployments * Update crates/stackable-operator/CHANGELOG.md Co-authored-by: Sebastian Bernauer <[email protected]> --------- Co-authored-by: Sebastian Bernauer <[email protected]>
1 parent e936f70 commit 650ac95

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

Diff for: crates/stackable-operator/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Added
8+
9+
- Add Deployments to `ClusterResource`s ([#992]).
10+
11+
[#992]: https://github.com/stackabletech/operator-rs/pull/992
12+
713
## [0.87.5] - 2025-03-19
814

915
### Fixed

Diff for: crates/stackable-operator/src/cluster_resources.rs

+26-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ use std::{
77

88
use k8s_openapi::{
99
api::{
10-
apps::v1::{DaemonSet, DaemonSetSpec, StatefulSet, StatefulSetSpec},
10+
apps::v1::{
11+
DaemonSet, DaemonSetSpec, Deployment, DeploymentSpec, StatefulSet, StatefulSetSpec,
12+
},
1113
batch::v1::Job,
1214
core::v1::{
1315
ConfigMap, ObjectReference, PodSpec, PodTemplateSpec, Secret, Service, ServiceAccount,
@@ -279,6 +281,29 @@ impl ClusterResource for DaemonSet {
279281
}
280282
}
281283

284+
impl ClusterResource for Deployment {
285+
fn maybe_mutate(self, strategy: &ClusterResourceApplyStrategy) -> Self {
286+
match strategy {
287+
ClusterResourceApplyStrategy::ClusterStopped => Deployment {
288+
spec: Some(DeploymentSpec {
289+
replicas: Some(0),
290+
..self.spec.unwrap_or_default()
291+
}),
292+
..self
293+
},
294+
ClusterResourceApplyStrategy::Default
295+
| ClusterResourceApplyStrategy::ReconciliationPaused
296+
| ClusterResourceApplyStrategy::NoApply => self,
297+
}
298+
}
299+
300+
fn pod_spec(&self) -> Option<&PodSpec> {
301+
self.spec
302+
.as_ref()
303+
.and_then(|spec| spec.template.spec.as_ref())
304+
}
305+
}
306+
282307
/// A structure containing the cluster resources.
283308
///
284309
/// Cluster resources can be added and orphaned resources are deleted. A cluster resource becomes

0 commit comments

Comments
 (0)