diff --git a/crates/stackable-operator/CHANGELOG.md b/crates/stackable-operator/CHANGELOG.md index bfc1d698..d674fc2a 100644 --- a/crates/stackable-operator/CHANGELOG.md +++ b/crates/stackable-operator/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Added + +- Add Deployments to `ClusterResource`s ([#992]). + +[#992]: https://github.com/stackabletech/operator-rs/pull/992 + ## [0.87.5] - 2025-03-19 ### Fixed diff --git a/crates/stackable-operator/src/cluster_resources.rs b/crates/stackable-operator/src/cluster_resources.rs index dd4fad75..03dc2d9d 100644 --- a/crates/stackable-operator/src/cluster_resources.rs +++ b/crates/stackable-operator/src/cluster_resources.rs @@ -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, @@ -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