From accd4762feb590325d185340ffd72f1a73306ca4 Mon Sep 17 00:00:00 2001 From: Hidde Beydals Date: Wed, 30 Sep 2020 19:27:17 +0200 Subject: [PATCH] Promote API to v2beta1 --- .github/workflows/e2e.yaml | 2 +- .github/workflows/fossa.yml | 2 +- Dockerfile | 2 +- Makefile | 2 +- PROJECT | 2 +- README.md | 2 +- api/go.mod | 2 +- api/{v2alpha1 => v2beta1}/condition_types.go | 2 +- api/{v2alpha1 => v2beta1}/doc.go | 4 +- .../groupversion_info.go | 4 +- .../helmrelease_types.go | 24 +- api/{v2alpha1 => v2beta1}/reference_types.go | 2 +- .../zz_generated.deepcopy.go | 2 +- .../helm.toolkit.fluxcd.io_helmreleases.yaml | 16 +- config/default/kustomization.yaml | 4 +- ...lm_v2beta1_helmrelease_gitrepository.yaml} | 2 +- ...m_v2beta1_helmrelease_helmrepository.yaml} | 2 +- ...yaml => source_v1beta1_gitrepository.yaml} | 2 +- ...aml => source_v1beta1_helmrepository.yaml} | 2 +- .../dependencies/helmrelease-backend.yaml | 2 +- .../dependencies/helmrelease-frontend.yaml | 2 +- .../testdata/dependencies/helmrepository.yaml | 2 +- .../install-fail-remediate/helmrelease.yaml | 2 +- .../install-fail-retry/helmrelease.yaml | 2 +- config/testdata/install-fail/helmrelease.yaml | 2 +- .../install-test-fail-ignore/helmrelease.yaml | 2 +- .../install-test-fail/helmrelease.yaml | 2 +- config/testdata/podinfo/gitrepository.yaml | 2 +- config/testdata/podinfo/helmrelease-git.yaml | 2 +- config/testdata/podinfo/helmrelease.yaml | 2 +- config/testdata/podinfo/helmrepository.yaml | 2 +- .../install.yaml | 2 +- .../upgrade.yaml | 2 +- .../upgrade-fail-remediate/install.yaml | 2 +- .../upgrade-fail-remediate/upgrade.yaml | 2 +- .../testdata/upgrade-fail-retry/install.yaml | 2 +- .../testdata/upgrade-fail-retry/upgrade.yaml | 2 +- config/testdata/upgrade-fail/install.yaml | 2 +- config/testdata/upgrade-fail/upgrade.yaml | 2 +- .../testdata/upgrade-test-fail/install.yaml | 2 +- .../testdata/upgrade-test-fail/upgrade.yaml | 2 +- config/testdata/valuesfrom/helmrelease.yaml | 2 +- .../testdata/valuesfrom/helmrepository.yaml | 2 +- controllers/helmchart_predicate.go | 2 +- controllers/helmchart_watcher.go | 4 +- controllers/helmrelease_controller.go | 14 +- controllers/suite_test.go | 4 +- docs/api/helmrelease.md | 144 +-- docs/spec/README.md | 2 +- docs/spec/v2beta1/README.md | 24 + docs/spec/v2beta1/helmreleases.md | 900 ++++++++++++++++++ go.mod | 4 +- go.sum | 8 +- internal/runner/runner.go | 16 +- main.go | 4 +- 55 files changed, 1087 insertions(+), 167 deletions(-) rename api/{v2alpha1 => v2beta1}/condition_types.go (99%) rename api/{v2alpha1 => v2beta1}/doc.go (86%) rename api/{v2alpha1 => v2beta1}/groupversion_info.go (96%) rename api/{v2alpha1 => v2beta1}/helmrelease_types.go (97%) rename api/{v2alpha1 => v2beta1}/reference_types.go (99%) rename api/{v2alpha1 => v2beta1}/zz_generated.deepcopy.go (99%) rename config/samples/{helm_v2alpha1_helmrelease_gitrepository.yaml => helm_v2beta1_helmrelease_gitrepository.yaml} (87%) rename config/samples/{helm_v2alpha1_helmrelease_helmrepository.yaml => helm_v2beta1_helmrelease_helmrepository.yaml} (88%) rename config/samples/{source_v1alpha1_gitrepository.yaml => source_v1beta1_gitrepository.yaml} (75%) rename config/samples/{source_v1alpha1_helmrepository.yaml => source_v1beta1_helmrepository.yaml} (71%) create mode 100644 docs/spec/v2beta1/README.md create mode 100644 docs/spec/v2beta1/helmreleases.md diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 56c12e71c..25aad3e41 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -22,7 +22,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v2-beta with: - go-version: 1.14.x + go-version: 1.15.x - name: Setup Kubernetes uses: engineerd/setup-kind@v0.4.0 - name: Setup Helm diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index f24fa033e..5566d2248 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: - go-version: "^1.14.x" + go-version: "^1.15.x" - run: go version # Runs a set of commands to initialize and analyze with FOSSA - name: run FOSSA analysis diff --git a/Dockerfile b/Dockerfile index fe9994b04..8c27f10df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Docker buildkit multi-arch build requires golang alpine -FROM golang:1.14-alpine as builder +FROM golang:1.15-alpine as builder WORKDIR /workspace diff --git a/Makefile b/Makefile index 03291e44c..82f91ec1e 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,7 @@ manifests: controller-gen # Generate API reference documentation api-docs: gen-crd-api-reference-docs - $(API_REF_GEN) -api-dir=./api/v2alpha1 -config=./hack/api-docs/config.json -template-dir=./hack/api-docs/template -out-file=./docs/api/helmrelease.md + $(API_REF_GEN) -api-dir=./api/v2beta1 -config=./hack/api-docs/config.json -template-dir=./hack/api-docs/template -out-file=./docs/api/helmrelease.md # Run go fmt against code fmt: diff --git a/PROJECT b/PROJECT index f15919590..4b09ffd52 100644 --- a/PROJECT +++ b/PROJECT @@ -3,5 +3,5 @@ repo: github.com/fluxcd/helm-controller resources: - group: helm kind: HelmRelease - version: v2alpha1 + version: v2beta1 version: "2" diff --git a/README.md b/README.md index e7ff6b12a..93a111c64 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ operator. ## Specifications -* [API](docs/spec/v2alpha1/README.md) +* [API](docs/spec/v2beta1/README.md) * [Controller](docs/spec/README.md) [source-controller]: https://github.com/fluxcd/source-controller diff --git a/api/go.mod b/api/go.mod index 049389949..cc8af389f 100644 --- a/api/go.mod +++ b/api/go.mod @@ -1,6 +1,6 @@ module github.com/fluxcd/helm-controller/api -go 1.14 +go 1.15 require ( github.com/fluxcd/pkg/apis/meta v0.0.2 diff --git a/api/v2alpha1/condition_types.go b/api/v2beta1/condition_types.go similarity index 99% rename from api/v2alpha1/condition_types.go rename to api/v2beta1/condition_types.go index c7182aaa2..99f5d3a8a 100644 --- a/api/v2alpha1/condition_types.go +++ b/api/v2beta1/condition_types.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha1 +package v2beta1 const ( // ReleasedCondition represents the status of the last release attempt diff --git a/api/v2alpha1/doc.go b/api/v2beta1/doc.go similarity index 86% rename from api/v2alpha1/doc.go rename to api/v2beta1/doc.go index f4a9bbdf5..40d3310fe 100644 --- a/api/v2alpha1/doc.go +++ b/api/v2beta1/doc.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package v2alpha1 contains API Schema definitions for the helm v2alpha1 API group +// Package v2beta1 contains API Schema definitions for the helm v2beta1 API group // +kubebuilder:object:generate=true // +groupName=helm.toolkit.fluxcd.io -package v2alpha1 +package v2beta1 diff --git a/api/v2alpha1/groupversion_info.go b/api/v2beta1/groupversion_info.go similarity index 96% rename from api/v2alpha1/groupversion_info.go rename to api/v2beta1/groupversion_info.go index 1607df21d..14edc598e 100644 --- a/api/v2alpha1/groupversion_info.go +++ b/api/v2beta1/groupversion_info.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha1 +package v2beta1 import ( "k8s.io/apimachinery/pkg/runtime/schema" @@ -23,7 +23,7 @@ import ( var ( // GroupVersion is group version used to register these objects - GroupVersion = schema.GroupVersion{Group: "helm.toolkit.fluxcd.io", Version: "v2alpha1"} + GroupVersion = schema.GroupVersion{Group: "helm.toolkit.fluxcd.io", Version: "v2beta1"} // SchemeBuilder is used to add go types to the GroupVersionKind scheme SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} diff --git a/api/v2alpha1/helmrelease_types.go b/api/v2beta1/helmrelease_types.go similarity index 97% rename from api/v2alpha1/helmrelease_types.go rename to api/v2beta1/helmrelease_types.go index a657b4eb7..b4f3863f4 100644 --- a/api/v2alpha1/helmrelease_types.go +++ b/api/v2beta1/helmrelease_types.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha1 +package v2beta1 import ( "encoding/json" @@ -35,7 +35,7 @@ const HelmReleaseFinalizer = "finalizers.fluxcd.io" // HelmReleaseSpec defines the desired state of a Helm release. type HelmReleaseSpec struct { - // Chart defines the template of the v1alpha1.HelmChart that should be created + // Chart defines the template of the v1beta1.HelmChart that should be created // for this HelmRelease. // +required Chart HelmChartTemplate `json:"chart"` @@ -155,31 +155,31 @@ func (in HelmReleaseSpec) GetUninstall() Uninstall { } // HelmChartTemplate defines the template from which the controller will -// generate a v1alpha1.HelmChart object in the same namespace as the referenced -// v1alpha1.Source. +// generate a v1beta1.HelmChart object in the same namespace as the referenced +// v1beta1.Source. type HelmChartTemplate struct { - // Spec holds the template for the v1alpha1.HelmChartSpec for this HelmRelease. + // Spec holds the template for the v1beta1.HelmChartSpec for this HelmRelease. // +required Spec HelmChartTemplateSpec `json:"spec"` } // HelmChartTemplateSpec defines the template from which the controller will -// generate a v1alpha1.HelmChartSpec object. +// generate a v1beta1.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 v1alpha1.GitRepository and - // v1alpha1.Bucket sources. Defaults to latest when omitted. + // Version semver expression, ignored for charts from v1beta1.GitRepository and + // v1beta1.Bucket sources. Defaults to latest when omitted. // +optional Version string `json:"version,omitempty"` - // The name and namespace of the v1alpha1.Source the chart is available at. + // The name and namespace of the v1beta1.Source the chart is available at. // +required SourceRef CrossNamespaceObjectReference `json:"sourceRef"` - // Interval at which to check the v1alpha1.Source for updates. Defaults to + // Interval at which to check the v1beta1.Source for updates. Defaults to // 'HelmReleaseSpec.Interval'. // +optional Interval *metav1.Duration `json:"interval,omitempty"` @@ -190,7 +190,7 @@ type HelmChartTemplateSpec struct { ValuesFile string `json:"valuesFile,omitempty"` } -// GetInterval returns the configured interval for the v1alpha1.HelmChart, +// GetInterval returns the configured interval for the v1beta1.HelmChart, // or the given default. func (in HelmChartTemplate) GetInterval(defaultInterval metav1.Duration) metav1.Duration { if in.Spec.Interval == nil { @@ -200,7 +200,7 @@ func (in HelmChartTemplate) GetInterval(defaultInterval metav1.Duration) metav1. } // GetNamespace returns the namespace targeted namespace for the -// v1alpha1.HelmChart, or the given default. +// v1beta1.HelmChart, or the given default. func (in HelmChartTemplate) GetNamespace(defaultNamespace string) string { if in.Spec.SourceRef.Namespace == "" { return defaultNamespace diff --git a/api/v2alpha1/reference_types.go b/api/v2beta1/reference_types.go similarity index 99% rename from api/v2alpha1/reference_types.go rename to api/v2beta1/reference_types.go index 4365967da..15e8ed4e5 100644 --- a/api/v2alpha1/reference_types.go +++ b/api/v2beta1/reference_types.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha1 +package v2beta1 // CrossNamespaceObjectReference contains enough information to let you locate // the typed referenced object at cluster level. diff --git a/api/v2alpha1/zz_generated.deepcopy.go b/api/v2beta1/zz_generated.deepcopy.go similarity index 99% rename from api/v2alpha1/zz_generated.deepcopy.go rename to api/v2beta1/zz_generated.deepcopy.go index c670d5725..4840e428e 100644 --- a/api/v2alpha1/zz_generated.deepcopy.go +++ b/api/v2beta1/zz_generated.deepcopy.go @@ -18,7 +18,7 @@ limitations under the License. // Code generated by controller-gen. DO NOT EDIT. -package v2alpha1 +package v2beta1 import ( "github.com/fluxcd/pkg/apis/meta" diff --git a/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml b/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml index 437cdf6ad..9385095fb 100644 --- a/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml +++ b/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml @@ -28,7 +28,7 @@ spec: - jsonPath: .metadata.creationTimestamp name: Age type: date - name: v2alpha1 + name: v2beta1 schema: openAPIV3Schema: description: HelmRelease is the Schema for the helmreleases API @@ -49,11 +49,11 @@ spec: description: HelmReleaseSpec defines the desired state of a Helm release. properties: chart: - description: Chart defines the template of the v1alpha1.HelmChart - that should be created for this HelmRelease. + description: Chart defines the template of the v1beta1.HelmChart that + should be created for this HelmRelease. properties: spec: - description: Spec holds the template for the v1alpha1.HelmChartSpec + description: Spec holds the template for the v1beta1.HelmChartSpec for this HelmRelease. properties: chart: @@ -61,11 +61,11 @@ spec: at in the SourceRef. type: string interval: - description: Interval at which to check the v1alpha1.Source + description: Interval at which to check the v1beta1.Source for updates. Defaults to 'HelmReleaseSpec.Interval'. type: string sourceRef: - description: The name and namespace of the v1alpha1.Source + description: The name and namespace of the v1beta1.Source the chart is available at. properties: apiVersion: @@ -98,8 +98,8 @@ spec: type: string version: description: Version semver expression, ignored for charts - from v1alpha1.GitRepository and v1alpha1.Bucket sources. - Defaults to latest when omitted. + from v1beta1.GitRepository and v1beta1.Bucket sources. Defaults + to latest when omitted. type: string required: - chart diff --git a/config/default/kustomization.yaml b/config/default/kustomization.yaml index 5bb51d5c8..7606c36d8 100644 --- a/config/default/kustomization.yaml +++ b/config/default/kustomization.yaml @@ -5,6 +5,6 @@ resources: - ../crd - ../rbac - ../manager -- github.com/fluxcd/source-controller/config//crd?ref=v0.0.15 -- github.com/fluxcd/source-controller/config//manager?ref=v0.0.15 +- github.com/fluxcd/source-controller/config//crd?ref=v0.1.0 +- github.com/fluxcd/source-controller/config//manager?ref=v0.1.0 - namespace.yaml diff --git a/config/samples/helm_v2alpha1_helmrelease_gitrepository.yaml b/config/samples/helm_v2beta1_helmrelease_gitrepository.yaml similarity index 87% rename from config/samples/helm_v2alpha1_helmrelease_gitrepository.yaml rename to config/samples/helm_v2beta1_helmrelease_gitrepository.yaml index 5bb21d618..256b8ca98 100644 --- a/config/samples/helm_v2alpha1_helmrelease_gitrepository.yaml +++ b/config/samples/helm_v2beta1_helmrelease_gitrepository.yaml @@ -1,4 +1,4 @@ -apiVersion: helm.toolkit.fluxcd.io/v2alpha1 +apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: podinfo-gitrepository diff --git a/config/samples/helm_v2alpha1_helmrelease_helmrepository.yaml b/config/samples/helm_v2beta1_helmrelease_helmrepository.yaml similarity index 88% rename from config/samples/helm_v2alpha1_helmrelease_helmrepository.yaml rename to config/samples/helm_v2beta1_helmrelease_helmrepository.yaml index 4d471fa41..80df4f9c4 100644 --- a/config/samples/helm_v2alpha1_helmrelease_helmrepository.yaml +++ b/config/samples/helm_v2beta1_helmrelease_helmrepository.yaml @@ -1,4 +1,4 @@ -apiVersion: helm.toolkit.fluxcd.io/v2alpha1 +apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: podinfo-helmrepository diff --git a/config/samples/source_v1alpha1_gitrepository.yaml b/config/samples/source_v1beta1_gitrepository.yaml similarity index 75% rename from config/samples/source_v1alpha1_gitrepository.yaml rename to config/samples/source_v1beta1_gitrepository.yaml index 33b989544..5664f171b 100644 --- a/config/samples/source_v1alpha1_gitrepository.yaml +++ b/config/samples/source_v1beta1_gitrepository.yaml @@ -1,4 +1,4 @@ -apiVersion: source.toolkit.fluxcd.io/v1alpha1 +apiVersion: source.toolkit.fluxcd.io/v1beta1 kind: GitRepository metadata: name: podinfo diff --git a/config/samples/source_v1alpha1_helmrepository.yaml b/config/samples/source_v1beta1_helmrepository.yaml similarity index 71% rename from config/samples/source_v1alpha1_helmrepository.yaml rename to config/samples/source_v1beta1_helmrepository.yaml index 26f80a0de..79008e7b8 100644 --- a/config/samples/source_v1alpha1_helmrepository.yaml +++ b/config/samples/source_v1beta1_helmrepository.yaml @@ -1,4 +1,4 @@ -apiVersion: source.toolkit.fluxcd.io/v1alpha1 +apiVersion: source.toolkit.fluxcd.io/v1beta1 kind: HelmRepository metadata: name: podinfo diff --git a/config/testdata/dependencies/helmrelease-backend.yaml b/config/testdata/dependencies/helmrelease-backend.yaml index 0e25a9eab..f36bdfe69 100644 --- a/config/testdata/dependencies/helmrelease-backend.yaml +++ b/config/testdata/dependencies/helmrelease-backend.yaml @@ -1,4 +1,4 @@ -apiVersion: helm.toolkit.fluxcd.io/v2alpha1 +apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: backend diff --git a/config/testdata/dependencies/helmrelease-frontend.yaml b/config/testdata/dependencies/helmrelease-frontend.yaml index 29cc4e50f..13d2943fb 100644 --- a/config/testdata/dependencies/helmrelease-frontend.yaml +++ b/config/testdata/dependencies/helmrelease-frontend.yaml @@ -1,4 +1,4 @@ -apiVersion: helm.toolkit.fluxcd.io/v2alpha1 +apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: frontend diff --git a/config/testdata/dependencies/helmrepository.yaml b/config/testdata/dependencies/helmrepository.yaml index e63e5f361..d53a5fdd4 100644 --- a/config/testdata/dependencies/helmrepository.yaml +++ b/config/testdata/dependencies/helmrepository.yaml @@ -1,4 +1,4 @@ -apiVersion: source.toolkit.fluxcd.io/v1alpha1 +apiVersion: source.toolkit.fluxcd.io/v1beta1 kind: HelmRepository metadata: name: webapp diff --git a/config/testdata/install-fail-remediate/helmrelease.yaml b/config/testdata/install-fail-remediate/helmrelease.yaml index 44a2781dc..0b0a977c4 100644 --- a/config/testdata/install-fail-remediate/helmrelease.yaml +++ b/config/testdata/install-fail-remediate/helmrelease.yaml @@ -1,4 +1,4 @@ -apiVersion: helm.toolkit.fluxcd.io/v2alpha1 +apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: install-fail-remediate diff --git a/config/testdata/install-fail-retry/helmrelease.yaml b/config/testdata/install-fail-retry/helmrelease.yaml index 90f0f6999..b173aa88a 100644 --- a/config/testdata/install-fail-retry/helmrelease.yaml +++ b/config/testdata/install-fail-retry/helmrelease.yaml @@ -1,4 +1,4 @@ -apiVersion: helm.toolkit.fluxcd.io/v2alpha1 +apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: install-fail-retry diff --git a/config/testdata/install-fail/helmrelease.yaml b/config/testdata/install-fail/helmrelease.yaml index a565bb145..a7329bda3 100644 --- a/config/testdata/install-fail/helmrelease.yaml +++ b/config/testdata/install-fail/helmrelease.yaml @@ -1,4 +1,4 @@ -apiVersion: helm.toolkit.fluxcd.io/v2alpha1 +apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: install-fail diff --git a/config/testdata/install-test-fail-ignore/helmrelease.yaml b/config/testdata/install-test-fail-ignore/helmrelease.yaml index 5e0ecbe51..dcd3f441d 100644 --- a/config/testdata/install-test-fail-ignore/helmrelease.yaml +++ b/config/testdata/install-test-fail-ignore/helmrelease.yaml @@ -1,4 +1,4 @@ -apiVersion: helm.toolkit.fluxcd.io/v2alpha1 +apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: install-test-fail-ignore diff --git a/config/testdata/install-test-fail/helmrelease.yaml b/config/testdata/install-test-fail/helmrelease.yaml index df30d0a13..3ceb16793 100644 --- a/config/testdata/install-test-fail/helmrelease.yaml +++ b/config/testdata/install-test-fail/helmrelease.yaml @@ -1,4 +1,4 @@ -apiVersion: helm.toolkit.fluxcd.io/v2alpha1 +apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: install-test-fail diff --git a/config/testdata/podinfo/gitrepository.yaml b/config/testdata/podinfo/gitrepository.yaml index 33b989544..5664f171b 100644 --- a/config/testdata/podinfo/gitrepository.yaml +++ b/config/testdata/podinfo/gitrepository.yaml @@ -1,4 +1,4 @@ -apiVersion: source.toolkit.fluxcd.io/v1alpha1 +apiVersion: source.toolkit.fluxcd.io/v1beta1 kind: GitRepository metadata: name: podinfo diff --git a/config/testdata/podinfo/helmrelease-git.yaml b/config/testdata/podinfo/helmrelease-git.yaml index 4aa25b791..2e8d46084 100644 --- a/config/testdata/podinfo/helmrelease-git.yaml +++ b/config/testdata/podinfo/helmrelease-git.yaml @@ -1,4 +1,4 @@ -apiVersion: helm.toolkit.fluxcd.io/v2alpha1 +apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: podinfo-git diff --git a/config/testdata/podinfo/helmrelease.yaml b/config/testdata/podinfo/helmrelease.yaml index a48c2053f..6f9635ad0 100644 --- a/config/testdata/podinfo/helmrelease.yaml +++ b/config/testdata/podinfo/helmrelease.yaml @@ -1,4 +1,4 @@ -apiVersion: helm.toolkit.fluxcd.io/v2alpha1 +apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: podinfo diff --git a/config/testdata/podinfo/helmrepository.yaml b/config/testdata/podinfo/helmrepository.yaml index 26f80a0de..79008e7b8 100644 --- a/config/testdata/podinfo/helmrepository.yaml +++ b/config/testdata/podinfo/helmrepository.yaml @@ -1,4 +1,4 @@ -apiVersion: source.toolkit.fluxcd.io/v1alpha1 +apiVersion: source.toolkit.fluxcd.io/v1beta1 kind: HelmRepository metadata: name: podinfo diff --git a/config/testdata/upgrade-fail-remediate-uninstall/install.yaml b/config/testdata/upgrade-fail-remediate-uninstall/install.yaml index faec5875d..a734685a0 100644 --- a/config/testdata/upgrade-fail-remediate-uninstall/install.yaml +++ b/config/testdata/upgrade-fail-remediate-uninstall/install.yaml @@ -1,4 +1,4 @@ -apiVersion: helm.toolkit.fluxcd.io/v2alpha1 +apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: upgrade-fail-remediate-uninstall diff --git a/config/testdata/upgrade-fail-remediate-uninstall/upgrade.yaml b/config/testdata/upgrade-fail-remediate-uninstall/upgrade.yaml index 2789ad2f6..996dbcab6 100644 --- a/config/testdata/upgrade-fail-remediate-uninstall/upgrade.yaml +++ b/config/testdata/upgrade-fail-remediate-uninstall/upgrade.yaml @@ -1,4 +1,4 @@ -apiVersion: helm.toolkit.fluxcd.io/v2alpha1 +apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: upgrade-fail-remediate-uninstall diff --git a/config/testdata/upgrade-fail-remediate/install.yaml b/config/testdata/upgrade-fail-remediate/install.yaml index b111f914a..f957c4c75 100644 --- a/config/testdata/upgrade-fail-remediate/install.yaml +++ b/config/testdata/upgrade-fail-remediate/install.yaml @@ -1,4 +1,4 @@ -apiVersion: helm.toolkit.fluxcd.io/v2alpha1 +apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: upgrade-fail-remediate diff --git a/config/testdata/upgrade-fail-remediate/upgrade.yaml b/config/testdata/upgrade-fail-remediate/upgrade.yaml index 509ff2de1..b96dfd471 100644 --- a/config/testdata/upgrade-fail-remediate/upgrade.yaml +++ b/config/testdata/upgrade-fail-remediate/upgrade.yaml @@ -1,4 +1,4 @@ -apiVersion: helm.toolkit.fluxcd.io/v2alpha1 +apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: upgrade-fail-remediate diff --git a/config/testdata/upgrade-fail-retry/install.yaml b/config/testdata/upgrade-fail-retry/install.yaml index 50b6fa453..709ac6630 100644 --- a/config/testdata/upgrade-fail-retry/install.yaml +++ b/config/testdata/upgrade-fail-retry/install.yaml @@ -1,4 +1,4 @@ -apiVersion: helm.toolkit.fluxcd.io/v2alpha1 +apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: upgrade-fail-retry diff --git a/config/testdata/upgrade-fail-retry/upgrade.yaml b/config/testdata/upgrade-fail-retry/upgrade.yaml index cd6849685..ec3a45e81 100644 --- a/config/testdata/upgrade-fail-retry/upgrade.yaml +++ b/config/testdata/upgrade-fail-retry/upgrade.yaml @@ -1,4 +1,4 @@ -apiVersion: helm.toolkit.fluxcd.io/v2alpha1 +apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: upgrade-fail-retry diff --git a/config/testdata/upgrade-fail/install.yaml b/config/testdata/upgrade-fail/install.yaml index a00d2453d..c116f375c 100644 --- a/config/testdata/upgrade-fail/install.yaml +++ b/config/testdata/upgrade-fail/install.yaml @@ -1,4 +1,4 @@ -apiVersion: helm.toolkit.fluxcd.io/v2alpha1 +apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: upgrade-fail diff --git a/config/testdata/upgrade-fail/upgrade.yaml b/config/testdata/upgrade-fail/upgrade.yaml index 1ed7ba1bb..0c5b30b7a 100644 --- a/config/testdata/upgrade-fail/upgrade.yaml +++ b/config/testdata/upgrade-fail/upgrade.yaml @@ -1,4 +1,4 @@ -apiVersion: helm.toolkit.fluxcd.io/v2alpha1 +apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: upgrade-fail diff --git a/config/testdata/upgrade-test-fail/install.yaml b/config/testdata/upgrade-test-fail/install.yaml index fe9b5ea1f..a1af5d87f 100644 --- a/config/testdata/upgrade-test-fail/install.yaml +++ b/config/testdata/upgrade-test-fail/install.yaml @@ -1,4 +1,4 @@ -apiVersion: helm.toolkit.fluxcd.io/v2alpha1 +apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: upgrade-test-fail diff --git a/config/testdata/upgrade-test-fail/upgrade.yaml b/config/testdata/upgrade-test-fail/upgrade.yaml index f7c21b33c..ca8a80930 100644 --- a/config/testdata/upgrade-test-fail/upgrade.yaml +++ b/config/testdata/upgrade-test-fail/upgrade.yaml @@ -1,4 +1,4 @@ -apiVersion: helm.toolkit.fluxcd.io/v2alpha1 +apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: upgrade-test-fail diff --git a/config/testdata/valuesfrom/helmrelease.yaml b/config/testdata/valuesfrom/helmrelease.yaml index 9015132d3..3d994b96e 100644 --- a/config/testdata/valuesfrom/helmrelease.yaml +++ b/config/testdata/valuesfrom/helmrelease.yaml @@ -1,4 +1,4 @@ -apiVersion: helm.toolkit.fluxcd.io/v2alpha1 +apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: valuesfrom diff --git a/config/testdata/valuesfrom/helmrepository.yaml b/config/testdata/valuesfrom/helmrepository.yaml index 42bc13546..25eff5d53 100644 --- a/config/testdata/valuesfrom/helmrepository.yaml +++ b/config/testdata/valuesfrom/helmrepository.yaml @@ -1,4 +1,4 @@ -apiVersion: source.toolkit.fluxcd.io/v1alpha1 +apiVersion: source.toolkit.fluxcd.io/v1beta1 kind: HelmRepository metadata: name: valuesfrom diff --git a/controllers/helmchart_predicate.go b/controllers/helmchart_predicate.go index 912cf736b..a7376a17f 100644 --- a/controllers/helmchart_predicate.go +++ b/controllers/helmchart_predicate.go @@ -20,7 +20,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/predicate" - sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1" + sourcev1 "github.com/fluxcd/source-controller/api/v1beta1" ) type HelmChartRevisionChangePredicate struct { diff --git a/controllers/helmchart_watcher.go b/controllers/helmchart_watcher.go index f75619721..b478b8a5c 100644 --- a/controllers/helmchart_watcher.go +++ b/controllers/helmchart_watcher.go @@ -31,9 +31,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/fluxcd/pkg/apis/meta" - sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1" + sourcev1 "github.com/fluxcd/source-controller/api/v1beta1" - v2 "github.com/fluxcd/helm-controller/api/v2alpha1" + v2 "github.com/fluxcd/helm-controller/api/v2beta1" ) // HelmChartWatcher watches HelmChart objects for revision changes and diff --git a/controllers/helmrelease_controller.go b/controllers/helmrelease_controller.go index ac0cc2f6a..314e0bb07 100644 --- a/controllers/helmrelease_controller.go +++ b/controllers/helmrelease_controller.go @@ -47,9 +47,9 @@ import ( "github.com/fluxcd/pkg/apis/meta" "github.com/fluxcd/pkg/recorder" "github.com/fluxcd/pkg/runtime/predicates" - sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1" + sourcev1 "github.com/fluxcd/source-controller/api/v1beta1" - v2 "github.com/fluxcd/helm-controller/api/v2alpha1" + v2 "github.com/fluxcd/helm-controller/api/v2beta1" "github.com/fluxcd/helm-controller/internal/runner" "github.com/fluxcd/helm-controller/internal/util" ) @@ -438,7 +438,7 @@ func (r *HelmReleaseReconciler) checkDependencies(hr v2.HelmRelease) error { return nil } -// composeValues attempts to resolve all v2alpha1.ValuesReference resources +// composeValues attempts to resolve all v2beta1.ValuesReference resources // and merges them as defined. Referenced resources are only retrieved once // to ensure a single version is taken into account during the merge. func (r *HelmReleaseReconciler) composeValues(ctx context.Context, hr v2.HelmRelease) (chartutil.Values, error) { @@ -567,7 +567,7 @@ func (r *HelmReleaseReconciler) loadHelmChart(source *sourcev1.HelmChart) (*char return loader.Load(f.Name()) } -// garbageCollect deletes the v1alpha1.HelmChart of the v2alpha1.HelmRelease, +// garbageCollect deletes the v1beta1.HelmChart of the v2beta1.HelmRelease, // and uninstalls the Helm release if the resource has not been suspended. func (r *HelmReleaseReconciler) garbageCollect(ctx context.Context, logger logr.Logger, hr v2.HelmRelease) error { if err := r.garbageCollectHelmChart(ctx, hr); err != nil { @@ -580,8 +580,8 @@ func (r *HelmReleaseReconciler) garbageCollect(ctx context.Context, logger logr. return r.garbageCollectHelmRelease(logger, hr) } -// garbageCollectHelmChart deletes the v1alpha1.HelmChart of the -// v2alpha1.HelmRelease. +// garbageCollectHelmChart deletes the v1beta1.HelmChart of the +// v2beta1.HelmRelease. func (r *HelmReleaseReconciler) garbageCollectHelmChart(ctx context.Context, hr v2.HelmRelease) error { if hr.Status.HelmChart == "" { return nil @@ -604,7 +604,7 @@ func (r *HelmReleaseReconciler) garbageCollectHelmChart(ctx context.Context, hr } // garbageCollectHelmRelease uninstalls the deployed Helm release of -// the given v2alpha1.HelmRelease. +// the given v2beta1.HelmRelease. func (r *HelmReleaseReconciler) garbageCollectHelmRelease(logger logr.Logger, hr v2.HelmRelease) error { run, err := runner.NewRunner(r.Config, hr.Namespace, logger) if err != nil { diff --git a/controllers/suite_test.go b/controllers/suite_test.go index e0abdc290..0da94ade5 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -30,7 +30,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - helmv2alpha1 "github.com/fluxcd/helm-controller/api/v2alpha1" + "github.com/fluxcd/helm-controller/api/v2beta1" // +kubebuilder:scaffold:imports ) @@ -62,7 +62,7 @@ var _ = BeforeSuite(func(done Done) { Expect(err).ToNot(HaveOccurred()) Expect(cfg).ToNot(BeNil()) - err = helmv2alpha1.AddToScheme(scheme.Scheme) + err = v2beta1.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) // +kubebuilder:scaffold:scheme diff --git a/docs/api/helmrelease.md b/docs/api/helmrelease.md index c565b57ee..857a3b0d9 100644 --- a/docs/api/helmrelease.md +++ b/docs/api/helmrelease.md @@ -2,16 +2,16 @@

