k8c.io/api/v3@v3.0.0-20230904060738-b0a93889c0b6/pkg/apis/kubermatic/v1/ee.etcd_backup_config.go (about) 1 /* 2 Copyright 2023 The Kubermatic Kubernetes Platform contributors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package v1 18 19 import ( 20 corev1 "k8s.io/api/core/v1" 21 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 ) 23 24 // +kubebuilder:validation:Enum=Running;Completed;Failed 25 26 // EtcdBackupPhase is used to indicate the type of a EtcdBackupConfig condition. 27 // For all condition types, the `true` value must indicate success. 28 type EtcdBackupPhase string 29 30 const ( 31 // EtcdBackupPhaseRunning indicates that the corresponding job has started. 32 EtcdBackupPhaseRunning EtcdBackupPhase = "Running" 33 34 // EtcdBackupPhaseCompleted indicates that the corresponding job has completed successfully. 35 EtcdBackupPhaseCompleted EtcdBackupPhase = "Completed" 36 37 // EtcdBackupPhaseFailed indicates that the corresponding job has completed with an error. 38 EtcdBackupPhaseFailed EtcdBackupPhase = "Failed" 39 ) 40 41 // +kubebuilder:validation:Enum=SchedulingActive 42 43 // EtcdBackupConfigConditionType is used to indicate the type of a EtcdBackupConfig condition. For all condition 44 // types, the `true` value must indicate success. All condition types must be registered within 45 // the `AllClusterConditionTypes` variable. 46 type EtcdBackupConfigConditionType string 47 48 const ( 49 // EtcdBackupConfigConditionSchedulingActive indicates that the EtcdBackupConfig is active, i.e. 50 // new backups are being scheduled according to the config's schedule. 51 EtcdBackupConfigConditionSchedulingActive EtcdBackupConfigConditionType = "SchedulingActive" 52 ) 53 54 // +genclient 55 // +kubebuilder:object:generate=true 56 // +kubebuilder:resource:categories=kkpee 57 // +kubebuilder:object:root=true 58 // +kubebuilder:subresource:status 59 // +kubebuilder:printcolumn:JSONPath=".spec.cluster.name",name="Cluster",type="string" 60 // +kubebuilder:printcolumn:JSONPath=".metadata.creationTimestamp",name="Age",type="date" 61 62 // EtcdBackupConfig specifies the configuration for a usercluster etcd backup. 63 // 64 // Note that this resource is part of a KKP Enterprise feature and is not used in the Community Edition. 65 type EtcdBackupConfig struct { 66 metav1.TypeMeta `json:",inline"` 67 metav1.ObjectMeta `json:"metadata,omitempty"` 68 69 Spec EtcdBackupConfigSpec `json:"spec,omitempty"` 70 Status EtcdBackupConfigStatus `json:"status,omitempty"` 71 } 72 73 // EtcdBackupConfigSpec specifies details of an etcd backup. 74 type EtcdBackupConfigSpec struct { 75 // Name defines the name of the backup 76 // The name of the backup file in S3 will be <cluster>-<backup name> 77 // If a schedule is set (see below), -<timestamp> will be appended. 78 Name string `json:"name"` 79 // Cluster is the reference to the cluster whose etcd will be backed up. 80 Cluster ClusterReference `json:"cluster"` 81 // Schedule is a cron expression defining when to perform 82 // the backup. If not set, the backup is performed exactly 83 // once, immediately. 84 Schedule string `json:"schedule,omitempty"` 85 // Keep is the number of backups to keep around before deleting the oldest one 86 // If not set, defaults to DefaultKeptBackupsCount. Only used if Schedule is set. 87 Keep *int `json:"keep,omitempty"` 88 // Destination indicates where the backup will be stored. The destination name must correspond to a destination in 89 // the cluster's Seed.Spec.EtcdBackupRestore. 90 Destination string `json:"destination"` 91 } 92 93 // +kubebuilder:object:generate=true 94 // +kubebuilder:object:root=true 95 96 // EtcdBackupConfigList is a list of etcd backup configs. 97 type EtcdBackupConfigList struct { 98 metav1.TypeMeta `json:",inline"` 99 metav1.ListMeta `json:"metadata,omitempty"` 100 101 Items []EtcdBackupConfig `json:"items"` 102 } 103 104 type EtcdBackupConfigStatus struct { 105 // CurrentBackups tracks the creation and deletion progress of all backups managed by the EtcdBackupConfig 106 CurrentBackups []BackupStatus `json:"currentBackups,omitempty"` 107 // Conditions contains conditions of the EtcdBackupConfig 108 Conditions map[EtcdBackupConfigConditionType]EtcdBackupConfigCondition `json:"conditions,omitempty"` 109 // If the controller was configured with a cleanupContainer, CleanupRunning keeps track of the corresponding job 110 CleanupRunning bool `json:"cleanupRunning,omitempty"` 111 } 112 113 type BackupStatus struct { 114 // ScheduledTime will always be set when the BackupStatus is created, so it'll never be nil 115 // +optional 116 ScheduledTime metav1.Time `json:"scheduledTime,omitempty"` 117 BackupName string `json:"backupName,omitempty"` 118 JobName string `json:"jobName,omitempty"` 119 // +optional 120 BackupStartTime metav1.Time `json:"backupStartTime,omitempty"` 121 // +optional 122 BackupFinishedTime metav1.Time `json:"backupFinishedTime,omitempty"` 123 BackupPhase EtcdBackupPhase `json:"backupPhase,omitempty"` 124 BackupMessage string `json:"backupMessage,omitempty"` 125 DeleteJobName string `json:"deleteJobName,omitempty"` 126 // +optional 127 DeleteStartTime metav1.Time `json:"deleteStartTime,omitempty"` 128 // +optional 129 DeleteFinishedTime metav1.Time `json:"deleteFinishedTime,omitempty"` 130 DeletePhase EtcdBackupPhase `json:"deletePhase,omitempty"` 131 DeleteMessage string `json:"deleteMessage,omitempty"` 132 } 133 134 type EtcdBackupConfigCondition struct { 135 // Status of the condition, one of True, False, Unknown. 136 Status corev1.ConditionStatus `json:"status"` 137 // Last time we got an update on a given condition. 138 LastHeartbeatTime metav1.Time `json:"lastHeartbeatTime"` 139 // Last time the condition transit from one status to another. 140 // +optional 141 LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` 142 // (brief) reason for the condition's last transition. 143 // +optional 144 Reason string `json:"reason,omitempty"` 145 // Human readable message indicating details about last transition. 146 // +optional 147 Message string `json:"message,omitempty"` 148 }