Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

release: support skipping CRD installations for Helm v3 #282

Merged
merged 1 commit into from
Feb 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions chart/helm-operator/crds/helmrelease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ spec:
resetValues:
description: If supplied will reset values on helm upgrade
type: boolean
skipCRDs:
description: If set, will skip CRD installation for Helm v3
type: boolean
wait:
description: Wait for an upgrade to complete before marking release as successful
type: boolean
Expand Down
3 changes: 3 additions & 0 deletions deploy/flux-helm-release-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ spec:
resetValues:
description: If supplied will reset values on helm upgrade
type: boolean
skipCRDs:
description: If set, will skip CRD installation for Helm v3
type: boolean
wait:
description: Wait for an upgrade to complete before marking release as successful
type: boolean
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/helm.fluxcd.io/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ type HelmReleaseSpec struct {
// Reset values on helm upgrade
// +optional
ResetValues bool `json:"resetValues,omitempty"`
// Skip helm3 CRD installation
// +optional
SkipCRDs bool `json:"skipCRDs,omitempty"`
// Wait for the install or upgrade to complete before marking release as successful
// +optional
Wait bool `json:"wait,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions pkg/helm/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type UpgradeOptions struct {
ClientOnly bool
Force bool
ResetValues bool
SkipCRDs bool
ReuseValues bool
Recreate bool
MaxHistory int
Expand Down
1 change: 1 addition & 0 deletions pkg/helm/v3/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func (opts installOptions) configure(action *action.Install, releaseName string)
action.ClientOnly = opts.ClientOnly
action.Timeout = opts.Timeout
action.Wait = opts.Wait
action.SkipCRDs = opts.SkipCRDs
}

type upgradeOptions helm.UpgradeOptions
Expand Down
4 changes: 2 additions & 2 deletions pkg/install/generated_templates.gogen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pkg/install/templates/flux-helm-release-crd.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ spec:
resetValues:
description: If supplied will reset values on helm upgrade
type: boolean
skipCRDs:
description: If set, will skip CRD installation for Helm v3
type: boolean
wait:
description: Wait for an upgrade to complete before marking release as successful
type: boolean
Expand Down
1 change: 1 addition & 0 deletions pkg/release/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ func (r *Release) Sync(client helm.Client, hr *v1.HelmRelease) (rHr *v1.HelmRele
Install: curRel == nil,
Force: hr.Spec.ForceUpgrade,
ResetValues: hr.Spec.ResetValues,
SkipCRDs: hr.Spec.SkipCRDs,
MaxHistory: hr.GetMaxHistory(),
Wait: hr.Spec.Wait || (curRel != nil && hr.Spec.Rollback.Enable),
})
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/10_helm_chart.bats
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ function setup() {
poll_until_equals "gitconfig secret" "$GITCONFIG" "kubectl get secrets -n $E2E_NAMESPACE gitconfig -ojsonpath={..data.gitconfig} | base64 --decode"

# Apply the HelmRelease fixtures
kubectl apply -f "$FIXTURES_DIR/releases" >&3
kubectl apply -f "$FIXTURES_DIR/releases/git.yaml" >&3
hiddeco marked this conversation as resolved.
Show resolved Hide resolved
kubectl apply -f "$FIXTURES_DIR/releases/helm-repository.yaml" >&3

poll_until_equals 'podinfo-helm-repository HelmRelease' 'deployed' "kubectl -n $DEMO_NAMESPACE get helmrelease/podinfo-helm-repository -o 'custom-columns=status:status.releaseStatus' --no-headers"
poll_until_equals 'podinfo-git HelmRelease' 'deployed' "kubectl -n $DEMO_NAMESPACE get helmrelease/podinfo-git -o 'custom-columns=status:status.releaseStatus' --no-headers"
Expand Down
42 changes: 42 additions & 0 deletions test/e2e/35_skip_crds.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bats

function setup() {
# Load libraries in setup() to access BATS_* variables
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copying and pasting e2e to get going makes me feel dirty... I will have a look at what common stuff we can extract out at some point to make it easier to get started.

load lib/env
load lib/install
load lib/poll

kubectl create namespace "$E2E_NAMESPACE"
install_git_srv
install_tiller
install_helm_operator_with_helm
kubectl create namespace "$DEMO_NAMESPACE"
}

@test "When skipCRDs is set" {
if [ "$HELM_VERSION" != "v3" ]; then
skip
fi

# Apply the HelmRelease
kubectl apply -f "$FIXTURES_DIR/releases/skip-crd.yaml" >&3
poll_until_equals 'skip-crd HelmRelease' 'deployed' "kubectl -n $DEMO_NAMESPACE get helmrelease/skip-crd -o 'custom-columns=status:status.releaseStatus' --no-headers"

# Assert no CRDs were installed
count=$(kubectl get crd --no-headers | grep 'konghq.com' | wc -l)
[ "$count" -eq 0 ]
}

function teardown() {
# Teardown is verbose when a test fails, and this will help most of the time
# to determine _why_ it failed.
kubectl logs -n "$E2E_NAMESPACE" deploy/helm-operator

# Removing the operator also takes care of the global resources it installs.
uninstall_helm_operator_with_helm
uninstall_tiller
# Removing the namespace also takes care of removing gitsrv.
kubectl delete namespace "$E2E_NAMESPACE"
# Only remove the demo workloads after the operator, so that they cannot be recreated.
kubectl delete namespace "$DEMO_NAMESPACE"
}
Loading