Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions crates/stackable-operator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Added

- Make Deployments to ClusterResources ([#992]).

[#992]: https://github.com/stackabletech/operator-rs/pull/992

## [0.87.5] - 2025-03-19

### Fixed
Expand Down
27 changes: 26 additions & 1 deletion crates/stackable-operator/src/cluster_resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ use std::{

use k8s_openapi::{
api::{
apps::v1::{DaemonSet, DaemonSetSpec, StatefulSet, StatefulSetSpec},
apps::v1::{
DaemonSet, DaemonSetSpec, Deployment, DeploymentSpec, StatefulSet, StatefulSetSpec,
},
batch::v1::Job,
core::v1::{
ConfigMap, ObjectReference, PodSpec, PodTemplateSpec, Secret, Service, ServiceAccount,
Expand Down Expand Up @@ -279,6 +281,29 @@ impl ClusterResource for DaemonSet {
}
}

impl ClusterResource for Deployment {
fn maybe_mutate(self, strategy: &ClusterResourceApplyStrategy) -> Self {
match strategy {
ClusterResourceApplyStrategy::ClusterStopped => Deployment {
spec: Some(DeploymentSpec {
replicas: Some(0),
..self.spec.unwrap_or_default()
}),
..self
},
ClusterResourceApplyStrategy::Default
| ClusterResourceApplyStrategy::ReconciliationPaused
| ClusterResourceApplyStrategy::NoApply => self,
}
}

fn pod_spec(&self) -> Option<&PodSpec> {
self.spec
.as_ref()
.and_then(|spec| spec.template.spec.as_ref())
}
}

/// A structure containing the cluster resources.
///
/// Cluster resources can be added and orphaned resources are deleted. A cluster resource becomes
Expand Down
Loading