Support charts from GitRepository sources

This commit is contained in:
Hidde Beydals 2020-08-31 15:22:34 +02:00
parent 3413c76f36
commit a7e6727d8e
37 changed files with 521 additions and 275 deletions

View File

@ -61,6 +61,7 @@ jobs:
run: |
kubectl -n helm-system apply -f config/testdata/podinfo/
kubectl -n helm-system wait helmreleases/podinfo --for=condition=ready --timeout=4m
kubectl -n helm-system wait helmreleases/podinfo-git --for=condition=ready --timeout=4m
- name: Run dependency tests
run: |
kubectl -n helm-system apply -f config/testdata/dependencies

View File

@ -32,7 +32,8 @@ const HelmReleaseFinalizer = "finalizers.fluxcd.io"
// HelmReleaseSpec defines the desired state of HelmRelease.
type HelmReleaseSpec struct {
// Chart defines the Helm chart name, version and repository.
// Chart defines the template of the v1alpha1.HelmChart that should be created
// for this HelmRelease.
// +required
Chart HelmChartTemplate `json:"chart"`
@ -40,7 +41,7 @@ type HelmReleaseSpec struct {
// +required
Interval metav1.Duration `json:"interval"`
// Suspend tells the reconciler to suspend reconciliation for this HelmRelease,
// Suspend tells the controller to suspend reconciliation for this HelmRelease,
// it does not apply to already started reconciliations. Defaults to false.
// +optional
Suspend bool `json:"suspend,omitempty"`
@ -139,41 +140,52 @@ func (in HelmReleaseSpec) GetUninstall() Uninstall {
return *in.Uninstall
}
// HelmChartTemplate defines the template from which the controller
// will generate a HelmChart object in the same namespace as the HelmRepository.
// HelmChartTemplate defines the template from which the controller will generate a
// v1alpha1.HelmChart object in the same namespace as the referenced v1alpha1.Source.
type HelmChartTemplate struct {
// Name of the Helm chart, as made available by the referenced Helm repository.
// Spec holds the template for the v1alpha1.HelmChartSpec for this HelmRelease.
// +required
Name string `json:"name"`
Spec HelmChartTemplateSpec `json:"spec"`
}
// Version semver expression, defaults to latest when omitted.
// HelmChartTemplateSpec defines the template from which the controller will generate
// a v1alpha1.HelmChartSpec object.
type HelmChartTemplateSpec struct {
// The name or path the Helm chart is available at in the SourceRef.
// +required
Chart string `json:"chart"`
// Version semver expression, ignored for charts from GitRepository sources.
// Defaults to latest when omitted.
// +optional
Version string `json:"version,omitempty"`
// The name and namespace of the source HelmRepository the chart is available at.
// The name and namespace of the v1alpha1.Source the chart is available at.
// +required
SourceRef CrossNamespaceObjectReference `json:"sourceRef"`
// Interval at which to check the Helm repository for chart updates.
// Interval at which to check the v1alpha1.Source for updates.
// Defaults to 'HelmReleaseSpec.Interval'.
// +optional
Interval *metav1.Duration `json:"interval,omitempty"`
}
// GetInterval returns the configured interval for the HelmChart, or the given default.
// GetInterval returns the configured interval for the v1alpha1.HelmChart,
// or the given default.
func (in HelmChartTemplate) GetInterval(defaultInterval metav1.Duration) metav1.Duration {
if in.Interval == nil {
if in.Spec.Interval == nil {
return defaultInterval
}
return *in.Interval
return *in.Spec.Interval
}
// GetNamespace returns the namespace targeted namespace for the HelmChart, or the given default.
// GetNamespace returns the namespace targeted namespace for the v1alpha1.HelmChart,
// or the given default.
func (in HelmChartTemplate) GetNamespace(defaultNamespace string) string {
if in.SourceRef.Namespace == "" {
if in.Spec.SourceRef.Namespace == "" {
return defaultNamespace
}
return in.SourceRef.Namespace
return in.Spec.SourceRef.Namespace
}
// DeploymentAction defines a consistent interface for Install and Upgrade.
@ -765,7 +777,7 @@ func (in HelmRelease) GetMaxHistory() int {
// +kubebuilder:object:root=true
// HelmReleaseList contains a list of HelmRelease
// HelmReleaseList contains a list of HelmRelease objects.
type HelmReleaseList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`

View File

@ -24,7 +24,7 @@ type CrossNamespaceObjectReference struct {
APIVersion string `json:"apiVersion,omitempty"`
// Kind of the referent.
// +kubebuilder:validation:Enum=HelmRepository
// +kubebuilder:validation:Enum=HelmRepository;GitRepository
// +required
Kind string `json:"kind,omitempty"`

View File

@ -60,12 +60,7 @@ func (in *CrossNamespaceObjectReference) DeepCopy() *CrossNamespaceObjectReferen
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HelmChartTemplate) DeepCopyInto(out *HelmChartTemplate) {
*out = *in
out.SourceRef = in.SourceRef
if in.Interval != nil {
in, out := &in.Interval, &out.Interval
*out = new(v1.Duration)
**out = **in
}
in.Spec.DeepCopyInto(&out.Spec)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmChartTemplate.
@ -78,6 +73,27 @@ func (in *HelmChartTemplate) DeepCopy() *HelmChartTemplate {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HelmChartTemplateSpec) DeepCopyInto(out *HelmChartTemplateSpec) {
*out = *in
out.SourceRef = in.SourceRef
if in.Interval != nil {
in, out := &in.Interval, &out.Interval
*out = new(v1.Duration)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmChartTemplateSpec.
func (in *HelmChartTemplateSpec) DeepCopy() *HelmChartTemplateSpec {
if in == nil {
return nil
}
out := new(HelmChartTemplateSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HelmRelease) DeepCopyInto(out *HelmRelease) {
*out = *in

View File

@ -49,44 +49,53 @@ spec:
description: HelmReleaseSpec defines the desired state of HelmRelease.
properties:
chart:
description: Chart defines the Helm chart name, version and repository.
description: Chart defines the template of the v1alpha1.HelmChart
that should be created for this HelmRelease.
properties:
interval:
description: Interval at which to check the Helm repository for
chart updates. Defaults to 'HelmReleaseSpec.Interval'.
type: string
name:
description: Name of the Helm chart, as made available by the
referenced Helm repository.
type: string
sourceRef:
description: The name and namespace of the source HelmRepository
the chart is available at.
spec:
description: Spec holds the template for the v1alpha1.HelmChartSpec
for this HelmRelease.
properties:
apiVersion:
description: APIVersion of the referent.
chart:
description: The name or path the Helm chart is available
at in the SourceRef.
type: string
kind:
description: Kind of the referent.
enum:
- HelmRepository
interval:
description: Interval at which to check the v1alpha1.Source
for updates. Defaults to 'HelmReleaseSpec.Interval'.
type: string
name:
description: Name of the referent.
type: string
namespace:
description: Namespace of the referent.
sourceRef:
description: The name and namespace of the v1alpha1.Source
the chart is available at.
properties:
apiVersion:
description: APIVersion of the referent.
type: string
kind:
description: Kind of the referent.
enum:
- HelmRepository
- GitRepository
type: string
name:
description: Name of the referent.
type: string
namespace:
description: Namespace of the referent.
type: string
required:
- name
type: object
version:
description: Version semver expression, ignored for charts
from GitRepository sources. Defaults to latest when omitted.
type: string
required:
- name
- chart
- sourceRef
type: object
version:
description: Version semver expression, defaults to latest when
omitted.
type: string
required:
- name
- sourceRef
- spec
type: object
dependsOn:
description: DependsOn may contain a list of HelmReleases that must
@ -191,7 +200,7 @@ spec:
type: string
type: object
suspend:
description: Suspend tells the reconciler to suspend reconciliation
description: Suspend tells the controller to suspend reconciliation
for this HelmRelease, it does not apply to already started reconciliations.
Defaults to false.
type: boolean

View File

@ -5,6 +5,6 @@ resources:
- ../crd
- ../rbac
- ../manager
- github.com/fluxcd/source-controller/config//crd?ref=v0.0.9
- github.com/fluxcd/source-controller/config//manager?ref=v0.0.9
- github.com/fluxcd/source-controller/config//crd?ref=v0.0.13
- github.com/fluxcd/source-controller/config//manager?ref=v0.0.13
- namespace.yaml

View File

@ -1,17 +0,0 @@
apiVersion: helm.toolkit.fluxcd.io/v2alpha1
kind: HelmRelease
metadata:
name: podinfo
spec:
interval: 5m
chart:
name: podinfo
version: '^4.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
test:
enable: true
rollback:
enable: true

View File

@ -0,0 +1,18 @@
apiVersion: helm.toolkit.fluxcd.io/v2alpha1
kind: HelmRelease
metadata:
name: podinfo-gitrepository
spec:
interval: 5m
chart:
spec:
chart: ./charts/podinfo
sourceRef:
kind: GitRepository
name: podinfo
interval: 1m
upgrade:
remediation:
remediateLastFailure: true
test:
enable: true

View File

@ -0,0 +1,19 @@
apiVersion: helm.toolkit.fluxcd.io/v2alpha1
kind: HelmRelease
metadata:
name: podinfo-helmrepository
spec:
interval: 5m
chart:
spec:
chart: podinfo
version: '>=4.0.0 <5.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
upgrade:
remediation:
remediateLastFailure: true
test:
enable: true

View File

@ -0,0 +1,9 @@
apiVersion: source.toolkit.fluxcd.io/v1alpha1
kind: GitRepository
metadata:
name: podinfo
spec:
interval: 1m
url: https://github.com/stefanprodan/podinfo
ref:
branch: master

View File

@ -5,12 +5,13 @@ metadata:
spec:
interval: 5m
chart:
name: podinfo
version: '^4.0.0'
sourceRef:
kind: HelmRepository
name: webapp
interval: 1m
spec:
chart: podinfo
version: '>=4.0.0 <5.0.0'
sourceRef:
kind: HelmRepository
name: webapp
interval: 1m
values:
service:
grpcService: backend

View File

@ -5,12 +5,13 @@ metadata:
spec:
interval: 5m
chart:
name: podinfo
version: '^4.0.0'
sourceRef:
kind: HelmRepository
name: webapp
interval: 1m
spec:
chart: podinfo
version: '>=4.0.0 <5.0.0'
sourceRef:
kind: HelmRepository
name: webapp
interval: 1m
dependsOn:
- backend
values:

View File

@ -5,12 +5,13 @@ metadata:
spec:
interval: 5m
chart:
name: podinfo
version: '^4.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
spec:
chart: podinfo
version: '>=4.0.0 <5.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
install:
remediation:
remediateLastFailure: true

View File

@ -5,12 +5,13 @@ metadata:
spec:
interval: 5m
chart:
name: podinfo
version: '^4.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
spec:
chart: podinfo
version: '>=4.0.0 <5.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
install:
remediation:
retries: 1

View File

@ -5,12 +5,13 @@ metadata:
spec:
interval: 5m
chart:
name: podinfo
version: '^4.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
spec:
chart: podinfo
version: '>=4.0.0 <5.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
values:
resources:
requests:

View File

@ -5,12 +5,13 @@ metadata:
spec:
interval: 5m
chart:
name: podinfo
version: '^4.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
spec:
chart: podinfo
version: '>=4.0.0 <5.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
test:
enable: true
ignoreFailures: true

View File

@ -5,12 +5,13 @@ metadata:
spec:
interval: 5m
chart:
name: podinfo
version: '^4.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
spec:
chart: podinfo
version: '>=4.0.0 <5.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
test:
enable: true
values:

View File

@ -0,0 +1,9 @@
apiVersion: source.toolkit.fluxcd.io/v1alpha1
kind: GitRepository
metadata:
name: podinfo
spec:
interval: 1m
url: https://github.com/stefanprodan/podinfo
ref:
branch: master

View File

@ -0,0 +1,18 @@
apiVersion: helm.toolkit.fluxcd.io/v2alpha1
kind: HelmRelease
metadata:
name: podinfo-git
spec:
interval: 5m
chart:
spec:
chart: ./charts/podinfo
sourceRef:
kind: GitRepository
name: podinfo
interval: 1m
values:
resources:
requests:
cpu: 100m
memory: 64Mi

View File

@ -5,12 +5,13 @@ metadata:
spec:
interval: 5m
chart:
name: podinfo
version: '^4.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
spec:
chart: podinfo
version: '>=4.0.0 <5.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
values:
resources:
requests:

View File

@ -5,12 +5,13 @@ metadata:
spec:
interval: 5m
chart:
name: podinfo
version: '^4.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
spec:
chart: podinfo
version: '>=4.0.0 <5.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
values:
resources:
requests:

View File

@ -5,12 +5,13 @@ metadata:
spec:
interval: 5m
chart:
name: podinfo
version: '^4.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
spec:
chart: podinfo
version: '>=4.0.0 <5.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
upgrade:
remediation:
remediateLastFailure: true

View File

@ -5,12 +5,13 @@ metadata:
spec:
interval: 5m
chart:
name: podinfo
version: '^4.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
spec:
chart: podinfo
version: '>=4.0.0 <5.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
values:
resources:
requests:

View File

@ -5,12 +5,13 @@ metadata:
spec:
interval: 5m
chart:
name: podinfo
version: '^4.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
spec:
chart: podinfo
version: '>=4.0.0 <5.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
upgrade:
remediation:
remediateLastFailure: true

View File

@ -5,12 +5,13 @@ metadata:
spec:
interval: 5m
chart:
name: podinfo
version: '^4.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
spec:
chart: podinfo
version: '>=4.0.0 <5.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
values:
resources:
requests:

View File

@ -5,12 +5,13 @@ metadata:
spec:
interval: 5m
chart:
name: podinfo
version: '^4.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
spec:
chart: podinfo
version: '>=4.0.0 <5.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
upgrade:
remediation:
retries: 1

View File

@ -5,12 +5,13 @@ metadata:
spec:
interval: 5m
chart:
name: podinfo
version: '^4.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
spec:
chart: podinfo
version: '>=4.0.0 <5.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
values:
resources:
requests:

View File

@ -5,12 +5,13 @@ metadata:
spec:
interval: 5m
chart:
name: podinfo
version: '^4.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
spec:
chart: podinfo
version: '>=4.0.0 <5.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
values:
resources:
requests:

View File

@ -5,12 +5,13 @@ metadata:
spec:
interval: 5m
chart:
name: podinfo
version: '^4.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
spec:
chart: podinfo
version: '>=4.0.0 <5.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
values:
resources:
requests:

View File

@ -5,12 +5,13 @@ metadata:
spec:
interval: 5m
chart:
name: podinfo
version: '^4.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
spec:
chart: podinfo
version: '>=4.0.0 <5.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
test:
enable: true
values:

View File

@ -5,12 +5,13 @@ metadata:
spec:
interval: 5m
chart:
name: podinfo
version: '^4.0.0'
sourceRef:
kind: HelmRepository
name: valuesfrom
interval: 1m
spec:
chart: podinfo
version: '>=4.0.0 <5.0.0'
sourceRef:
kind: HelmRepository
name: valuesfrom
interval: 1m
valuesFrom:
- kind: ConfigMap
name: valuesfrom-config

View File

@ -598,10 +598,11 @@ func helmChartFromTemplate(hr v2.HelmRelease) *sourcev1.HelmChart {
Namespace: hr.Spec.Chart.GetNamespace(hr.Namespace),
},
Spec: sourcev1.HelmChartSpec{
Name: template.Name,
Version: template.Version,
HelmRepositoryRef: corev1.LocalObjectReference{
Name: template.SourceRef.Name,
Chart: template.Spec.Chart,
Version: template.Spec.Version,
SourceRef: sourcev1.LocalHelmChartSourceReference{
Name: template.Spec.SourceRef.Name,
Kind: template.Spec.SourceRef.Kind,
},
Interval: template.GetInterval(hr.Spec.Interval),
},
@ -611,11 +612,13 @@ func helmChartFromTemplate(hr v2.HelmRelease) *sourcev1.HelmChart {
func helmChartRequiresUpdate(hr v2.HelmRelease, chart sourcev1.HelmChart) bool {
template := hr.Spec.Chart
switch {
case template.Name != chart.Spec.Name:
case template.Spec.Chart != chart.Spec.Chart:
return true
case template.Version != chart.Spec.Version:
case template.Spec.Version != chart.Spec.Version:
return true
case template.SourceRef.Name != chart.Spec.HelmRepositoryRef.Name:
case template.Spec.SourceRef.Name != chart.Spec.SourceRef.Name:
return true
case template.Spec.SourceRef.Kind != chart.Spec.SourceRef.Kind:
return true
case template.GetInterval(hr.Spec.Interval) != chart.Spec.Interval:
return true

View File

@ -78,7 +78,8 @@ HelmChartTemplate
</em>
</td>
<td>
<p>Chart defines the Helm chart name, version and repository.</p>
<p>Chart defines the template of the v1alpha1.HelmChart that should be created
for this HelmRelease.</p>
</td>
</tr>
<tr>
@ -103,7 +104,7 @@ bool
</td>
<td>
<em>(Optional)</em>
<p>Suspend tells the reconciler to suspend reconciliation for this HelmRelease,
<p>Suspend tells the controller to suspend reconciliation for this HelmRelease,
it does not apply to already started reconciliations. Defaults to false.</p>
</td>
</tr>
@ -381,7 +382,7 @@ transition, complementing reason.</p>
</h3>
<p>
(<em>Appears on:</em>
<a href="#helm.toolkit.fluxcd.io/v2alpha1.HelmChartTemplate">HelmChartTemplate</a>)
<a href="#helm.toolkit.fluxcd.io/v2alpha1.HelmChartTemplateSpec">HelmChartTemplateSpec</a>)
</p>
<p>CrossNamespaceObjectReference contains enough information to let you locate the
typed referenced object at cluster level.</p>
@ -454,8 +455,8 @@ string
(<em>Appears on:</em>
<a href="#helm.toolkit.fluxcd.io/v2alpha1.HelmReleaseSpec">HelmReleaseSpec</a>)
</p>
<p>HelmChartTemplate defines the template from which the controller
will generate a HelmChart object in the same namespace as the HelmRepository.</p>
<p>HelmChartTemplate defines the template from which the controller will generate a
v1alpha1.HelmChart object in the same namespace as the referenced v1alpha1.Source.</p>
<div class="md-typeset__scrollwrap">
<div class="md-typeset__table">
<table>
@ -468,13 +469,27 @@ will generate a HelmChart object in the same namespace as the HelmRepository.</p
<tbody>
<tr>
<td>
<code>name</code><br>
<code>spec</code><br>
<em>
<a href="#helm.toolkit.fluxcd.io/v2alpha1.HelmChartTemplateSpec">
HelmChartTemplateSpec
</a>
</em>
</td>
<td>
<p>Spec holds the template for the v1alpha1.HelmChartSpec for this HelmRelease.</p>
<br/>
<br/>
<table>
<tr>
<td>
<code>chart</code><br>
<em>
string
</em>
</td>
<td>
<p>Name of the Helm chart, as made available by the referenced Helm repository.</p>
<p>The name or path the Helm chart is available at in the SourceRef.</p>
</td>
</tr>
<tr>
@ -486,7 +501,8 @@ string
</td>
<td>
<em>(Optional)</em>
<p>Version semver expression, defaults to latest when omitted.</p>
<p>Version semver expression, ignored for charts from GitRepository sources.
Defaults to latest when omitted.</p>
</td>
</tr>
<tr>
@ -499,7 +515,7 @@ CrossNamespaceObjectReference
</em>
</td>
<td>
<p>The name and namespace of the source HelmRepository the chart is available at.</p>
<p>The name and namespace of the v1alpha1.Source the chart is available at.</p>
</td>
</tr>
<tr>
@ -513,7 +529,84 @@ Kubernetes meta/v1.Duration
</td>
<td>
<em>(Optional)</em>
<p>Interval at which to check the Helm repository for chart updates.
<p>Interval at which to check the v1alpha1.Source for updates.
Defaults to &lsquo;HelmReleaseSpec.Interval&rsquo;.</p>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h3 id="helm.toolkit.fluxcd.io/v2alpha1.HelmChartTemplateSpec">HelmChartTemplateSpec
</h3>
<p>
(<em>Appears on:</em>
<a href="#helm.toolkit.fluxcd.io/v2alpha1.HelmChartTemplate">HelmChartTemplate</a>)
</p>
<p>HelmChartTemplateSpec defines the template from which the controller will generate
a v1alpha1.HelmChartSpec object.</p>
<div class="md-typeset__scrollwrap">
<div class="md-typeset__table">
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>chart</code><br>
<em>
string
</em>
</td>
<td>
<p>The name or path the Helm chart is available at in the SourceRef.</p>
</td>
</tr>
<tr>
<td>
<code>version</code><br>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>Version semver expression, ignored for charts from GitRepository sources.
Defaults to latest when omitted.</p>
</td>
</tr>
<tr>
<td>
<code>sourceRef</code><br>
<em>
<a href="#helm.toolkit.fluxcd.io/v2alpha1.CrossNamespaceObjectReference">
CrossNamespaceObjectReference
</a>
</em>
</td>
<td>
<p>The name and namespace of the v1alpha1.Source the chart is available at.</p>
</td>
</tr>
<tr>
<td>
<code>interval</code><br>
<em>
<a href="https://godoc.org/k8s.io/apimachinery/pkg/apis/meta/v1#Duration">
Kubernetes meta/v1.Duration
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>Interval at which to check the v1alpha1.Source for updates.
Defaults to &lsquo;HelmReleaseSpec.Interval&rsquo;.</p>
</td>
</tr>
@ -548,7 +641,8 @@ HelmChartTemplate
</em>
</td>
<td>
<p>Chart defines the Helm chart name, version and repository.</p>
<p>Chart defines the template of the v1alpha1.HelmChart that should be created
for this HelmRelease.</p>
</td>
</tr>
<tr>
@ -573,7 +667,7 @@ bool
</td>
<td>
<em>(Optional)</em>
<p>Suspend tells the reconciler to suspend reconciliation for this HelmRelease,
<p>Suspend tells the controller to suspend reconciliation for this HelmRelease,
it does not apply to already started reconciliations. Defaults to false.</p>
</td>
</tr>

View File

@ -12,7 +12,8 @@ automated Helm actions that are being performed.
```go
// HelmReleaseSpec defines the desired state of HelmRelease.
type HelmReleaseSpec struct {
// Chart defines the Helm chart name, version and repository.
// Chart defines the template of the v1alpha1.HelmChart that should be created
// for this HelmRelease.
// +required
Chart HelmChartTemplate `json:"chart"`
@ -20,7 +21,7 @@ type HelmReleaseSpec struct {
// +required
Interval metav1.Duration `json:"interval"`
// Suspend tells the reconciler to suspend reconciliation for this HelmRelease,
// Suspend tells the controller to suspend reconciliation for this HelmRelease,
// it does not apply to already started reconciliations. Defaults to false.
// +optional
Suspend bool `json:"suspend,omitempty"`
@ -79,22 +80,31 @@ type HelmReleaseSpec struct {
Values *apiextensionsv1.JSON `json:"values,omitempty"`
}
// HelmChartTemplate defines the template from which the controller
// will generate a HelmChart object in the same namespace as the HelmRepository.
// HelmChartTemplate defines the template from which the controller will generate a
// v1alpha1.HelmChart object in the same namespace as the referenced v1alpha1.Source.
type HelmChartTemplate struct {
// Name of the Helm chart, as made available by the referenced Helm repository.
// Spec holds the template for the v1alpha1.HelmChartSpec for this HelmRelease.
// +required
Name string `json:"name"`
Spec HelmChartTemplateSpec `json:"spec"`
}
// Version semver expression, defaults to latest when omitted.
// HelmChartTemplateSpec defines the template from which the controller will generate
// a v1alpha1.HelmChartSpec object.
type HelmChartTemplateSpec struct {
// The name or path the Helm chart is available at in the SourceRef.
// +required
Chart string `json:"chart"`
// Version semver expression, ignored for charts from GitRepository sources.
// Defaults to latest when omitted.
// +optional
Version string `json:"version,omitempty"`
// The name and namespace of the source HelmRepository the chart is available at.
// The name and namespace of the v1alpha1.Source the chart is available at.
// +required
SourceRef CrossNamespaceObjectReference `json:"sourceRef"`
// Interval at which to check the Helm repository for chart updates.
// Interval at which to check the v1alpha1.Source for updates.
// Defaults to 'HelmReleaseSpec.Interval'.
// +optional
Interval *metav1.Duration `json:"interval,omitempty"`
@ -494,16 +504,18 @@ metadata:
spec:
interval: 5m
chart:
name: podinfo
version: '^4.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
spec:
chart: podinfo
version: '>=4.0.0 <5.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
upgrade:
remediation:
remediateLastFailure: true
test:
enable: true
rollback:
enable: true
values:
service:
grpcService: backend
@ -519,18 +531,20 @@ metadata:
spec:
interval: 5m
chart:
name: podinfo
version: '^4.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
spec:
chart: podinfo
version: '>=4.0.0 <5.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
dependsOn:
- backend
upgrade:
remediation:
remediateLastFailure: true
test:
enable: true
rollback:
enable: true
values:
backend: http://backend-podinfo:9898/echo
resources:
@ -544,7 +558,7 @@ spec:
## Enabling Helm rollback actions
From time to time an Helm upgrade made by the helm-controller may fail, automatically recovering
From time to time a Helm upgrade made by the helm-controller may fail, automatically recovering
from this via a Helm rollback action is possible by enabling rollbacks for the `HelmRelease`.
```yaml
@ -555,14 +569,16 @@ metadata:
spec:
interval: 5m
chart:
name: podinfo
version: '^4.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
rollback:
enable: true
spec:
chart: podinfo
version: '>=4.0.0 <5.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
upgrade:
remediation:
remediateLastFailure: true
values:
resources:
requests:
@ -589,32 +605,33 @@ One can also opt-in to remediation of the last failure (when no retries remain)
2. For upgrades, setting `spec.upgrade.remediation.remediateLastFailure` to `true`, or configuring
at least one retry.
```yaml
apiVersion: helm.fluxcd.io/v2alpha1
kind: HelmRelease
metadata:
name: podinfo
spec:
interval: 5m
chart:
name: podinfo
version: '^4.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
install:
remediation:
retries: 3
upgrade:
remediation:
remediateLastFailure: false
values:
resources:
requests:
cpu: 100m
memory: 64Mi
```
```yaml
apiVersion: helm.fluxcd.io/v2alpha1
kind: HelmRelease
metadata:
name: podinfo
spec:
interval: 5m
chart:
spec:
chart: podinfo
version: '>=4.0.0 <5.0.0'
sourceRef:
kind: HelmRepository
name: podinfo
interval: 1m
install:
remediation:
retries: 3
upgrade:
remediation:
remediateLastFailure: false
values:
resources:
requests:
cpu: 100m
memory: 64Mi
```
## Configuring Helm test actions
@ -636,8 +653,9 @@ metadata:
spec:
interval: 5m
chart:
name: podinfo
version: '^4.0.0'
spec:
chart: podinfo
version: '>=4.0.0 <5.0.0'
sourceRef:
kind: HelmRepository
name: podinfo

10
go.mod
View File

@ -8,16 +8,16 @@ require (
github.com/fluxcd/helm-controller/api v0.0.5
github.com/fluxcd/pkg/lockedfile v0.0.5
github.com/fluxcd/pkg/recorder v0.0.5
github.com/fluxcd/source-controller/api v0.0.9
github.com/fluxcd/source-controller/api v0.0.13
github.com/go-logr/logr v0.1.0
github.com/onsi/ginkgo v1.12.1
github.com/onsi/gomega v1.10.1
go.uber.org/zap v1.13.0
helm.sh/helm/v3 v3.3.0
k8s.io/api v0.18.4
k8s.io/apimachinery v0.18.4
k8s.io/api v0.18.8
k8s.io/apimachinery v0.18.8
k8s.io/cli-runtime v0.18.4
k8s.io/client-go v0.18.4
k8s.io/client-go v0.18.6
rsc.io/letsencrypt v0.0.3 // indirect
sigs.k8s.io/controller-runtime v0.6.1
sigs.k8s.io/controller-runtime v0.6.2
)

22
go.sum
View File

@ -182,6 +182,7 @@ github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT
github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/evanphx/json-patch v0.0.0-20200808040245-162e5629780b/go.mod h1:NAJj0yf/KaRKURN6nyi7A9IZydMivZEm9oQLWNjfKDc=
github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/evanphx/json-patch v4.5.0+incompatible h1:ouOWdg56aJriqS0huScTkVXPC5IcNrDCXZ6OoTAWu7M=
github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
@ -194,8 +195,8 @@ github.com/fluxcd/pkg/lockedfile v0.0.5 h1:C3T8wfdff1UY1bvplmCkGOLrdMWJHO8Q8+tdl
github.com/fluxcd/pkg/lockedfile v0.0.5/go.mod h1:uAtPUBId6a2RqO84MTH5HKGX0SbM1kNW3Wr/FhYyDVA=
github.com/fluxcd/pkg/recorder v0.0.5 h1:D8qfupahIvh6ncCMn2yTHsrzG91S05sp4zdpsbKWeaU=
github.com/fluxcd/pkg/recorder v0.0.5/go.mod h1:2UG6EroZ6ZbqmqoL8k/cQMe09e6A36WyH4t4UDUGyuU=
github.com/fluxcd/source-controller/api v0.0.9 h1:LDaC6JMWmxRMOhb+Q60OQZU2iiwvw2rNPHqxxfebKyI=
github.com/fluxcd/source-controller/api v0.0.9/go.mod h1:Q0bjU4/O1C4FoQT/O2YgGtJnoRWtrw4R/MowywCaDNg=
github.com/fluxcd/source-controller/api v0.0.13 h1:rf0uZ20OAN+yJVs0uHJUhw3n3ci9ZyjaLqt5Jt/5K9A=
github.com/fluxcd/source-controller/api v0.0.13/go.mod h1:PUe+EYQ/s+KPnz2iOCgdf+L6clM0SWkyvdXIpbfpkQE=
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
@ -397,6 +398,7 @@ github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJ
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jmespath/go-jmespath v0.0.0-20160803190731-bd40a432e4c7/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
@ -927,18 +929,32 @@ honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXe
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
k8s.io/api v0.18.4 h1:8x49nBRxuXGUlDlwlWd3RMY1SayZrzFfxea3UZSkFw4=
k8s.io/api v0.18.4/go.mod h1:lOIQAKYgai1+vz9J7YcDZwC26Z0zQewYOGWdyIPUUQ4=
k8s.io/api v0.18.6/go.mod h1:eeyxr+cwCjMdLAmr2W3RyDI0VvTawSg/3RFFBEnmZGI=
k8s.io/api v0.18.8 h1:aIKUzJPb96f3fKec2lxtY7acZC9gQNDLVhfSGpxBAC4=
k8s.io/api v0.18.8/go.mod h1:d/CXqwWv+Z2XEG1LgceeDmHQwpUJhROPx16SlxJgERY=
k8s.io/apiextensions-apiserver v0.18.4 h1:Y3HGERmS8t9u12YNUFoOISqefaoGRuTc43AYCLzWmWE=
k8s.io/apiextensions-apiserver v0.18.4/go.mod h1:NYeyeYq4SIpFlPxSAB6jHPIdvu3hL0pc36wuRChybio=
k8s.io/apiextensions-apiserver v0.18.6 h1:vDlk7cyFsDyfwn2rNAO2DbmUbvXy5yT5GE3rrqOzaMo=
k8s.io/apiextensions-apiserver v0.18.6/go.mod h1:lv89S7fUysXjLZO7ke783xOwVTm6lKizADfvUM/SS/M=
k8s.io/apimachinery v0.18.4 h1:ST2beySjhqwJoIFk6p7Hp5v5O0hYY6Gngq/gUYXTPIA=
k8s.io/apimachinery v0.18.4/go.mod h1:OaXp26zu/5J7p0f92ASynJa1pZo06YlV9fG7BoWbCko=
k8s.io/apimachinery v0.18.6/go.mod h1:OaXp26zu/5J7p0f92ASynJa1pZo06YlV9fG7BoWbCko=
k8s.io/apimachinery v0.18.8 h1:jimPrycCqgx2QPearX3to1JePz7wSbVLq+7PdBTTwQ0=
k8s.io/apimachinery v0.18.8/go.mod h1:6sQd+iHEqmOtALqOFjSWp2KZ9F0wlU/nWm0ZgsYWMig=
k8s.io/apiserver v0.18.4/go.mod h1:q+zoFct5ABNnYkGIaGQ3bcbUNdmPyOCoEBcg51LChY8=
k8s.io/apiserver v0.18.6/go.mod h1:Zt2XvTHuaZjBz6EFYzpp+X4hTmgWGy8AthNVnTdm3Wg=
k8s.io/cli-runtime v0.18.4 h1:IUx7quIOb4gbQ4M+B1ksF/PTBovQuL5tXWzplX3t+FM=
k8s.io/cli-runtime v0.18.4/go.mod h1:9/hS/Cuf7NVzWR5F/5tyS6xsnclxoPLVtwhnkJG1Y4g=
k8s.io/client-go v0.18.4 h1:un55V1Q/B3JO3A76eS0kUSywgGK/WR3BQ8fHQjNa6Zc=
k8s.io/client-go v0.18.4/go.mod h1:f5sXwL4yAZRkAtzOxRWUhA/N8XzGCb+nPZI8PfobZ9g=
k8s.io/client-go v0.18.6 h1:I+oWqJbibLSGsZj8Xs8F0aWVXJVIoUHWaaJV3kUN/Zw=
k8s.io/client-go v0.18.6/go.mod h1:/fwtGLjYMS1MaM5oi+eXhKwG+1UHidUEXRh6cNsdO0Q=
k8s.io/code-generator v0.18.4/go.mod h1:TgNEVx9hCyPGpdtCWA34olQYLkh3ok9ar7XfSsr8b6c=
k8s.io/code-generator v0.18.6/go.mod h1:TgNEVx9hCyPGpdtCWA34olQYLkh3ok9ar7XfSsr8b6c=
k8s.io/component-base v0.18.4 h1:Kr53Fp1iCGNsl9Uv4VcRvLy7YyIqi9oaJOQ7SXtKI98=
k8s.io/component-base v0.18.4/go.mod h1:7jr/Ef5PGmKwQhyAz/pjByxJbC58mhKAhiaDu0vXfPk=
k8s.io/component-base v0.18.6 h1:Wd6cHGwJN2qpufnirVOB3oMhyhbioGsKEi5HeDBsV+s=
k8s.io/component-base v0.18.6/go.mod h1:knSVsibPR5K6EW2XOjEHik6sdU5nCvKMrzMt2D4In14=
k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
k8s.io/gengo v0.0.0-20200114144118-36b2048a9120/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
@ -961,6 +977,8 @@ rsc.io/letsencrypt v0.0.3/go.mod h1:buyQKZ6IXrRnB7TdkHP0RyEybLx18HHyOSoTyoOLqNY=
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.7/go.mod h1:PHgbrJT7lCHcxMU+mDHEm+nx46H4zuuHZkDP6icnhu0=
sigs.k8s.io/controller-runtime v0.6.1 h1:LcK2+nk0kmaOnKGN+vBcWHqY5WDJNJNB/c5pW+sU8fc=
sigs.k8s.io/controller-runtime v0.6.1/go.mod h1:XRYBPdbf5XJu9kpS84VJiZ7h/u1hF3gEORz0efEja7A=
sigs.k8s.io/controller-runtime v0.6.2 h1:jkAnfdTYBpFwlmBn3pS5HFO06SfxvnTZ1p5PeEF/zAA=
sigs.k8s.io/controller-runtime v0.6.2/go.mod h1:vhcq/rlnENJ09SIRp3EveTaZ0yqH526hjf9iJdbUJ/E=
sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0=
sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU=
sigs.k8s.io/structured-merge-diff/v3 v3.0.0-20200116222232-67a7b8c61874/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw=