Skip to content
Draft
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
11 changes: 11 additions & 0 deletions api/v1alpha1/condition_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,20 @@ const (
// ClusterSelectionFailedReason indicates that the HelmChartProxy controller failed to select the workload Clusters.
ClusterSelectionFailedReason = "ClusterSelectionFailed"

// HelmReleaseProxiesRolloutNotCompleteReason indicates that the initial rollout
// of HelmReleaseProxies has not been completed.
HelmReleaseProxiesRolloutNotCompleteReason = "HelmReleaseProxiesRolloutNotComplete"

// HelmReleaseProxiesRolloutUndefinedReason indicates that HelmChartProxy doesn't
// use Rollout Step Size to reconcile HelmReleaseProxies.
HelmReleaseProxiesRolloutUndefinedReason = "HelmReleaseProxiesRolloutUndefined"

// HelmReleaseProxiesReadyCondition indicates that the HelmReleaseProxies are ready, meaning that the Helm installation, upgrade
// or deletion is complete.
HelmReleaseProxiesReadyCondition clusterv1.ConditionType = "HelmReleaseProxiesReady"

// HelmReleaseProxiesRolloutCompletedCondition indicates if the initial rollout of HelmReleaseProxies is complete.
HelmReleaseProxiesRolloutCompletedCondition clusterv1.ConditionType = "HelmReleaseProxiesRolloutCompleted"
)

// HelmReleaseProxy Conditions and Reasons.
Expand Down
55 changes: 55 additions & 0 deletions api/v1alpha1/helmchartproxy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package v1alpha1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