Packages:

-

helm.toolkit.fluxcd.io/v2alpha1

-

Package v2alpha1 contains API Schema definitions for the helm v2alpha1 API group

+

helm.toolkit.fluxcd.io/v2beta1

+

Package v2beta1 contains API Schema definitions for the helm v2beta1 API group

Resource Types: -

HelmRelease +

HelmRelease

HelmRelease is the Schema for the helmreleases API

@@ -29,7 +29,7 @@ Resource Types: apiVersion
string -helm.toolkit.fluxcd.io/v2alpha1 +helm.toolkit.fluxcd.io/v2beta1 @@ -59,7 +59,7 @@ Refer to the Kubernetes API documentation for the fields of the spec
- + HelmReleaseSpec @@ -72,13 +72,13 @@ HelmReleaseSpec chart
- + HelmChartTemplate -

Chart defines the template of the v1alpha1.HelmChart that should be created +

Chart defines the template of the v1beta1.HelmChart that should be created for this HelmRelease.

@@ -182,7 +182,7 @@ Use ‘0’ for an unlimited number of revisions; defaults to ‘10& install
- + Install @@ -196,7 +196,7 @@ Install upgrade
- + Upgrade @@ -210,7 +210,7 @@ Upgrade test
- + Test @@ -224,7 +224,7 @@ Test rollback
- + Rollback @@ -238,7 +238,7 @@ Rollback uninstall
- + Uninstall @@ -252,7 +252,7 @@ Uninstall valuesFrom
- + []ValuesReference @@ -283,7 +283,7 @@ Kubernetes pkg/apis/apiextensions/v1.JSON status
- + HelmReleaseStatus @@ -295,11 +295,11 @@ HelmReleaseStatus
-

