From 376ba3c65262040532e35a0c07536698f0210ccf Mon Sep 17 00:00:00 2001
From: Vincent Dely
Date: Tue, 5 May 2026 02:02:59 +0200
Subject: [PATCH] feat(api): allow dependencies on any Kubernetes resource
HelmReleases can now depend on any Kubernetes object, improving
flexibility in release ordering and readiness behavior.
Signed-off-by: Vincent Dely
---
api/v2/helmrelease_types.go | 2 +-
api/v2/reference_types.go | 23 +-
api/v2/zz_generated.deepcopy.go | 9 +-
.../helm.toolkit.fluxcd.io_helmreleases.yaml | 27 +-
docs/api/v2/helm.md | 51 ++-
internal/controller/helmrelease_controller.go | 84 ++++-
.../controller/helmrelease_controller_test.go | 299 +++++++++++++++++-
7 files changed, 463 insertions(+), 32 deletions(-)
diff --git a/api/v2/helmrelease_types.go b/api/v2/helmrelease_types.go
index 73cea73a4..19ec1518f 100644
--- a/api/v2/helmrelease_types.go
+++ b/api/v2/helmrelease_types.go
@@ -101,7 +101,7 @@ type HelmReleaseSpec struct {
StorageNamespace string `json:"storageNamespace,omitempty"`
// DependsOn may contain a DependencyReference slice with
- // references to HelmRelease resources that must be ready before this HelmRelease
+ // references to Kubernetes resources that must be ready before this HelmRelease
// can be reconciled.
// +optional
DependsOn []DependencyReference `json:"dependsOn,omitempty"`
diff --git a/api/v2/reference_types.go b/api/v2/reference_types.go
index 9f3ee4a1c..d6958394e 100644
--- a/api/v2/reference_types.go
+++ b/api/v2/reference_types.go
@@ -69,17 +69,32 @@ type CrossNamespaceSourceReference struct {
Namespace string `json:"namespace,omitempty"`
}
-// DependencyReference defines a HelmRelease dependency on another HelmRelease resource.
+// DependencyReference defines a HelmRelease dependency on a Kubernetes resource.
+// When the dependency is a HelmRelease, defaults are applied during reconciliation.
type DependencyReference struct {
- // Name of the referent.
+ // APIVersion of the resource to depend on, defaults to the HelmRelease API
+ // group version when the dependency is a HelmRelease.
+ // +optional
+ APIVersion string `json:"apiVersion,omitempty"`
+
+ // Kind of the resource to depend on, defaults to HelmRelease.
+ // +optional
+ Kind string `json:"kind,omitempty"`
+
+ // Name of the resource to depend on.
// +required
Name string `json:"name"`
- // Namespace of the referent, defaults to the namespace of the HelmRelease
- // resource object that contains the reference.
+ // Namespace of the resource to depend on, defaults to the namespace of the
+ // HelmRelease resource object that contains the reference.
// +optional
Namespace string `json:"namespace,omitempty"`
+ // Ready checks if the resource Ready status condition is true, defaults to
+ // true when the dependency is a HelmRelease.
+ // +optional
+ Ready *bool `json:"ready,omitempty"`
+
// ReadyExpr is a CEL expression that can be used to assess the readiness
// of a dependency. When specified, the built-in readiness check
// is replaced by the logic defined in the CEL expression.
diff --git a/api/v2/zz_generated.deepcopy.go b/api/v2/zz_generated.deepcopy.go
index f371a2181..e97dc01b9 100644
--- a/api/v2/zz_generated.deepcopy.go
+++ b/api/v2/zz_generated.deepcopy.go
@@ -90,6 +90,11 @@ func (in *CrossNamespaceSourceReference) DeepCopy() *CrossNamespaceSourceReferen
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DependencyReference) DeepCopyInto(out *DependencyReference) {
*out = *in
+ if in.Ready != nil {
+ in, out := &in.Ready, &out.Ready
+ *out = new(bool)
+ **out = **in
+ }
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DependencyReference.
@@ -321,7 +326,9 @@ func (in *HelmReleaseSpec) DeepCopyInto(out *HelmReleaseSpec) {
if in.DependsOn != nil {
in, out := &in.DependsOn, &out.DependsOn
*out = make([]DependencyReference, len(*in))
- copy(*out, *in)
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
}
if in.Timeout != nil {
in, out := &in.Timeout, &out.Timeout
diff --git a/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml b/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml
index bf06f7d30..a7a5db823 100644
--- a/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml
+++ b/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml
@@ -241,20 +241,35 @@ spec:
dependsOn:
description: |-
DependsOn may contain a DependencyReference slice with
- references to HelmRelease resources that must be ready before this HelmRelease
+ references to Kubernetes resources that must be ready before this HelmRelease
can be reconciled.
items:
- description: DependencyReference defines a HelmRelease dependency
- on another HelmRelease resource.
+ description: |-
+ DependencyReference defines a HelmRelease dependency on a Kubernetes resource.
+ When the dependency is a HelmRelease, defaults are applied during reconciliation.
properties:
+ apiVersion:
+ description: |-
+ APIVersion of the resource to depend on, defaults to the HelmRelease API
+ group version when the dependency is a HelmRelease.
+ type: string
+ kind:
+ description: Kind of the resource to depend on, defaults to
+ HelmRelease.
+ type: string
name:
- description: Name of the referent.
+ description: Name of the resource to depend on.
type: string
namespace:
description: |-
- Namespace of the referent, defaults to the namespace of the HelmRelease
- resource object that contains the reference.
+ Namespace of the resource to depend on, defaults to the namespace of the
+ HelmRelease resource object that contains the reference.
type: string
+ ready:
+ description: |-
+ Ready checks if the resource Ready status condition is true, defaults to
+ true when the dependency is a HelmRelease.
+ type: boolean
readyExpr:
description: |-
ReadyExpr is a CEL expression that can be used to assess the readiness
diff --git a/docs/api/v2/helm.md b/docs/api/v2/helm.md
index 639745c4f..b8f99936f 100644
--- a/docs/api/v2/helm.md
+++ b/docs/api/v2/helm.md
@@ -195,7 +195,7 @@ Defaults to the namespace of the HelmRelease.
(Optional)
DependsOn may contain a DependencyReference slice with
-references to HelmRelease resources that must be ready before this HelmRelease
+references to Kubernetes resources that must be ready before this HelmRelease
can be reconciled.
|
@@ -675,7 +675,8 @@ resource object that contains the reference.
(Appears on:
HelmReleaseSpec)
-DependencyReference defines a HelmRelease dependency on another HelmRelease resource.
+DependencyReference defines a HelmRelease dependency on a Kubernetes resource.
+When the dependency is a HelmRelease, defaults are applied during reconciliation.