Skip to content
Closed
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
89 changes: 89 additions & 0 deletions api/v1/checkpointschedule_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
Copyright 2026.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1

import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

type CheckpointIntent string

const (
Backup CheckpointIntent = "Backup"
PodDisruption CheckpointIntent = "PodDisruption"
ResourcePressure CheckpointIntent = "ResourcePressure"
Manual CheckpointIntent = "Manual"
)

type CheckpointScheduleSpec struct {
Namespace string `json:"namespace"`
Selector metav1.LabelSelector `json:"selector"`
ContainerNames []string `json:"containerNames,omitempty"`
Intent CheckpointIntent `json:"intent"`
Triggers TriggersSpec `json:"triggers"`
}

type TriggersSpec struct {
Schedule string `json:"schedule,omitempty"`
ResourceThreshold *ResourceThresholdSpec `json:"resourceThreshold,omitempty"`
OnKubernetesEvents []string `json:"onKubernetesEvents,omitempty"`
OnAnnotation bool `json:"onAnnotation,omitempty"`
}

// ResourcePercentThreshold defines upper and lower percentage bounds for a resource.
type ResourcePercentThreshold struct {
Upper *int `json:"upper,omitempty"`
Lower *int `json:"lower,omitempty"`
}

type ResourceThresholdSpec struct {
CPUPercent *ResourcePercentThreshold `json:"cpuPercent,omitempty"`
MemoryPercent *ResourcePercentThreshold `json:"memoryPercent,omitempty"`
PollIntervalSeconds *int `json:"pollIntervalSeconds,omitempty"`
}

// CheckpointScheduleStatus defines the observed state of CheckpointSchedule
type CheckpointScheduleStatus struct {
LastCheckpointTime *metav1.Time `json:"lastCheckpointTime,omitempty"`
CheckpointsCreated int `json:"checkpointsCreated,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// CheckpointSchedule is the Schema for the checkpointschedules API
type CheckpointSchedule struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec CheckpointScheduleSpec `json:"spec,omitempty"`
Status CheckpointScheduleStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// CheckpointScheduleList contains a list of CheckpointSchedule
type CheckpointScheduleList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []CheckpointSchedule `json:"items"`
}

func init() {
SchemeBuilder.Register(&CheckpointSchedule{}, &CheckpointScheduleList{})
}
188 changes: 188 additions & 0 deletions api/v1/zz_generated.deepcopy.go

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

8 changes: 8 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "CheckpointRestoreOperator")
os.Exit(1)
}
if err = (&controller.CheckpointScheduleReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
RestConfig: mgr.GetConfig(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "CheckpointSchedule")
os.Exit(1)
}
//+kubebuilder:scaffold:builder

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
Expand Down
Loading