github.com/rancher/types@v0.0.0-20220328215343-4370ff10ecd5/apis/management.cattle.io/v3/backup_types.go (about)

     1  package v3
     2  
     3  import (
     4  	"github.com/rancher/norman/condition"
     5  	"github.com/rancher/norman/types"
     6  	v1 "k8s.io/api/core/v1"
     7  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
     8  )
     9  
    10  const (
    11  	BackupConditionCreated   condition.Cond = "Created"
    12  	BackupConditionCompleted condition.Cond = "Completed"
    13  )
    14  
    15  type BackupConfig struct {
    16  	// Enable or disable recurring backups in rancher
    17  	Enabled *bool `yaml:"enabled" json:"enabled,omitempty" norman:"default=true"`
    18  	// Backup interval in hours
    19  	IntervalHours int `yaml:"interval_hours" json:"intervalHours,omitempty" norman:"default=12"`
    20  	// Number of backups to keep
    21  	Retention int `yaml:"retention" json:"retention,omitempty" norman:"default=6"`
    22  	// s3 target
    23  	S3BackupConfig *S3BackupConfig `yaml:",omitempty" json:"s3BackupConfig"`
    24  	// replace special characters in snapshot names
    25  	SafeTimestamp bool `yaml:"safe_timestamp" json:"safeTimestamp,omitempty"`
    26  	// Backup execution timeout
    27  	Timeout int `yaml:"timeout" json:"timeout,omitempty" norman:"default=300"`
    28  }
    29  
    30  type S3BackupConfig struct {
    31  	// Access key ID
    32  	AccessKey string `yaml:"access_key" json:"accessKey,omitempty"`
    33  	// Secret access key
    34  	SecretKey string `yaml:"secret_key" json:"secretKey,omitempty" norman:"type=password" `
    35  	// name of the bucket to use for backup
    36  	BucketName string `yaml:"bucket_name" json:"bucketName,omitempty"`
    37  	// AWS Region, AWS spcific
    38  	Region string `yaml:"region" json:"region,omitempty"`
    39  	// Endpoint is used if this is not an AWS API
    40  	Endpoint string `yaml:"endpoint" json:"endpoint"`
    41  	// CustomCA is used to connect to custom s3 endpoints
    42  	CustomCA string `yaml:"custom_ca" json:"customCa,omitempty"`
    43  	// Folder to place the files
    44  	Folder string `yaml:"folder" json:"folder,omitempty"`
    45  }
    46  type EtcdBackup struct {
    47  	types.Namespaced
    48  
    49  	metav1.TypeMeta   `json:",inline"`
    50  	metav1.ObjectMeta `json:"metadata,omitempty"`
    51  
    52  	// backup spec
    53  	Spec EtcdBackupSpec `json:"spec"`
    54  	// backup status
    55  	Status EtcdBackupStatus `yaml:"status" json:"status,omitempty"`
    56  }
    57  
    58  type EtcdBackupSpec struct {
    59  	// cluster ID
    60  	ClusterID string `json:"clusterId,omitempty" norman:"required,type=reference[cluster],noupdate"`
    61  	// manual backup flag
    62  	Manual bool `yaml:"manual" json:"manual,omitempty"`
    63  	// actual file name on the target
    64  	Filename string `yaml:"filename" json:"filename,omitempty" norman:"noupdate"`
    65  	// backupConfig
    66  	BackupConfig BackupConfig `yaml:",omitempty" json:"backupConfig,omitempty" norman:"noupdate"`
    67  }
    68  
    69  type EtcdBackupStatus struct {
    70  	Conditions []EtcdBackupCondition `json:"conditions"`
    71  	// version of k8s in the backup pulled from rke config
    72  	KubernetesVersion string `yaml:"kubernetesVersion" json:"kubernetesVersion,omitempty" norman:"noupdate"`
    73  	// json + gzipped + base64 backup of the cluster object when the backup was created
    74  	ClusterObject string `yaml:"clusterObject" json:"clusterObject,omitempty" norman:"type=password,noupdate"`
    75  }
    76  
    77  type EtcdBackupCondition struct {
    78  	// Type of condition.
    79  	Type string `json:"type"`
    80  	// Status of the condition, one of True, False, Unknown.
    81  	Status v1.ConditionStatus `json:"status"`
    82  	// The last time this condition was updated.
    83  	LastUpdateTime string `json:"lastUpdateTime,omitempty"`
    84  	// Last time the condition transitioned from one status to another.
    85  	LastTransitionTime string `json:"lastTransitionTime,omitempty"`
    86  	// The reason for the condition's last transition.
    87  	Reason string `json:"reason,omitempty"`
    88  	// Human-readable message indicating details about last transition
    89  	Message string `json:"message,omitempty"`
    90  }