api: add `PersistentClient` flag to allow control

This adds a `PersistentClient` flag which should be consumed by the
controller while initializing the Kubernetes client used by Helm
actions.

This to allow the controller to work with certain charts which do
require a client which does not persist, as they create Custom Resource
Definitions on demand during e.g. install, which then later aren't
observed by Helm as it does not reset the REST mapper between successive
action steps.

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
This commit is contained in:
Hidde Beydals 2023-03-30 12:01:11 +02:00
parent 6f0fd5f97e
commit 3f65b45e4a
No known key found for this signature in database
GPG Key ID: 979F380FC2341744
5 changed files with 95 additions and 0 deletions

View File

@ -137,6 +137,21 @@ type HelmReleaseSpec struct {
// +optional
ServiceAccountName string `json:"serviceAccountName,omitempty"`
// PersistentClient tells the controller to use a persistent Kubernetes
// client for this release. When enabled, the client will be reused for the
// duration of the reconciliation, instead of being created and destroyed
// for each (step of a) Helm action.
//
// This can improve performance, but may cause issues with some Helm charts
// that for example do create Custom Resource Definitions during installation
// outside Helm's CRD lifecycle hooks, which are then not observed to be
// available by e.g. post-install hooks.
//
// If not set, it defaults to true.
//
// +optional
PersistentClient *bool `json:"persistentClient,omitempty"`
// Install holds the configuration for Helm install actions for this HelmRelease.
// +optional
Install *Install `json:"install,omitempty"`
@ -1039,6 +1054,15 @@ func (in HelmRelease) GetMaxHistory() int {
return *in.Spec.MaxHistory
}
// UsePersistentClient returns the configured PersistentClient, or the default
// of true.
func (in HelmRelease) UsePersistentClient() bool {
if in.Spec.PersistentClient == nil {
return true
}
return *in.Spec.PersistentClient
}
// GetDependsOn returns the list of dependencies across-namespaces.
func (in HelmRelease) GetDependsOn() []meta.NamespacedObjectReference {
return in.Spec.DependsOn

View File

@ -225,6 +225,11 @@ func (in *HelmReleaseSpec) DeepCopyInto(out *HelmReleaseSpec) {
*out = new(int)
**out = **in
}
if in.PersistentClient != nil {
in, out := &in.PersistentClient, &out.PersistentClient
*out = new(bool)
**out = **in
}
if in.Install != nil {
in, out := &in.Install, &out.Install
*out = new(Install)

View File

@ -322,6 +322,17 @@ spec:
this HelmRelease. Use '0' for an unlimited number of revisions;
defaults to '10'.
type: integer
persistentClient:
description: "PersistentClient tells the controller to use a persistent
Kubernetes client for this release. When enabled, the client will
be reused for the duration of the reconciliation, instead of being
created and destroyed for each (step of a) Helm action. \n This
can improve performance, but may cause issues with some Helm charts
that for example do create Custom Resource Definitions during installation
outside Helm's CRD lifecycle hooks, which are then not observed
to be available by e.g. post-install hooks. \n If not set, it defaults
to true."
type: boolean
postRenderers:
description: PostRenderers holds an array of Helm PostRenderers, which
will be applied in order of their definition.

View File

@ -226,6 +226,26 @@ when reconciling this HelmRelease.</p>
</tr>
<tr>
<td>
<code>persistentClient</code><br>
<em>
bool
</em>
</td>
<td>
<em>(Optional)</em>
<p>PersistentClient tells the controller to use a persistent Kubernetes
client for this release. When enabled, the client will be reused for the
duration of the reconciliation, instead of being created and destroyed
for each (step of a) Helm action.</p>
<p>This can improve performance, but may cause issues with some Helm charts
that for example do create Custom Resource Definitions during installation
outside Helm&rsquo;s CRD lifecycle hooks, which are then not observed to be
available by e.g. post-install hooks.</p>
<p>If not set, it defaults to true.</p>
</td>
</tr>
<tr>
<td>
<code>install</code><br>
<em>
<a href="#helm.toolkit.fluxcd.io/v2beta1.Install">
@ -1015,6 +1035,26 @@ when reconciling this HelmRelease.</p>
</tr>
<tr>
<td>
<code>persistentClient</code><br>
<em>
bool
</em>
</td>
<td>
<em>(Optional)</em>
<p>PersistentClient tells the controller to use a persistent Kubernetes
client for this release. When enabled, the client will be reused for the
duration of the reconciliation, instead of being created and destroyed
for each (step of a) Helm action.</p>
<p>This can improve performance, but may cause issues with some Helm charts
that for example do create Custom Resource Definitions during installation
outside Helm&rsquo;s CRD lifecycle hooks, which are then not observed to be
available by e.g. post-install hooks.</p>
<p>If not set, it defaults to true.</p>
</td>
</tr>
<tr>
<td>
<code>install</code><br>
<em>
<a href="#helm.toolkit.fluxcd.io/v2beta1.Install">

View File

@ -66,6 +66,21 @@ type HelmReleaseSpec struct {
// +optional
MaxHistory *int `json:"maxHistory,omitempty"`
// PersistentClient tells the controller to use a persistent Kubernetes
// client for this release. When enabled, the client will be reused for the
// duration of the reconciliation, instead of being created and destroyed
// for each (step of a) Helm action.
//
// This can improve performance, but may cause issues with some Helm charts
// that for example do create Custom Resource Definitions during installation
// outside Helm's CRD lifecycle hooks, which are then not observed to be
// available by e.g. post-install hooks.
//
// If not set, it defaults to true.
//
// +optional
PersistentClient *bool `json:"persistentClient,omitempty"`
// Install holds the configuration for Helm install actions for this HelmRelease.
// +optional
Install *Install `json:"install,omitempty"`