add optional storageNamespace

Signed-off-by: gtracer <ganesha.ashoka@gmail.com>

update comments

Signed-off-by: gtracer <ganesha.ashoka@gmail.com>

make test

Signed-off-by: gtracer <ganesha.ashoka@gmail.com>

revert controller-gen version

Signed-off-by: gtracer <ganesha.ashoka@gmail.com>
This commit is contained in:
gtracer 2021-01-21 15:39:02 -08:00 committed by Hidde Beydals
parent e402a46816
commit a5ab88962a
4 changed files with 51 additions and 2 deletions

View File

@ -69,6 +69,14 @@ type HelmReleaseSpec struct {
// +optional
TargetNamespace string `json:"targetNamespace,omitempty"`
// StorageNamespace used for the Helm storage.
// Defaults to the namespace of the HelmRelease.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=63
// +kubebuilder:validation:Optional
// +optional
StorageNamespace string `json:"storageNamespace,omitempty"`
// DependsOn may contain a dependency.CrossNamespaceDependencyReference slice with
// references to HelmRelease resources that must be ready before this HelmRelease
// can be reconciled.
@ -793,6 +801,15 @@ func (in HelmRelease) GetReleaseNamespace() string {
return in.Namespace
}
// GetStorageNamespace returns the configured StorageNamespace for helm, or the namespace
// of the HelmRelease.
func (in HelmRelease) GetStorageNamespace() string {
if in.Spec.StorageNamespace != "" {
return in.Spec.StorageNamespace
}
return in.Namespace
}
// GetHelmChartName returns the name used by the controller for the HelmChart creation.
func (in HelmRelease) GetHelmChartName() string {
return strings.Join([]string{in.Namespace, in.Name}, "-")

View File

@ -255,6 +255,12 @@ spec:
description: The name of the Kubernetes service account to impersonate
when reconciling this HelmRelease.
type: string
storageNamespace:
description: StorageNamespace used for the Helm storage. Defaults
to the namespace of the HelmRelease.
maxLength: 63
minLength: 1
type: string
suspend:
description: Suspend tells the controller to suspend reconciliation
for this HelmRelease, it does not apply to already started reconciliations.

View File

@ -265,7 +265,7 @@ func (r *HelmReleaseReconciler) reconcileRelease(ctx context.Context,
if err != nil {
return v2.HelmReleaseNotReady(hr, v2.InitFailedReason, err.Error()), err
}
run, err := runner.NewRunner(getter, hr.GetNamespace(), log)
run, err := runner.NewRunner(getter, hr.GetStorageNamespace(), log)
if err != nil {
return v2.HelmReleaseNotReady(hr, v2.InitFailedReason, "failed to initialize Helm action runner"), err
}
@ -616,7 +616,7 @@ func (r *HelmReleaseReconciler) reconcileDelete(ctx context.Context, hr v2.HelmR
if err != nil {
return ctrl.Result{}, err
}
run, err := runner.NewRunner(getter, hr.GetNamespace(), logr.FromContext(ctx))
run, err := runner.NewRunner(getter, hr.GetStorageNamespace(), logr.FromContext(ctx))
if err != nil {
return ctrl.Result{}, err
}

View File

@ -151,6 +151,19 @@ Defaults to the namespace of the HelmRelease.</p>
</tr>
<tr>
<td>
<code>storageNamespace</code><br>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>StorageNamespace used for the Helm storage.
Defaults to the namespace of the HelmRelease.</p>
</td>
</tr>
<tr>
<td>
<code>dependsOn</code><br>
<em>
<a href="https://godoc.org/github.com/fluxcd/pkg/runtime/dependency#CrossNamespaceDependencyReference">
@ -686,6 +699,19 @@ Defaults to the namespace of the HelmRelease.</p>
</tr>
<tr>
<td>
<code>storageNamespace</code><br>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>StorageNamespace used for the Helm storage.
Defaults to the namespace of the HelmRelease.</p>
</td>
</tr>
<tr>
<td>
<code>dependsOn</code><br>
<em>
<a href="https://godoc.org/github.com/fluxcd/pkg/runtime/dependency#CrossNamespaceDependencyReference">