CrossNamespaceObjectReference +

CrossNamespaceObjectReference

(Appears on: -HelmChartTemplateSpec) +HelmChartTemplateSpec)

CrossNamespaceObjectReference contains enough information to let you locate the typed referenced object at cluster level.

@@ -363,18 +363,18 @@ string -

DeploymentAction +

DeploymentAction

DeploymentAction defines a consistent interface for Install and Upgrade.

-

HelmChartTemplate +

HelmChartTemplate

(Appears on: -HelmReleaseSpec) +HelmReleaseSpec)

HelmChartTemplate defines the template from which the controller will -generate a v1alpha1.HelmChart object in the same namespace as the referenced -v1alpha1.Source.

+generate a v1beta1.HelmChart object in the same namespace as the referenced +v1beta1.Source.

@@ -389,13 +389,13 @@ v1alpha1.Source.

@@ -689,7 +689,7 @@ Use ‘0’ for an unlimited number of revisions; defaults to ‘10&
spec
- + HelmChartTemplateSpec
-

Spec holds the template for the v1alpha1.HelmChartSpec for this HelmRelease.

+

Spec holds the template for the v1beta1.HelmChartSpec for this HelmRelease.



@@ -419,21 +419,21 @@ string @@ -447,7 +447,7 @@ Kubernetes meta/v1.Duration @@ -471,14 +471,14 @@ relative path in the SourceRef. Ignored when omitted.