Expand Down Expand Up @@ -84,6 +85,13 @@ type HelmChartProxySpec struct {
// +optional
ReconcileStrategy string `json:"reconcileStrategy,omitempty"`

// Rollout is used to define install and upgrade level rollout options that
// will be used when rolling out HelmReleaseProxy resources changes. If
// undefined, it defaults to no rollout; i.e it applies changes to all
// matching clusters at once.
// +optional
Rollout *Rollout `json:"rollout,omitempty"`

// Options represents CLI flags passed to Helm operations (i.e. install, upgrade, delete) and
// include options such as wait, skipCRDs, timeout, waitForJobs, etc.
// +optional
Expand All @@ -98,6 +106,46 @@ type HelmChartProxySpec struct {
TLSConfig *TLSConfig `json:"tlsConfig,omitempty"`
}

// Rollout defines install and upgrade level rollout options when rolling out
// HelmReleaseProxy resource changes.
type Rollout struct {
// Install rollout options. If left empty, it defaults to no rollout; i.e. it
// applies changes to all matching clusters at once.
// +optional
Install *RolloutOptions `json:"install,omitempty"`

// Upgrade rollout options. If left empty, it defaults to no rollout; i.e. it
// applies changes to all matching clusters at once.
// +optional
Upgrade *RolloutOptions `json:"upgrade,omitempty"`
}

// RolloutOptions defines rollout options to be used when rolling out
// HelmReleaseProxy resource changes.
type RolloutOptions struct {
// StepInit defines the initial step to start from during rollout.
// e.g. an int (5) or percentage of count of total matching clusters (25%)
StepInit *intstr.IntOrString `json:"stepInit"`

// StepIncrement defines the increment to be added to existing stepSize
// during rollout.
// If StepIncrement is undefined, step size is set to stepInit.
// e.g. an int (5) or percentage of count of total matching clusters (25%)
// +optional
StepIncrement *intstr.IntOrString `json:"stepIncrement,omitempty"`

// StepLimit defines the upper limit on stepSize during rollout.
// If defined and computes to less than stepInit, step size can reach 100%;
// meaning that no upper limit is set.
// If stepIncrement is defined and stepLimit is omitted, step size can reach
// 100%; meaning that no upper limit is set.
// If StepIncrement is undefined and if stepLimit is omitted, step size is
// defaulted to the value computed from stepInit.
// e.g. an int (5) or percentage of count of total matching clusters (25%)
// +optional
StepLimit *intstr.IntOrString `json:"stepLimit,omitempty"`
}

type HelmOptions struct {
// DisableHooks prevents hooks from running during the Helm install action.
// +optional
Expand Down Expand Up @@ -238,6 +286,11 @@ type TLSConfig struct {
InsecureSkipTLSVerify bool `json:"insecureSkipTLSVerify,omitempty"`
}

type RolloutStatus struct {
Count *int `json:"count,omitempty"`
StepSize *int `json:"stepSize,omitempty"`
}

// HelmChartProxyStatus defines the observed state of HelmChartProxy.
type HelmChartProxyStatus struct {
// Conditions defines current state of the HelmChartProxy.
Expand All @@ -248,6 +301,8 @@ type HelmChartProxyStatus struct {
// +optional
MatchingClusters []corev1.ObjectReference `json:"matchingClusters"`

Rollout *RolloutStatus `json:"rollout,omitempty"`

// ObservedGeneration is the latest generation observed by the controller.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
Expand Down
91 changes: 91 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

95 changes: 95 additions & 0 deletions config/crd/bases/addons.cluster.x-k8s.io_helmchartproxies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,94 @@ spec:
RepoURL is the URL of the Helm chart repository.
e.g. chart-path oci://repo-url/chart-name as repoURL: oci://repo-url and https://repo-url/chart-name as repoURL: https://repo-url
type: string
rollout:
description: |-
Rollout is used to define install and upgrade level rollout options that
will be used when rolling out HelmReleaseProxy resources changes. If
undefined, it defaults to no rollout; i.e it applies changes to all
matching clusters at once.
properties:
install:
description: |-
Install rollout options. If left empty, it defaults to no rollout; i.e. it
applies changes to all matching clusters at once.
properties:
stepIncrement:
anyOf:
- type: integer
- type: string
description: |-
StepIncrement defines the increment to be added to existing stepSize
during rollout.
If StepIncrement is undefined, step size is set to stepInit.
e.g. an int (5) or percentage of count of total matching clusters (25%)
x-kubernetes-int-or-string: true
stepInit:
anyOf:
- type: integer
- type: string
description: |-
StepInit defines the initial step to start from during rollout.
e.g. an int (5) or percentage of count of total matching clusters (25%)
x-kubernetes-int-or-string: true
stepLimit:
anyOf:
- type: integer
- type: string
description: |-
StepLimit defines the upper limit on stepSize during rollout.
If defined and computes to less than stepInit, step size can reach 100%;
meaning that no upper limit is set.
If stepIncrement is defined and stepLimit is omitted, step size can reach
100%; meaning that no upper limit is set.
If StepIncrement is undefined and if stepLimit is omitted, step size is
defaulted to the value computed from stepInit.
e.g. an int (5) or percentage of count of total matching clusters (25%)
x-kubernetes-int-or-string: true
required:
- stepInit
type: object
upgrade:
description: |-
Upgrade rollout options. If left empty, it defaults to no rollout; i.e. it
applies changes to all matching clusters at once.
properties:
stepIncrement:
anyOf:
- type: integer
- type: string
description: |-
StepIncrement defines the increment to be added to existing stepSize
during rollout.
If StepIncrement is undefined, step size is set to stepInit.
e.g. an int (5) or percentage of count of total matching clusters (25%)
x-kubernetes-int-or-string: true
stepInit:
anyOf:
- type: integer
- type: string
description: |-
StepInit defines the initial step to start from during rollout.
e.g. an int (5) or percentage of count of total matching clusters (25%)
x-kubernetes-int-or-string: true
stepLimit:
anyOf:
- type: integer
- type: string
description: |-
StepLimit defines the upper limit on stepSize during rollout.
If defined and computes to less than stepInit, step size can reach 100%;
meaning that no upper limit is set.
If stepIncrement is defined and stepLimit is omitted, step size can reach
100%; meaning that no upper limit is set.
If StepIncrement is undefined and if stepLimit is omitted, step size is
defaulted to the value computed from stepInit.
e.g. an int (5) or percentage of count of total matching clusters (25%)
x-kubernetes-int-or-string: true
required:
- stepInit
type: object
type: object
tlsConfig:
description: TLSConfig contains the TLS configuration for a HelmChartProxy.
properties:
Expand Down Expand Up @@ -424,6 +512,13 @@ spec:
by the controller.
format: int64
type: integer
rollout:
properties:
count:
type: integer
stepSize:
type: integer
type: object
type: object
type: object
served: true
Expand Down
20 changes: 20 additions & 0 deletions config/samples/withrollout.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: addons.cluster.x-k8s.io/v1alpha1
kind: HelmChartProxy
metadata:
name: metallb
spec:
rollout:
install:
stepInit: 10%
stepIncrement: 5%
stepLimit: 25%
upgrade:
stepInit: 10%
stepIncrement: 5%
stepLimit: 25%
clusterSelector:
matchLabels:
MetalLBChart: enabled
repoURL: https://metallb.github.io/metallb
chartName: metallb
releaseName: metallb
Loading