Skip to content

Commit

Permalink
Merge pull request #339 from gianlucam76/window
Browse files Browse the repository at this point in the history
(feat): Add optional schedule for pausing and unpausing the cluster.
  • Loading branch information
gianlucam76 authored Jul 28, 2024
2 parents 6666774 + 84f4232 commit 3f91322
Show file tree
Hide file tree
Showing 8 changed files with 325 additions and 0 deletions.
25 changes: 25 additions & 0 deletions api/v1alpha1/sveltoscluster_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ const (
SveltosClusterKind = "SveltosCluster"
)

type ActiveWindow struct {
// From in Cron format, see https://en.wikipedia.org/wiki/Cron.
// Indicates when to un-pause the cluster (cluster in paused state receives no update from sveltos).
// +kubebuilder:validation:MinLength=1
From string `json:"from"`

// To in Cron format, see https://en.wikipedia.org/Cron.
// Indicates when to pause the cluster (cluster in paused state receives no update from sveltos).
// +kubebuilder:validation:MinLength=1
To string `json:"to"`
}

type TokenRequestRenewalOption struct {
// RenewTokenRequestInterval is the interval at which to renew the TokenRequest
RenewTokenRequestInterval metav1.Duration `json:"renewTokenRequestInterval"`
Expand All @@ -50,6 +62,11 @@ type SveltosClusterSpec struct {
// ArbitraryData allows for arbitrary nested structures
// +optional
ArbitraryData map[string]string `json:"data,omitempty"`

// ActiveWindow is an optional field for automatically pausing and unpausing
// the cluster.
// If not specified, the cluster will not be paused or unpaused automatically.
ActiveWindow *ActiveWindow `json:"activeWindow,omitempty"`
}

// SveltosClusterStatus defines the status of SveltosCluster
Expand All @@ -71,6 +88,14 @@ type SveltosClusterStatus struct {
// was renewed.
// +optional
LastReconciledTokenRequestAt string `json:"lastReconciledTokenRequestAt,omitempty"`

// Information when next unpause cluster is scheduled
// +optional
NextUnpause *metav1.Time `json:"nextUnpause,omitempty"`

// Information when next pause cluster is scheduled
// +optional
NextPause *metav1.Time `json:"nextPause,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
39 changes: 39 additions & 0 deletions api/v1alpha1/zz_generated.conversion.go

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

28 changes: 28 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.

25 changes: 25 additions & 0 deletions api/v1beta1/sveltoscluster_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ const (
SveltosClusterKind = "SveltosCluster"
)

type ActiveWindow struct {
// From in Cron format, see https://en.wikipedia.org/wiki/Cron.
// Indicates when to un-pause the cluster (cluster in paused state receives no update from sveltos).
// +kubebuilder:validation:MinLength=1
From string `json:"from"`

// To in Cron format, see https://en.wikipedia.org/Cron.
// Indicates when to pause the cluster (cluster in paused state receives no update from sveltos).
// +kubebuilder:validation:MinLength=1
To string `json:"to"`
}

type TokenRequestRenewalOption struct {
// RenewTokenRequestInterval is the interval at which to renew the TokenRequest
RenewTokenRequestInterval metav1.Duration `json:"renewTokenRequestInterval"`
Expand All @@ -50,6 +62,11 @@ type SveltosClusterSpec struct {
// ArbitraryData allows for arbitrary nested structures
// +optional
ArbitraryData map[string]string `json:"data,omitempty"`

// ActiveWindow is an optional field for automatically pausing and unpausing
// the cluster.
// If not specified, the cluster will not be paused or unpaused automatically.
ActiveWindow *ActiveWindow `json:"activeWindow,omitempty"`
}

// SveltosClusterStatus defines the status of SveltosCluster
Expand All @@ -71,6 +88,14 @@ type SveltosClusterStatus struct {
// was renewed.
// +optional
LastReconciledTokenRequestAt string `json:"lastReconciledTokenRequestAt,omitempty"`

// Information when next unpause cluster is scheduled
// +optional
NextUnpause *metav1.Time `json:"nextUnpause,omitempty"`

// Information when next pause cluster is scheduled
// +optional
NextPause *metav1.Time `json:"nextPause,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
28 changes: 28 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

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

60 changes: 60 additions & 0 deletions config/crd/bases/lib.projectsveltos.io_sveltosclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,28 @@ spec:
spec:
description: SveltosClusterSpec defines the desired state of SveltosCluster
properties:
activeWindow:
description: |-
ActiveWindow is an optional field for automatically pausing and unpausing
the cluster.
If not specified, the cluster will not be paused or unpaused automatically.
properties:
from:
description: |-
From in Cron format, see https://en.wikipedia.org/wiki/Cron.
Indicates when to un-pause the cluster (cluster in paused state receives no update from sveltos).
minLength: 1
type: string
to:
description: |-
To in Cron format, see https://en.wikipedia.org/Cron.
Indicates when to pause the cluster (cluster in paused state receives no update from sveltos).
minLength: 1
type: string
required:
- from
- to
type: object
data:
additionalProperties:
type: string
Expand Down Expand Up @@ -92,6 +114,14 @@ spec:
LastReconciledTokenRequestAt is the last time the TokenRequest
was renewed.
type: string
nextPause:
description: Information when next pause cluster is scheduled
format: date-time
type: string
nextUnpause:
description: Information when next unpause cluster is scheduled
format: date-time
type: string
ready:
description: Ready is the state of the cluster.
type: boolean
Expand Down Expand Up @@ -138,6 +168,28 @@ spec:
spec:
description: SveltosClusterSpec defines the desired state of SveltosCluster
properties:
activeWindow:
description: |-
ActiveWindow is an optional field for automatically pausing and unpausing
the cluster.
If not specified, the cluster will not be paused or unpaused automatically.
properties:
from:
description: |-
From in Cron format, see https://en.wikipedia.org/wiki/Cron.
Indicates when to un-pause the cluster (cluster in paused state receives no update from sveltos).
minLength: 1
type: string
to:
description: |-
To in Cron format, see https://en.wikipedia.org/Cron.
Indicates when to pause the cluster (cluster in paused state receives no update from sveltos).
minLength: 1
type: string
required:
- from
- to
type: object
data:
additionalProperties:
type: string
Expand Down Expand Up @@ -182,6 +234,14 @@ spec:
LastReconciledTokenRequestAt is the last time the TokenRequest
was renewed.
type: string
nextPause:
description: Information when next pause cluster is scheduled
format: date-time
type: string
nextUnpause:
description: Information when next unpause cluster is scheduled
format: date-time
type: string
ready:
description: Ready is the state of the cluster.
type: boolean
Expand Down
Loading

0 comments on commit 3f91322

Please sign in to comment.