(Optional) -

Version semver expression, ignored for charts from v1alpha1.GitRepository and -v1alpha1.Bucket sources. Defaults to latest when omitted.

+

Version semver expression, ignored for charts from v1beta1.GitRepository and +v1beta1.Bucket sources. Defaults to latest when omitted.

sourceRef
- + CrossNamespaceObjectReference
-

The name and namespace of the v1alpha1.Source the chart is available at.

+

The name and namespace of the v1beta1.Source the chart is available at.

(Optional) -

Interval at which to check the v1alpha1.Source for updates. Defaults to +

Interval at which to check the v1beta1.Source for updates. Defaults to ‘HelmReleaseSpec.Interval’.

-

HelmChartTemplateSpec +

HelmChartTemplateSpec

(Appears on: -HelmChartTemplate) +HelmChartTemplate)

HelmChartTemplateSpec defines the template from which the controller will -generate a v1alpha1.HelmChartSpec object.

+generate a v1beta1.HelmChartSpec object.

@@ -509,21 +509,21 @@ string @@ -537,7 +537,7 @@ Kubernetes meta/v1.Duration @@ -558,11 +558,11 @@ relative path in the SourceRef. Ignored when omitted.

(Optional) -

Version semver expression, ignored for charts from v1alpha1.GitRepository and -v1alpha1.Bucket sources. Defaults to latest when omitted.

+

Version semver expression, ignored for charts from v1beta1.GitRepository and +v1beta1.Bucket sources. Defaults to latest when omitted.

sourceRef
- + CrossNamespaceObjectReference
-

The name and namespace of the v1alpha1.Source the chart is available at.

+

The name and namespace of the v1beta1.Source the chart is available at.

(Optional) -

Interval at which to check the v1alpha1.Source for updates. Defaults to +

Interval at which to check the v1beta1.Source for updates. Defaults to ‘HelmReleaseSpec.Interval’.

-

HelmReleaseSpec +

HelmReleaseSpec

(Appears on: -HelmRelease) +HelmRelease)

HelmReleaseSpec defines the desired state of a Helm release.

@@ -579,13 +579,13 @@ relative path in the SourceRef. Ignored when omitted.

chart
- + HelmChartTemplate
-

Chart defines the template of the v1alpha1.HelmChart that should be created +

Chart defines the template of the v1beta1.HelmChart that should be created for this HelmRelease.

install
- + Install @@ -703,7 +703,7 @@ Install
upgrade
- + Upgrade @@ -717,7 +717,7 @@ Upgrade
test
- + Test @@ -731,7 +731,7 @@ Test
rollback
- + Rollback @@ -745,7 +745,7 @@ Rollback
uninstall
- + Uninstall @@ -759,7 +759,7 @@ Uninstall
valuesFrom
- + []ValuesReference @@ -787,11 +787,11 @@ Kubernetes pkg/apis/apiextensions/v1.JSON
-

HelmReleaseStatus +

HelmReleaseStatus

(Appears on: -HelmRelease) +HelmRelease)

HelmReleaseStatus defines the observed state of a HelmRelease.

@@ -948,11 +948,11 @@ state. It is reset after a successful reconciliation.

-

Install +

Install

(Appears on: -HelmReleaseSpec) +HelmReleaseSpec)

Install holds the configuration for Helm install actions performed for this HelmRelease.

@@ -986,7 +986,7 @@ Jobs for hooks) during the performance of a Helm install action. Defaults to remediation
- + InstallRemediation @@ -1065,11 +1065,11 @@ CRDs are installed if not already present.

-

InstallRemediation +

InstallRemediation

(Appears on: -Install) +Install)

InstallRemediation holds the configuration for Helm install remediation.

@@ -1127,23 +1127,23 @@ no retries remain. Defaults to ‘false’.

-

Remediation +

Remediation

Remediation defines a consistent interface for InstallRemediation and UpgradeRemediation.

-

RemediationStrategy +

RemediationStrategy (string alias)

(Appears on: -UpgradeRemediation) +UpgradeRemediation)

RemediationStrategy returns the strategy to use to remediate a failed install or upgrade.

-

Rollback +

Rollback

(Appears on: -HelmReleaseSpec) +HelmReleaseSpec)

Rollback holds the configuration for Helm rollback actions for this HelmRelease.

