k8c.io/api/v3@v3.0.0-20230904060738-b0a93889c0b6/pkg/apis/kubermatic/v1/ee.etcd_restore.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  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    21  )
    22  
    23  // +kubebuilder:validation:Enum=Started;StsRebuilding;Completed;EtcdLauncherNotEnabled
    24  
    25  // EtcdRestorePhase represents the lifecycle phase of an EtcdRestore.
    26  type EtcdRestorePhase string
    27  
    28  const (
    29  	// EtcdRestorePhaseStarted indicates that the restore has started.
    30  	EtcdRestorePhaseStarted EtcdRestorePhase = "Started"
    31  
    32  	// EtcdRestorePhaseStsRebuilding indicates that the old Etcd statefulset has been deleted and is now rebuilding.
    33  	EtcdRestorePhaseStsRebuilding EtcdRestorePhase = "StsRebuilding"
    34  
    35  	// EtcdRestorePhaseCompleted indicates that the old Etcd statefulset has completed successfully.
    36  	EtcdRestorePhaseCompleted EtcdRestorePhase = "Completed"
    37  
    38  	// EtcdRestorePhaseEtcdLauncherNotEnabled indicates that etcd-launcher is not enabled.
    39  	EtcdRestorePhaseEtcdLauncherNotEnabled EtcdRestorePhase = "EtcdLauncherNotEnabled"
    40  )
    41  
    42  // +genclient
    43  // +kubebuilder:object:generate=true
    44  // +kubebuilder:resource:categories=kkpee
    45  // +kubebuilder:object:root=true
    46  // +kubebuilder:subresource:status
    47  // +kubebuilder:printcolumn:JSONPath=".spec.cluster.name",name="Cluster",type="string"
    48  // +kubebuilder:printcolumn:JSONPath=".status.phase",name="Phase",type="string"
    49  // +kubebuilder:printcolumn:JSONPath=".metadata.creationTimestamp",name="Age",type="date"
    50  
    51  // EtcdRestore specifies how to restore an etcd backup for a usercluster.
    52  //
    53  // Note that this resource is part of a KKP Enterprise feature and is not used in the Community Edition.
    54  type EtcdRestore struct {
    55  	metav1.TypeMeta   `json:",inline"`
    56  	metav1.ObjectMeta `json:"metadata,omitempty"`
    57  
    58  	Spec   EtcdRestoreSpec   `json:"spec,omitempty"`
    59  	Status EtcdRestoreStatus `json:"status,omitempty"`
    60  }
    61  
    62  // EtcdRestoreSpec specifies details of an etcd restore.
    63  type EtcdRestoreSpec struct {
    64  	// Cluster is the reference to the cluster whose etcd will be backed up.
    65  	Cluster ClusterReference `json:"cluster"`
    66  	// BackupName is the name of the backup to restore from
    67  	BackupName string `json:"backupName"`
    68  	// BackupDownloadCredentialsSecret is the name of a secret in the cluster-xxx namespace containing
    69  	// credentials needed to download the backup
    70  	BackupDownloadCredentialsSecret string `json:"backupDownloadCredentialsSecret,omitempty"`
    71  	// Destination indicates where the backup was stored. The destination name should correspond to a destination in
    72  	// the cluster's Seed.Spec.EtcdBackupRestore. If empty, it will use the legacy destination configured in Seed.Spec.BackupRestore
    73  	Destination string `json:"destination,omitempty"`
    74  }
    75  
    76  // +kubebuilder:object:generate=true
    77  // +kubebuilder:object:root=true
    78  
    79  // EtcdRestoreList is a list of etcd restores.
    80  type EtcdRestoreList struct {
    81  	metav1.TypeMeta `json:",inline"`
    82  	metav1.ListMeta `json:"metadata,omitempty"`
    83  
    84  	Items []EtcdRestore `json:"items"`
    85  }
    86  
    87  type EtcdRestoreStatus struct {
    88  	Phase EtcdRestorePhase `json:"phase"`
    89  	// +optional
    90  	RestoreTime metav1.Time `json:"restoreTime,omitempty"`
    91  }