Skip to content
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
29 changes: 29 additions & 0 deletions api/v1beta1/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,24 @@ const (
PostRenderStrategyNoHooks = PostRenderStrategy("nohooks")
)

// ExistingCRDsPolicy controls what happens when a Helm chart is installed and one of the
// CRDs in the chart's crds/ directory already exists in the cluster with a different definition.
// +kubebuilder:validation:Enum:=Skip;Fail;Overwrite
type ExistingCRDsPolicy string

const (
// ExistingCRDsPolicySkip leaves the existing CRD as it is and carries on with the
// remaining CRDs of the chart. CRDs not yet in the cluster are created.
ExistingCRDsPolicySkip = ExistingCRDsPolicy("Skip")

// ExistingCRDsPolicyFail fails the installation, reporting the CRDs that differ.
// No CRD of the chart is created or changed.
ExistingCRDsPolicyFail = ExistingCRDsPolicy("Fail")

// ExistingCRDsPolicyOverwrite applies the CRD of the chart over the existing one.
ExistingCRDsPolicyOverwrite = ExistingCRDsPolicy("Overwrite")
)

type HelmOptions struct {
// SkipCRDs controls whether CRDs should be installed during install/upgrade operation.
// By default, CRDs are installed if not already present.
Expand Down Expand Up @@ -307,6 +325,17 @@ type HelmInstallOptions struct {
// +optional
TakeOwnership bool `json:"takeOwnership,omitempty"`

// ExistingCRDs controls what happens when a CRD in the chart's crds/ directory (subcharts
// included) already exists in the cluster with a different definition. CRDs not yet in the
// cluster are always created. Ignored when SkipCRDs is true.
// Fail fails the installation and reports the CRDs that differ. No CRD is created or changed.
// Skip leaves the existing CRD as it is, logs it and carries on with the rest of the chart.
// Overwrite applies the CRD of the chart over the existing one.
// Default to Fail
// +kubebuilder:default:=Fail
// +optional
ExistingCRDs ExistingCRDsPolicy `json:"existingCRDs,omitempty"`

// RecoverAfterConsecutiveFailures is the number of consecutive install failures for this
// chart after which Sveltos uninstalls any existing release under this name before
// retrying, to clear potentially stale Helm release history that would otherwise keep
Expand Down
15 changes: 15 additions & 0 deletions config/crd/bases/config.projectsveltos.io_clusterprofiles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,21 @@ spec:
disable hooks on install
Default to false
type: boolean
existingCRDs:
default: Fail
description: |-
ExistingCRDs controls what happens when a CRD in the chart's crds/ directory (subcharts
included) already exists in the cluster with a different definition. CRDs not yet in the
cluster are always created. Ignored when SkipCRDs is true.
Fail fails the installation and reports the CRDs that differ. No CRD is created or changed.
Skip leaves the existing CRD as it is, logs it and carries on with the rest of the chart.
Overwrite applies the CRD of the chart over the existing one.
Default to Fail
enum:
- Skip
- Fail
- Overwrite
type: string
recoverAfterConsecutiveFailures:
default: 5
description: |-
Expand Down
15 changes: 15 additions & 0 deletions config/crd/bases/config.projectsveltos.io_clusterpromotions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,21 @@ spec:
disable hooks on install
Default to false
type: boolean
existingCRDs:
default: Fail
description: |-
ExistingCRDs controls what happens when a CRD in the chart's crds/ directory (subcharts
included) already exists in the cluster with a different definition. CRDs not yet in the
cluster are always created. Ignored when SkipCRDs is true.
Fail fails the installation and reports the CRDs that differ. No CRD is created or changed.
Skip leaves the existing CRD as it is, logs it and carries on with the rest of the chart.
Overwrite applies the CRD of the chart over the existing one.
Default to Fail
enum:
- Skip
- Fail
- Overwrite
type: string
recoverAfterConsecutiveFailures:
default: 5
description: |-
Expand Down
15 changes: 15 additions & 0 deletions config/crd/bases/config.projectsveltos.io_clustersummaries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,21 @@ spec:
disable hooks on install
Default to false
type: boolean
existingCRDs:
default: Fail
description: |-
ExistingCRDs controls what happens when a CRD in the chart's crds/ directory (subcharts
included) already exists in the cluster with a different definition. CRDs not yet in the
cluster are always created. Ignored when SkipCRDs is true.
Fail fails the installation and reports the CRDs that differ. No CRD is created or changed.
Skip leaves the existing CRD as it is, logs it and carries on with the rest of the chart.
Overwrite applies the CRD of the chart over the existing one.
Default to Fail
enum:
- Skip
- Fail
- Overwrite
type: string
recoverAfterConsecutiveFailures:
default: 5
description: |-
Expand Down
15 changes: 15 additions & 0 deletions config/crd/bases/config.projectsveltos.io_profiles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,21 @@ spec:
disable hooks on install
Default to false
type: boolean
existingCRDs:
default: Fail
description: |-
ExistingCRDs controls what happens when a CRD in the chart's crds/ directory (subcharts
included) already exists in the cluster with a different definition. CRDs not yet in the
cluster are always created. Ignored when SkipCRDs is true.
Fail fails the installation and reports the CRDs that differ. No CRD is created or changed.
Skip leaves the existing CRD as it is, logs it and carries on with the rest of the chart.
Overwrite applies the CRD of the chart over the existing one.
Default to Fail
enum:
- Skip
- Fail
- Overwrite
type: string
recoverAfterConsecutiveFailures:
default: 5
description: |-
Expand Down
10 changes: 7 additions & 3 deletions controllers/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,13 @@ var (
)

var (
IsCRDEstablished = isCRDEstablished
GetCRDObjects = getCRDObjects
GetHelmUpgradeClient = getHelmUpgradeClient
IsCRDEstablished = isCRDEstablished
GetCRDObjects = getCRDObjects
GetExistingCRDsPolicy = getExistingCRDsPolicy
InstallMissingCRDs = installMissingCRDs
InstallChartCRDs = installChartCRDs
WithRestConfig = withRestConfig
GetHelmUpgradeClient = getHelmUpgradeClient
)

type (
Expand Down
Loading
Loading