@@ -1239,11 +1239,11 @@ rollback action when it fails.

-

Test +

Test

(Appears on: -HelmReleaseSpec) +HelmReleaseSpec)

Test holds the configuration for Helm test actions for this HelmRelease.

@@ -1302,11 +1302,11 @@ actions in ‘Install.IgnoreTestFailures’ and ‘Upgrade.IgnoreTes
-

Uninstall +

Uninstall

(Appears on: -HelmReleaseSpec) +HelmReleaseSpec)

Uninstall holds the configuration for Helm uninstall actions for this HelmRelease.

@@ -1365,11 +1365,11 @@ release as deleted, but retain the release history.

-

Upgrade +

Upgrade

(Appears on: -HelmReleaseSpec) +HelmReleaseSpec)

Upgrade holds the configuration for Helm upgrade actions for this HelmRelease.

@@ -1403,7 +1403,7 @@ Jobs for hooks) during the performance of a Helm upgrade action. Defaults to remediation
- + UpgradeRemediation @@ -1495,11 +1495,11 @@ upgrade action when it fails.

-

UpgradeRemediation +

UpgradeRemediation

(Appears on: -Upgrade) +Upgrade)

UpgradeRemediation holds the configuration for Helm upgrade remediation.

@@ -1557,7 +1557,7 @@ no retries remain. Defaults to ‘false’ unless ‘Retries’ strategy
- + RemediationStrategy @@ -1571,11 +1571,11 @@ RemediationStrategy
-

ValuesReference +

ValuesReference

(Appears on: -HelmReleaseSpec) +HelmReleaseSpec)

ValuesReference contains a reference to a resource containing Helm values, and optionally the key they can be found at.

