mirror of
https://github.com/rancher/types.git
synced 2025-07-12 21:07:59 +00:00
etcd backup types
This commit is contained in:
parent
db4a9fe544
commit
c38be11d77
70
apis/management.cattle.io/v3/backup_types.go
Normal file
70
apis/management.cattle.io/v3/backup_types.go
Normal file
@ -0,0 +1,70 @@
|
||||
package v3
|
||||
|
||||
import (
|
||||
"github.com/rancher/norman/condition"
|
||||
"github.com/rancher/norman/types"
|
||||
"k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
BackupConditionCreated condition.Cond = "Created"
|
||||
BackupConditionCompleted condition.Cond = "Completed"
|
||||
BackupConditionRestored condition.Cond = "Restored"
|
||||
)
|
||||
|
||||
type BackupConfig struct {
|
||||
// Backup interval in hours
|
||||
IntervalHours int `yaml:"interval_hours" json:"intervalHours,omitempty" norman:"default=12"`
|
||||
// Number of backups to keep
|
||||
Retention int `yaml:"retention" json:"retention,omitempty" norman:"default=6"`
|
||||
// s3 target
|
||||
S3BackupConfig *S3BackupConfig `yaml:",omitempty" json:"s3BackupConfig"`
|
||||
}
|
||||
|
||||
type S3BackupConfig struct {
|
||||
// Access key ID
|
||||
AccessKey string `yaml:"access_key" json:"accessKey,omitempty"`
|
||||
// Secret access key
|
||||
SecretKey string `yaml:"secret_key" json:"secretKey,omitempty" norman:"required,type=password" `
|
||||
// name of the bucket to use for backup
|
||||
BucketName string `yaml:"bucket_name" json:"bucketName,omitempty"`
|
||||
// AWS Region, AWS spcific
|
||||
Region string `yaml:"region" json:"region,omitempty"`
|
||||
// Endpoint is used if this is not an AWS API
|
||||
Endpoint string `yaml:"endpoint" json:"endpoint"`
|
||||
}
|
||||
type EtcdBackup struct {
|
||||
types.Namespaced
|
||||
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
// cluster ID
|
||||
ClusterID string `json:"clusterId,omitempty" norman:"required,type=reference[cluster]"`
|
||||
// actual file name on the target
|
||||
Filename string `yaml:"filename" json:"filename,omitempty"`
|
||||
// backupConfig
|
||||
BackupConfig BackupConfig `yaml:",omitempty" json:"backupConfig,omitempty"`
|
||||
// backup status
|
||||
Status EtcdBackupStatus `yaml:"status" json:"status,omitempty"`
|
||||
}
|
||||
|
||||
type EtcdBackupStatus struct {
|
||||
Conditions []EtcdBackupCondition `json:"conditions"`
|
||||
}
|
||||
|
||||
type EtcdBackupCondition struct {
|
||||
// Type of condition.
|
||||
Type string `json:"type"`
|
||||
// Status of the condition, one of True, False, Unknown.
|
||||
Status v1.ConditionStatus `json:"status"`
|
||||
// The last time this condition was updated.
|
||||
LastUpdateTime string `json:"lastUpdateTime,omitempty"`
|
||||
// Last time the condition transitioned from one status to another.
|
||||
LastTransitionTime string `json:"lastTransitionTime,omitempty"`
|
||||
// The reason for the condition's last transition.
|
||||
Reason string `json:"reason,omitempty"`
|
||||
// Human-readable message indicating details about last transition
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
@ -237,6 +237,11 @@ type IngressCapabilities struct {
|
||||
type MonitoringInput struct {
|
||||
Answers map[string]string `json:"answers,omitempty"`
|
||||
}
|
||||
|
||||
type RestoreFromEtcdBackupInput struct {
|
||||
EtcdBackupName string `json:"etcdBackupName,omitempty" norman:"type=reference[etcdBackup]"`
|
||||
}
|
||||
|
||||
type RotateCertificateInput struct {
|
||||
CACertificates bool `json:"caCertificates,omitempty"`
|
||||
Services []string `json:"services,omitempty" norman:"type=enum,options=etcd|kubelet|kube-apiserver|kube-proxy|kube-scheduler|kube-controller-manager"`
|
||||
|
@ -41,6 +41,8 @@ type RancherKubernetesEngineConfig struct {
|
||||
BastionHost BastionHost `yaml:"bastion_host" json:"bastionHost,omitempty"`
|
||||
// Monitoring Config
|
||||
Monitoring MonitoringConfig `yaml:"monitoring" json:"monitoring,omitempty"`
|
||||
// RestoreCluster flag
|
||||
Restore RestoreConfig `yaml:"restore" json:"restore,omitempty"`
|
||||
// Rotating Certificates Option
|
||||
RotateCertificates *RotateCertificates `yaml:"rotate_certificates,omitempty" json:"rotateCertificates,omitempty"`
|
||||
}
|
||||
@ -185,6 +187,8 @@ type ETCDService struct {
|
||||
Retention string `yaml:"retention" json:"retention,omitempty" norman:"default=72h"`
|
||||
// Etcd snapshot Creation period
|
||||
Creation string `yaml:"creation" json:"creation,omitempty" norman:"default=12h"`
|
||||
// Backup backend for etcd snapshots, used by rke only
|
||||
BackupConfig *BackupConfig `yaml:"backup_target" json:"backupConfig,omitempty"`
|
||||
}
|
||||
|
||||
type KubeAPIService struct {
|
||||
@ -583,6 +587,10 @@ type MonitoringConfig struct {
|
||||
Options map[string]string `yaml:"options" json:"options,omitempty"`
|
||||
}
|
||||
|
||||
type RestoreConfig struct {
|
||||
Restore bool `yaml:"restore" json:"restore,omitempty"`
|
||||
SnapshotName string `yaml:"snapshot_name" json:"snapshotName,omitempty"`
|
||||
}
|
||||
type RotateCertificates struct {
|
||||
// Rotate CA Certificates
|
||||
CACertificates bool `json:"caCertificates,omitempty"`
|
||||
|
@ -39,6 +39,7 @@ var (
|
||||
Init(multiClusterAppTypes).
|
||||
Init(globalDNSTypes).
|
||||
Init(kontainerTypes).
|
||||
Init(etcdBackupTypes).
|
||||
Init(monitorTypes)
|
||||
|
||||
TokenSchemas = factory.Schemas(&Version).
|
||||
@ -149,6 +150,7 @@ func clusterTypes(schemas *types.Schemas) *types.Schemas {
|
||||
MustImport(&Version, v3.ImportYamlOutput{}).
|
||||
MustImport(&Version, v3.ExportOutput{}).
|
||||
MustImport(&Version, v3.MonitoringInput{}).
|
||||
MustImport(&Version, v3.RestoreFromEtcdBackupInput{}).
|
||||
MustImportAndCustomize(&Version, v3.ETCDService{}, func(schema *types.Schema) {
|
||||
schema.MustCustomizeField("extraArgs", func(field types.Field) types.Field {
|
||||
field.Default = map[string]interface{}{
|
||||
@ -178,6 +180,10 @@ func clusterTypes(schemas *types.Schemas) *types.Schemas {
|
||||
Input: "monitoringInput",
|
||||
}
|
||||
schema.ResourceActions["disableMonitoring"] = types.Action{}
|
||||
schema.ResourceActions["backupEtcd"] = types.Action{}
|
||||
schema.ResourceActions["restoreFromEtcdBackup"] = types.Action{
|
||||
Input: "restoreFromEtcdBackupInput",
|
||||
}
|
||||
schema.ResourceActions["rotateCertificates"] = types.Action{
|
||||
Input: "rotateCertificateInput",
|
||||
}
|
||||
@ -695,3 +701,7 @@ func monitorTypes(schemas *types.Schemas) *types.Schemas {
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func etcdBackupTypes(schemas *types.Schemas) *types.Schemas {
|
||||
return schemas.MustImport(&Version, v3.EtcdBackup{})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user