diff --git a/docs/spec/README.md b/docs/spec/README.md index 86658f78e..e79f55ff9 100644 --- a/docs/spec/README.md +++ b/docs/spec/README.md @@ -50,7 +50,7 @@ trigger a Helm uninstall. Alerting can be configured with a Kubernetes custom resource that specifies a webhook address, and a group of `HelmRelease` resources to be monitored using the [notification-controller](https://github.com/fluxcd/notification-controller). -The API design of the controller can be found at [helm.toolkit.fluxcd.io/v2alpha1](./v2alpha1/helmreleases.md). +The API design of the controller can be found at [helm.toolkit.fluxcd.io/v2beta1](./v2beta1/helmreleases.md). ## Backward compatibility diff --git a/docs/spec/v2beta1/README.md b/docs/spec/v2beta1/README.md new file mode 100644 index 000000000..90641f242 --- /dev/null +++ b/docs/spec/v2beta1/README.md @@ -0,0 +1,24 @@ +# helm.toolkit.fluxcd.io/v2beta1 + +This is the v2beta1 API specification for declaratively managing Helm chart releases with +Kubernetes manifests. + +## Specification + +- [`HelmRelease` CRD](helmreleases.md) + + [Specification](helmreleases.md#specification) + * [Reference types](helmreleases.md#reference-types) + * [Status specification](helmreleases.md#status-specification) + + [Helm release placement](helmreleases.md#helm-release-placement) + + [Helm chart template](helmreleases.md#helm-chart-template) + + [Values overrides](helmreleases.md#values-overrides) + + [Reconciliation](helmreleases.md#reconciliation) + * [Disabling resource waiting](helmreleases.md#disabling-resource-waiting) + * [`HelmRelease` dependencies](helmreleases.md#helmrelease-dependencies) + * [Configuring Helm test actions](helmreleases.md#configuring-helm-test-actions) + * [Configuring failure remediation](helmreleases.md#configuring-failure-remediation) + + [Status](helmreleases.md#status) + +## Implementation + +* [helm-controller](https://github.com/fluxcd/helm-controller/) diff --git a/docs/spec/v2beta1/helmreleases.md b/docs/spec/v2beta1/helmreleases.md new file mode 100644 index 000000000..238bc6a52 --- /dev/null +++ b/docs/spec/v2beta1/helmreleases.md @@ -0,0 +1,900 @@ +# Helm Releases + +The `HelmRelease` API defines a resource for automated controller driven Helm releases. + +## Specification + +A **helmrelease** object defines a resource for controller driven reconciliation +of Helm releases via Helm actions such as install, upgrade, test, uninstall, and rollback. +This includes release placement (namespace/name), release content (chart/values overrides), +action trigger configuration, individual action configuration, and statusing. + +```go +// HelmReleaseSpec defines the desired state of a Helm Release. +type HelmReleaseSpec struct { + // Chart defines the template of the v1beta1.HelmChart that should be created + // for this HelmRelease. + // +required + Chart HelmChartTemplate `json:"chart"` + + // Interval at which to reconcile the Helm release. + // +required + Interval metav1.Duration `json:"interval"` + + // 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"` + + // ReleaseName used for the Helm release. Defaults to a composition of + // '[TargetNamespace-]Name'. + // +kubebuilder:validation:MinLength=1 + // +kubebuilder:validation:MaxLength=53 + // +kubebuilder:validation:Optional + // +optional + ReleaseName string `json:"releaseName,omitempty"` + + // TargetNamespace to target when performing operations for the HelmRelease. + // Defaults to the namespace of the HelmRelease. + // +kubebuilder:validation:MinLength=1 + // +kubebuilder:validation:MaxLength=63 + // +kubebuilder:validation:Optional + // +optional + TargetNamespace string `json:"targetNamespace,omitempty"` + + // DependsOn may contain a dependency.CrossNamespaceDependencyReference slice with + // references to HelmRelease resources that must be ready before this HelmRelease + // can be reconciled. + // +optional + DependsOn []dependency.CrossNamespaceDependencyReference `json:"dependsOn,omitempty"` + + // Timeout is the time to wait for any individual Kubernetes operation (like Jobs + // for hooks) during the performance of a Helm action. Defaults to '5m0s'. + // +optional + Timeout *metav1.Duration `json:"timeout,omitempty"` + + // MaxHistory is the number of revisions saved by Helm for this HelmRelease. + // Use '0' for an unlimited number of revisions; defaults to '10'. + // +optional + MaxHistory *int `json:"maxHistory,omitempty"` + + // Install holds the configuration for Helm install actions for this HelmRelease. + // +optional + Install *Install `json:"install,omitempty"` + + // Upgrade holds the configuration for Helm upgrade actions for this HelmRelease. + // +optional + Upgrade *Upgrade `json:"upgrade,omitempty"` + + // Test holds the configuration for Helm test actions for this HelmRelease. + // +optional + Test *Test `json:"test,omitempty"` + + // Rollback holds the configuration for Helm rollback actions for this HelmRelease. + // +optional + Rollback *Rollback `json:"rollback,omitempty"` + + // Uninstall holds the configuration for Helm uninstall actions for this HelmRelease. + // +optional + Uninstall *Uninstall `json:"uninstall,omitempty"` + + // ValuesFrom holds references to resources containing Helm values for this HelmRelease, + // and information about how they should be merged. + ValuesFrom []ValuesReference `json:"valuesFrom,omitempty"` + + // Values holds the values for this Helm release. + // +optional + Values *apiextensionsv1.JSON `json:"values,omitempty"` +} + +// HelmChartTemplate defines the template from which the controller will +// generate a v1beta1.HelmChart object in the same namespace as the referenced +// v1beta1.Source. +type HelmChartTemplate struct { + // Spec holds the template for the v1beta1.HelmChartSpec for this HelmRelease. + // +required + Spec HelmChartTemplateSpec `json:"spec"` +} + +// HelmChartTemplateSpec defines the template from which the controller will +// generate a v1beta1.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 v1beta1.GitRepository and + // v1beta1.Bucket sources. Defaults to latest when omitted. + // +optional + Version string `json:"version,omitempty"` + + // The name and namespace of the v1beta1.Source the chart is available at. + // +required + SourceRef CrossNamespaceObjectReference `json:"sourceRef"` + + // Interval at which to check the v1beta1.Source for updates. Defaults to + // 'HelmReleaseSpec.Interval'. + // +optional + Interval *metav1.Duration `json:"interval,omitempty"` + + // Alternative values file to use as the default chart values, expected to be a + // relative path in the SourceRef. Ignored when omitted. + // +optional + ValuesFile string `json:"valuesFile,omitempty"` +} + +// Install holds the configuration for Helm install actions performed for this +// HelmRelease. +type Install struct { + // Timeout is the time to wait for any individual Kubernetes operation (like + // Jobs for hooks) during the performance of a Helm install action. Defaults to + // 'HelmReleaseSpec.Timeout'. + // +optional + Timeout *metav1.Duration `json:"timeout,omitempty"` + + // Remediation holds the remediation configuration for when the Helm install + // action for the HelmRelease fails. The default is to not perform any action. + // +optional + Remediation *InstallRemediation `json:"remediation,omitempty"` + + // DisableWait disables the waiting for resources to be ready after a Helm + // install has been performed. + // +optional + DisableWait bool `json:"disableWait,omitempty"` + + // DisableHooks prevents hooks from running during the Helm install action. + // +optional + DisableHooks bool `json:"disableHooks,omitempty"` + + // DisableOpenAPIValidation prevents the Helm install action from validating + // rendered templates against the Kubernetes OpenAPI Schema. + // +optional + DisableOpenAPIValidation bool `json:"disableOpenAPIValidation,omitempty"` + + // Replace tells the Helm install action to re-use the 'ReleaseName', but only + // if that name is a deleted release which remains in the history. + // +optional + Replace bool `json:"replace,omitempty"` + + // SkipCRDs tells the Helm install action to not install any CRDs. By default, + // CRDs are installed if not already present. + // +optional + SkipCRDs bool `json:"skipCRDs,omitempty"` +} + +// InstallRemediation holds the configuration for Helm install remediation. +type InstallRemediation struct { + // Retries is the number of retries that should be attempted on failures before + // bailing. Remediation, using an uninstall, is performed between each attempt. + // Defaults to '0', a negative integer equals to unlimited retries. + // +optional + Retries int `json:"retries,omitempty"` + + // IgnoreTestFailures tells the controller to skip remediation when the Helm + // tests are run after an install action but fail. Defaults to + // 'Test.IgnoreFailures'. + // +optional + IgnoreTestFailures *bool `json:"ignoreTestFailures,omitempty"` + + // RemediateLastFailure tells the controller to remediate the last failure, when + // no retries remain. Defaults to 'false'. + // +optional + RemediateLastFailure *bool `json:"remediateLastFailure,omitempty"` +} + +// Upgrade holds the configuration for Helm upgrade actions for this +// HelmRelease. +type Upgrade struct { + // Timeout is the time to wait for any individual Kubernetes operation (like + // Jobs for hooks) during the performance of a Helm upgrade action. Defaults to + // 'HelmReleaseSpec.Timeout'. + // +optional + Timeout *metav1.Duration `json:"timeout,omitempty"` + + // Remediation holds the remediation configuration for when the Helm upgrade + // action for the HelmRelease fails. The default is to not perform any action. + // +optional + Remediation *UpgradeRemediation `json:"remediation,omitempty"` + + // DisableWait disables the waiting for resources to be ready after a Helm + // upgrade has been performed. + // +optional + DisableWait bool `json:"disableWait,omitempty"` + + // DisableHooks prevents hooks from running during the Helm upgrade action. + // +optional + DisableHooks bool `json:"disableHooks,omitempty"` + + // DisableOpenAPIValidation prevents the Helm upgrade action from validating + // rendered templates against the Kubernetes OpenAPI Schema. + // +optional + DisableOpenAPIValidation bool `json:"disableOpenAPIValidation,omitempty"` + + // Force forces resource updates through a replacement strategy. + // +optional + Force bool `json:"force,omitempty"` + + // PreserveValues will make Helm reuse the last release's values and merge in + // overrides from 'Values'. Setting this flag makes the HelmRelease + // non-declarative. + // +optional + PreserveValues bool `json:"preserveValues,omitempty"` + + // CleanupOnFail allows deletion of new resources created during the Helm + // upgrade action when it fails. + // +optional + CleanupOnFail bool `json:"cleanupOnFail,omitempty"` +} + +// UpgradeRemediation holds the configuration for Helm upgrade remediation. +type UpgradeRemediation struct { + // Retries is the number of retries that should be attempted on failures before + // bailing. Remediation, using 'Strategy', is performed between each attempt. + // Defaults to '0', a negative integer equals to unlimited retries. + // +optional + Retries int `json:"retries,omitempty"` + + // IgnoreTestFailures tells the controller to skip remediation when the Helm + // tests are run after an upgrade action but fail. + // Defaults to 'Test.IgnoreFailures'. + // +optional + IgnoreTestFailures *bool `json:"ignoreTestFailures,omitempty"` + + // RemediateLastFailure tells the controller to remediate the last failure, when + // no retries remain. Defaults to 'false' unless 'Retries' is greater than 0. + // +optional + RemediateLastFailure *bool `json:"remediateLastFailure,omitempty"` + + // Strategy to use for failure remediation. Defaults to 'rollback'. + // +kubebuilder:validation:Enum=rollback;uninstall + // +optional + Strategy *RemediationStrategy `json:"strategy,omitempty"` +} + +// Test holds the configuration for Helm test actions for this HelmRelease. +type Test struct { + // Enable enables Helm test actions for this HelmRelease after an Helm install + // or upgrade action has been performed. + // +optional + Enable bool `json:"enable,omitempty"` + + // Timeout is the time to wait for any individual Kubernetes operation during + // the performance of a Helm test action. Defaults to 'HelmReleaseSpec.Timeout'. + // +optional + Timeout *metav1.Duration `json:"timeout,omitempty"` + + // IgnoreFailures tells the controller to skip remediation when the Helm tests + // are run but fail. Can be overwritten for tests run after install or upgrade + // actions in 'Install.IgnoreTestFailures' and 'Upgrade.IgnoreTestFailures'. + // +optional + IgnoreFailures bool `json:"ignoreFailures,omitempty"` +} + +// Rollback holds the configuration for Helm rollback actions for this +// HelmRelease. +type Rollback struct { + // Timeout is the time to wait for any individual Kubernetes operation (like + // Jobs for hooks) during the performance of a Helm rollback action. Defaults to + // 'HelmReleaseSpec.Timeout'. + // +optional + Timeout *metav1.Duration `json:"timeout,omitempty"` + + // DisableWait disables the waiting for resources to be ready after a Helm + // rollback has been performed. + // +optional + DisableWait bool `json:"disableWait,omitempty"` + + // DisableHooks prevents hooks from running during the Helm rollback action. + // +optional + DisableHooks bool `json:"disableHooks,omitempty"` + + // Recreate performs pod restarts for the resource if applicable. + // +optional + Recreate bool `json:"recreate,omitempty"` + + // Force forces resource updates through a replacement strategy. + // +optional + Force bool `json:"force,omitempty"` + + // CleanupOnFail allows deletion of new resources created during the Helm + // rollback action when it fails. + // +optional + CleanupOnFail bool `json:"cleanupOnFail,omitempty"` +} + +// Uninstall holds the configuration for Helm uninstall actions for this +// HelmRelease. +type Uninstall struct { + // Timeout is the time to wait for any individual Kubernetes operation (like + // Jobs for hooks) during the performance of a Helm uninstall action. Defaults + // to 'HelmReleaseSpec.Timeout'. + // +optional + Timeout *metav1.Duration `json:"timeout,omitempty"` + + // DisableHooks prevents hooks from running during the Helm rollback action. + // +optional + DisableHooks bool `json:"disableHooks,omitempty"` + + // KeepHistory tells Helm to remove all associated resources and mark the + // release as deleted, but retain the release history. + // +optional + KeepHistory bool `json:"keepHistory,omitempty"` +} +``` + +### Reference types + +```go +// CrossNamespaceObjectReference contains enough information to let you locate the +// typed referenced object at cluster level. +type CrossNamespaceObjectReference struct { + // APIVersion of the referent. + // +optional + APIVersion string `json:"apiVersion,omitempty"` + + // Kind of the referent. + // +kubebuilder:validation:Enum=HelmRepository + // +required + Kind string `json:"kind,omitempty"` + + // Name of the referent. + // +kubebuilder:validation:MinLength=1 + // +kubebuilder:validation:MaxLength=253 + // +required + Name string `json:"name"` + + // Namespace of the referent. + // +kubebuilder:validation:MinLength=1 + // +kubebuilder:validation:MaxLength=63 + // +kubebuilder:validation:Optional + // +optional + Namespace string `json:"namespace,omitempty"` +} + +// ValuesReference contains a reference to a resource containing Helm values, +// and optionally the key they can be found at. +type ValuesReference struct { + // Kind of the values referent, valid values are ('Secret', 'ConfigMap'). + // +kubebuilder:validation:Enum=Secret;ConfigMap + // +required + Kind string `json:"kind"` + + // Name of the values referent. Should reside in the same namespace as the + // referring resource. + // +kubebuilder:validation:MinLength=1 + // +kubebuilder:validation:MaxLength=253 + // +required + Name string `json:"name"` + + // ValuesKey is the data key where the values.yaml or a specific value can be + // found at. Defaults to 'values.yaml'. + // +optional + ValuesKey string `json:"valuesKey,omitempty"` + + // TargetPath is the YAML dot notation path the value should be merged at. When + // set, the ValuesKey is expected to be a single flat value. Defaults to 'None', + // which results in the values getting merged at the root. + // +optional + TargetPath string `json:"targetPath,omitempty"` + + // Optional marks this ValuesReference as optional. When set, a not found error + // for the values reference is ignored, but any ValuesKey, TargetPath or + // transient error will still result in a reconciliation failure. + // +optional + Optional bool `json:"optional,omitempty"` +} +``` + +### Status specification + +```go +// HelmReleaseStatus defines the observed state of a HelmRelease. +type HelmReleaseStatus struct { + // ObservedGeneration is the last observed generation. + // +optional + ObservedGeneration int64 `json:"observedGeneration,omitempty"` + + // LastHandledReconcileAt is the last manual reconciliation request (by + // annotating the HelmRelease) handled by the reconciler. + // +optional + LastHandledReconcileAt string `json:"lastHandledReconcileAt,omitempty"` + + // Conditions holds the conditions for the HelmRelease. + // +optional + Conditions []meta.Condition `json:"conditions,omitempty"` + + // LastAppliedRevision is the revision of the last successfully applied source. + // +optional + LastAppliedRevision string `json:"lastAppliedRevision,omitempty"` + + // LastAttemptedRevision is the revision of the last reconciliation attempt. + // +optional + LastAttemptedRevision string `json:"lastAttemptedRevision,omitempty"` + + // LastAttemptedValuesChecksum is the SHA1 checksum of the values of the last + // reconciliation attempt. + // +optional + LastAttemptedValuesChecksum string `json:"lastAttemptedValuesChecksum,omitempty"` + + // LastReleaseRevision is the revision of the last successful Helm release. + // +optional + LastReleaseRevision int `json:"lastReleaseRevision,omitempty"` + + // HelmChart is the namespaced name of the HelmChart resource created by + // the controller for the HelmRelease. + // +optional + HelmChart string `json:"helmChart,omitempty"` + + // Failures is the reconciliation failure count against the latest observed + // state. It is reset after a successful reconciliation. + // +optional + Failures int64 `json:"failures,omitempty"` + + // InstallFailures is the install failure count against the latest observed + // state. It is reset after a successful reconciliation. + // +optional + InstallFailures int64 `json:"installFailures,omitempty"` + + // UpgradeFailures is the upgrade failure count against the latest observed + // state. It is reset after a successful reconciliation. + // +optional + UpgradeFailures int64 `json:"upgradeFailures,omitempty"` +} +``` + +#### Condition types + +```go +const ( + // ReleasedCondition represents the status of the last release attempt + // (install/upgrade/test) against the latest desired state. + ReleasedCondition string = "Released" + + // TestSuccessCondition represents the status of the last test attempt against + // the latest desired state. + TestSuccessCondition string = "TestSuccess" + + // RemediatedCondition represents the status of the last remediation attempt + // (uninstall/rollback) due to a failure of the last release attempt against the + // latest desired state. + RemediatedCondition string = "Remediated" +) +``` + +#### Condition reasons + +```go +const ( + // InstallSucceededReason represents the fact that the Helm install for the + // HelmRelease succeeded. + InstallSucceededReason string = "InstallSucceeded" + + // InstallFailedReason represents the fact that the Helm install for the + // HelmRelease failed. + InstallFailedReason string = "InstallFailed" + + // UpgradeSucceededReason represents the fact that the Helm upgrade for the + // HelmRelease succeeded. + UpgradeSucceededReason string = "UpgradeSucceeded" + + // UpgradeFailedReason represents the fact that the Helm upgrade for the + // HelmRelease failed. + UpgradeFailedReason string = "UpgradeFailed" + + // TestSucceededReason represents the fact that the Helm tests for the + // HelmRelease succeeded. + TestSucceededReason string = "TestSucceeded" + + // TestFailedReason represents the fact that the Helm tests for the HelmRelease + // failed. + TestFailedReason string = "TestFailed" + + // RollbackSucceededReason represents the fact that the Helm rollback for the + // HelmRelease succeeded. + RollbackSucceededReason string = "RollbackSucceeded" + + // RollbackFailedReason represents the fact that the Helm test for the + // HelmRelease failed. + RollbackFailedReason string = "RollbackFailed" + + // UninstallSucceededReason represents the fact that the Helm uninstall for the + // HelmRelease succeeded. + UninstallSucceededReason string = "UninstallSucceeded" + + // UninstallFailedReason represents the fact that the Helm uninstall for the + // HelmRelease failed. + UninstallFailedReason string = "UninstallFailed" + + // ArtifactFailedReason represents the fact that the artifact download for the + // HelmRelease failed. + ArtifactFailedReason string = "ArtifactFailed" + + // InitFailedReason represents the fact that the initialization of the Helm + // configuration failed. + InitFailedReason string = "InitFailed" + + // GetLastReleaseFailedReason represents the fact that observing the last + // release failed. + GetLastReleaseFailedReason string = "GetLastReleaseFailed" +) +``` + +## Helm release placement + +The namespace/name in which to deploy the Helm release defaults to the namespace/name of the +`HelmRelease`. These can be overridden respectively via `spec.targetNamespace` and +`spec.releaseName`. If `spec.targetNamespace` is set, `spec.releaseName` defaults to +`-`. + +> **Note:** that configuring the `spec.targetNamespace` only defines the namespace the release +> is made in, the metadata for the release (also known as the "Helm storage") will always be +> stored in the `metadata.namespace` of the `HelmRelease`. + +## Helm chart template + +The `spec.chart.spec` values are used by the helm-controller as a template +to create a new `HelmChart` resource with the given spec. + +The `spec.chart.spec.sourceRef` is a reference to an object managed by +[source-controller](https://github.com/fluxcd/source-controller). When the source +[revision](https://github.com/fluxcd/source-controller/blob/master/docs/spec/v1beta1/common.md#source-status) +changes, it generates a Kubernetes event that triggers a new release. + +Supported source types: + +* [HelmRepository](https://github.com/fluxcd/source-controller/blob/master/docs/spec/v1beta1/helmrepositories.md) +* [GitRepository](https://github.com/fluxcd/source-controller/blob/master/docs/spec/v1beta1/gitrepositories.md) +* [Bucket](https://github.com/fluxcd/source-controller/blob/master/docs/spec/v1beta1/buckets.md) + +The `HelmChart` is created in the same namespace as the `sourceRef`, +with a name matching the `HelmRelease` `-`. + +The `chart.spec.chart` can either contain: + +* The name of the chart as made available by the `HelmRepository` + (without any aliases), for example: `podinfo` +* The relative path the chart can be found at in the `GitRepository`, + for example: `./charts/podinfo` + +The `chart.spec.version` can be a fixed semver, or any semver range +(i.e. `>=4.0.0 <5.0.0`). It is ignored for `HelmRelease` resources +that reference a `GitRepository` or `Bucket` source. + +## Values overrides + +The simplest way to define values overrides is inline via `spec.values`. +It is also possible to define a list of `ConfigMap` and `Secret` resources +from which to take values via `spec.valuesFrom`. The values are merged in the order given, +with the later values overwriting earlier, and then `spec.values` overwriting those: + +```yaml +spec: + values: + replicaCount: 2 + valuesFrom: + - kind: ConfigMap + name: prod-env-values + valuesKey: values-prod.yaml + - kind: Secret + name: prod-tls-values + valuesKey: crt + targetPath: tls.crt + optional: true +``` + +The definition of the listed keys for items in `spec.valuesFrom` is as follows: + +- `kind`: Kind of the values referent (`ConfigMap` or `Secret`). +- `name`: Name of the values referent, in the same namespace as the + `HelmRelease`. +- `valuesKey` _(Optional)_: The data key where the values.yaml or a + specific value can be found. Defaults to `values.yaml` when omitted. +- `targetPath` _(Optional)_: The YAML dot notation path at which the + value should be merged. When set, the `valuesKey` is expected to be + a single flat value. Defaults to `None` when omitted, which results + in the values getting merged at the root. +- `optional` _(Optional)_: Whether this values reference is optional. When `true`, + a not found error for the values reference is ignored, but any valuesKey, targetPath or + transient error will still result in a reconciliation failure. Defaults to `false` + when omitted. + +> **Note:** that the `targetPath` supports the same formatting as you would supply as an +> argument to the `helm` binary using `--set [path]=[value]`. In addition to this, the +> referred value can contain the same value formats (e.g. `{a,b,c}` for a list). You can +> read more about the available formats and limitations in the +> [Helm documentation](https://helm.sh/docs/intro/using_helm/#the-format-and-limitations-of---set). + +## Reconciliation + +If no Helm release with the matching namespace/name is found it will be installed. It will +be upgraded any time the desired state is updated, which consists of: + +* `spec` (and thus `metadata.generation`) +* Latest `HelmChart` revision available +* [`ConfigMap` and `Secret` values overrides](#values-overrides). Changes to these do not trigger an + immediate reconciliation, but will be handled upon the next reconciliation. This is to avoid + a large number of upgrades occurring when multiple resources are updated. + +If the latest Helm release revision was not made by the helm-controller, it may not match the +desired state, so an upgrade is made in this case as well. + +The `spec.interval` tells the reconciler at which interval to reconcile the release. The +interval time units are `s`, `m` and `h` e.g. `interval: 5m`, the minimum value should be 60 seconds. + +The reconciler can be told to reconcile the `HelmRelease` outside of the specified interval +by annotating the object with a `fluxcd.io/reconcileAt` annotation. For example: + +```bash +kubectl annotate --overwrite helmrelease/podinfo fluxcd.io/reconcileAt="$(date +%s)" +``` + +Reconciliation can be suspended by setting `spec.susped` to `true`. + +The timeout for any individual Kubernetes operation (like Jobs for hooks) during the performance +of Helm actions can be configured via `spec.timeout` and can be overridden per action +via `spec..timeout`. + +### Disabling resource waiting + +For install, upgrade, and rollback actions resource waiting is enabled by default, +but can be disabled by setting `spec..disableWait`. + +### `HelmRelease` dependencies + +When applying a `HelmRelease`, you may need to make sure other releases are [Ready](#status) +before the release is reconciled. For example, because your chart relies on the presence of +a Custom Resource Definition installed by another `HelmRelease`. The `spec.dependsOn` field +allows you to specify each of these dependencies. + +Assuming two `HelmRelease` resources: + +- `backend` - contains the backend of the application +- `frontend` - contains the frontend of the application and relies on the backend + +```yaml +apiVersion: helm.toolkit.fluxcd.io/v2beta1 +kind: HelmRelease +metadata: + name: backend +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 + values: + service: + grpcService: backend + resources: + requests: + cpu: 100m + memory: 64Mi +--- +apiVersion: helm.toolkit.fluxcd.io/v2beta1 +kind: HelmRelease +metadata: + name: frontend +spec: + interval: 5m + chart: + 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 + values: + backend: http://backend-podinfo:9898/echo + resources: + requests: + cpu: 100m + memory: 64Mi +``` + +> **Note** that this does not account for upgrade ordering. Kubernetes only allows +> applying one resource (`HelmRelease` in this case) at a time, so there is no way for the +> controller to know when a dependency `HelmRelease` may be updated. Also, circular +> dependencies between `HelmRelease` resources must be avoided, otherwise the +> interdependent `HelmRelease` resources will never be reconciled. + +### Configuring Helm test actions + +To make the controller run the Helm tests available for your chart after a successful Helm install +or upgrade, `spec.test.enable` should be set to `true`. + +By default, when tests are enabled, failures in tests are considered release failures, and thus +are subject to the triggering Helm action's `remediation` configuration. However, test failures +can be ignored by setting `spec.test.ignoreFailures` to `true`. In this case, no remediation will +be taken, and the test failure will not affect the `Released` and `Ready` status conditions. This +can be overridden per Helm action by setting `spec.install.remediation.ignoreTestFailures` +or `spec.upgrade.remediation.ignoreTestFailures`. + +```yaml +apiVersion: helm.toolkit.fluxcd.io/v2beta1 +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 + test: + enable: true + ignoreFailures: true + values: + resources: + requests: + cpu: 100m + memory: 64Mi +``` + +### Configuring failure remediation + +From time to time a Helm install/upgrade and accompanying [Helm test](#configuring-helm-test-actions) +may fail. When this occurs, by default no action is taken, and the release is left in a failed state. +However, several automatic failure remediation options can be set via +`spec.install.remediation` and `spec.upgrade.remediation`. + +The `retries` can be set to configure the number of retries after an initial +failure. A negative integer results in infinite retries. This implicitly opts-in to a remediation +action between each attempt. The remediation action for install failures is an uninstall. The +remediation action for upgrade failures is by default a rollback, however +`spec.upgrade.remediation.strategy` can be set to `uninstall`, in which case after the uninstall, +the `spec.install` configuration takes over. + +One can also opt-in to remediation of the last failure (when no retries remain) by setting +`spec..remediation.remediateLastFailure` to `true`. For upgrades, this defaults +to true if at least one retry is configured. + +```yaml +apiVersion: helm.fluxcd.io/v2beta1 +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 +``` + +## Status + +When the controller completes a reconciliation, it reports the result in the status sub-resource. + +The following `status.condtions` types are advertised. Here, "desired state" is as detailed in +[reconciliation](#reconciliation): + +* `Ready` - status of the last reconciliation attempt +* `Released` - status of the last release attempt (install/upgrade/test) against the latest desired state +* `TestSuccess` - status of the last test attempt against the latest desired state +* `Remediated` - status of the last remediation attempt (uninstall/rollback) due to a failure of the + last release attempt against the latest desired state + +For example, you can wait for a successful helm-controller reconciliation with: + +```sh +kubectl wait helmrelease/podinfo --for=condition=ready +``` + +Each of these conditions also include descriptive `reason` / `message` fields +as to why the status is as such. + +### Examples + +#### Install success + +```yaml +status: + conditions: + - lastTransitionTime: "2020-07-13T13:13:40Z" + message: Helm install succeeded + reason: InstallSucceeded + status: "True" + type: Released + - lastTransitionTime: "2020-07-13T13:13:40Z" + message: Helm test succeeded + reason: TestSucceeded + status: "True" + type: TestSuccess + - lastTransitionTime: "2020-07-13T13:13:42Z" + message: release reconciliation succeeded + reason: ReconciliationSucceeded + status: "True" + type: Ready + lastAppliedRevision: 4.0.6 + lastAttemptedRevision: 4.0.6 + lastReleaseRevision: 1 + observedGeneration: 2 +``` + +#### Upgrade failure + +```yaml +status: + conditions: + - lastTransitionTime: "2020-07-13T13:17:28Z" + message: 'error validating "": error validating data: ValidationError(Deployment.spec.replicas): + invalid type for io.k8s.api.apps.v1.DeploymentSpec.replicas: got "string", + expected "integer"' + reason: UpgradeFailed + status: "False" + type: Released + - lastTransitionTime: "2020-07-13T13:17:28Z" + message: 'error validating "": error validating data: ValidationError(Deployment.spec.replicas): + invalid type for io.k8s.api.apps.v1.DeploymentSpec.replicas: got "string", + expected "integer"' + reason: UpgradeFailed + status: "False" + type: Ready + failures: 1 + lastAppliedRevision: 4.0.6 + lastAttemptedRevision: 4.0.6 + lastReleaseRevision: 1 + observedGeneration: 3 +``` + +#### Ignored test failure + +```yaml +status: + conditions: + - lastTransitionTime: "2020-07-13T13:13:40Z" + message: Helm install succeeded + reason: InstallSucceeded + status: "True" + type: Released + - lastTransitionTime: "2020-07-13T13:13:40Z" + message: Helm test failed + reason: TestFailed + status: "False" + type: TestSuccess + - lastTransitionTime: "2020-07-13T13:13:42Z" + message: release reconciliation succeeded + reason: ReconciliationSucceeded + status: "True" + type: Ready + lastAppliedRevision: 4.0.6 + lastAttemptedRevision: 4.0.6 + lastReleaseRevision: 1 + observedGeneration: 2 +``` diff --git a/go.mod b/go.mod index 28e712aa9..c84fee740 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/fluxcd/helm-controller -go 1.14 +go 1.15 replace github.com/fluxcd/helm-controller/api => ./api @@ -9,7 +9,7 @@ require ( github.com/fluxcd/pkg/apis/meta v0.0.2 github.com/fluxcd/pkg/recorder v0.0.5 github.com/fluxcd/pkg/runtime v0.0.6 - github.com/fluxcd/source-controller/api v0.0.18 + github.com/fluxcd/source-controller/api v0.1.0 github.com/go-logr/logr v0.1.0 github.com/onsi/ginkgo v1.12.1 github.com/onsi/gomega v1.10.1 diff --git a/go.sum b/go.sum index bf43a8cfa..491077cea 100644 --- a/go.sum +++ b/go.sum @@ -196,12 +196,10 @@ github.com/fluxcd/pkg/apis/meta v0.0.2 h1:kyA4Y0IzNjf1joBOnFqpWG7aNDHvtLExZcaHQM github.com/fluxcd/pkg/apis/meta v0.0.2/go.mod h1:nCNps5JJOcEQr3MNDmZqI4o0chjePSUYL6Q2ktDtotU= 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/pkg/runtime v0.0.3 h1:x9rOThl1qh5srIUpW0YHEj1I84swMj5m76UqrR1QknY= -github.com/fluxcd/pkg/runtime v0.0.3/go.mod h1:ECBTeplxhgbCJYIjmtwn3ZS0A91/+6YtOS4w2G0LeK4= github.com/fluxcd/pkg/runtime v0.0.6 h1:m7qwr2wRePs1vzVlM0Y88vitXSsv1lb3QCJflRpa3qQ= github.com/fluxcd/pkg/runtime v0.0.6/go.mod h1:iLjncjktQVpqpb1NsY2fW+UYDFOtVyt+yJrxqrrK8A0= -github.com/fluxcd/source-controller/api v0.0.18 h1:9goqqsW3vhwO6Nxr8SNxIUW/5t1JL9cgIs4UctlaJVk= -github.com/fluxcd/source-controller/api v0.0.18/go.mod h1:PUe+EYQ/s+KPnz2iOCgdf+L6clM0SWkyvdXIpbfpkQE= +github.com/fluxcd/source-controller/api v0.1.0 h1:ky3gMs3mnkDl6ClX+7uT2BNxU+sLzW/6a8B/M1KfySw= +github.com/fluxcd/source-controller/api v0.1.0/go.mod h1:1ac/vj49YVPKF+xBHTo/9pfFj64TcLc1RLaxi4MwVEM= 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= @@ -987,8 +985,6 @@ k8s.io/utils v0.0.0-20200603063816-c1c6865ac451/go.mod h1:jPW/WVKK9YHAvNhRxK0md/ rsc.io/letsencrypt v0.0.3 h1:H7xDfhkaFFSYEJlKeq38RwX2jYcnTeHuDQyT+mMNMwM= 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.2 h1:jkAnfdTYBpFwlmBn3pS5HFO06SfxvnTZ1p5PeEF/zAA= -sigs.k8s.io/controller-runtime v0.6.2/go.mod h1:vhcq/rlnENJ09SIRp3EveTaZ0yqH526hjf9iJdbUJ/E= sigs.k8s.io/controller-runtime v0.6.3 h1:SBbr+inLPEKhvlJtrvDcwIpm+uhDvp63Bl72xYJtoOE= sigs.k8s.io/controller-runtime v0.6.3/go.mod h1:WlZNXcM0++oyaQt4B7C2lEE5JYRs8vJUzRP4N4JpdAY= sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0= diff --git a/internal/runner/runner.go b/internal/runner/runner.go index 53df4e714..15819d4c5 100644 --- a/internal/runner/runner.go +++ b/internal/runner/runner.go @@ -29,11 +29,11 @@ import ( "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/client-go/rest" - v2 "github.com/fluxcd/helm-controller/api/v2alpha1" + v2 "github.com/fluxcd/helm-controller/api/v2beta1" ) // Runner represents a Helm action runner capable of performing Helm -// operations for a v2alpha1.HelmRelease. +// operations for a v2beta1.HelmRelease. type Runner struct { config *action.Configuration } @@ -53,7 +53,7 @@ func NewRunner(clusterCfg *rest.Config, namespace string, logger logr.Logger) (* return &Runner{config: cfg}, nil } -// Install runs an Helm install action for the given v2alpha1.HelmRelease. +// Install runs an Helm install action for the given v2beta1.HelmRelease. func (r *Runner) Install(hr v2.HelmRelease, chart *chart.Chart, values chartutil.Values) (*release.Release, error) { install := action.NewInstall(r.config) install.ReleaseName = hr.GetReleaseName() @@ -68,7 +68,7 @@ func (r *Runner) Install(hr v2.HelmRelease, chart *chart.Chart, values chartutil return install.Run(chart, values.AsMap()) } -// Upgrade runs an Helm upgrade action for the given v2alpha1.HelmRelease. +// Upgrade runs an Helm upgrade action for the given v2beta1.HelmRelease. func (r *Runner) Upgrade(hr v2.HelmRelease, chart *chart.Chart, values chartutil.Values) (*release.Release, error) { upgrade := action.NewUpgrade(r.config) upgrade.Namespace = hr.GetReleaseNamespace() @@ -84,7 +84,7 @@ func (r *Runner) Upgrade(hr v2.HelmRelease, chart *chart.Chart, values chartutil return upgrade.Run(hr.GetReleaseName(), chart, values.AsMap()) } -// Test runs an Helm test action for the given v2alpha1.HelmRelease. +// Test runs an Helm test action for the given v2beta1.HelmRelease. func (r *Runner) Test(hr v2.HelmRelease) (*release.Release, error) { test := action.NewReleaseTesting(r.config) test.Namespace = hr.GetReleaseNamespace() @@ -93,7 +93,7 @@ func (r *Runner) Test(hr v2.HelmRelease) (*release.Release, error) { return test.Run(hr.GetReleaseName()) } -// Rollback runs an Helm rollback action for the given v2alpha1.HelmRelease. +// Rollback runs an Helm rollback action for the given v2beta1.HelmRelease. func (r *Runner) Rollback(hr v2.HelmRelease) error { rollback := action.NewRollback(r.config) rollback.Timeout = hr.Spec.GetRollback().GetTimeout(hr.GetTimeout()).Duration @@ -106,7 +106,7 @@ func (r *Runner) Rollback(hr v2.HelmRelease) error { return rollback.Run(hr.GetReleaseName()) } -// Uninstall runs an Helm uninstall action for the given v2alpha1.HelmRelease. +// Uninstall runs an Helm uninstall action for the given v2beta1.HelmRelease. func (r *Runner) Uninstall(hr v2.HelmRelease) error { uninstall := action.NewUninstall(r.config) uninstall.Timeout = hr.Spec.GetUninstall().GetTimeout(hr.GetTimeout()).Duration @@ -118,7 +118,7 @@ func (r *Runner) Uninstall(hr v2.HelmRelease) error { } // ObserveLastRelease observes the last revision, if there is one, -// for the actual Helm release associated with the given v2alpha1.HelmRelease. +// for the actual Helm release associated with the given v2beta1.HelmRelease. func (r *Runner) ObserveLastRelease(hr v2.HelmRelease) (*release.Release, error) { rel, err := r.config.Releases.Last(hr.GetReleaseName()) if err != nil && errors.Is(err, driver.ErrReleaseNotFound) { diff --git a/main.go b/main.go index 9b7f9cae1..1ed053173 100644 --- a/main.go +++ b/main.go @@ -31,9 +31,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log/zap" "github.com/fluxcd/pkg/recorder" - sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1" + sourcev1 "github.com/fluxcd/source-controller/api/v1beta1" - v2 "github.com/fluxcd/helm-controller/api/v2alpha1" + v2 "github.com/fluxcd/helm-controller/api/v2beta1" "github.com/fluxcd/helm-controller/controllers" // +kubebuilder:scaffold:imports )