/
etcd_backup_types.go
87 lines (76 loc) · 3.03 KB
/
etcd_backup_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package v1alpha1
import (
v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/giantswarm/apiextensions/pkg/crd"
)
const (
kindETCDBackup = "ETCDBackup"
)
func NewETCDBackupCRD() *v1.CustomResourceDefinition {
return crd.LoadV1(group, kindETCDBackup)
}
// +genclient
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:storageversion
// +kubebuilder:subresource:status
// +kubebuilder:resource:categories=common;giantswarm,scope=Cluster
// +k8s:openapi-gen=true
type ETCDBackup struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Spec ETCDBackupSpec `json:"spec"`
// +kubebuilder:validation:Optional
Status ETCDBackupStatus `json:"status,omitempty"`
}
// +k8s:openapi-gen=true
type ETCDBackupSpec struct {
// GuestBackup is a boolean indicating if the tenant clusters have to be backupped
GuestBackup bool `json:"guestBackup"`
}
// +k8s:openapi-gen=true
type ETCDBackupStatus struct {
// map containing the state of the backup for all instances
Instances map[string]ETCDInstanceBackupStatusIndex `json:"instances,omitempty"`
// Status of the whole backup job (can be 'Pending', 'Running'. 'Completed', 'Failed')
Status string `json:"status"`
// Timestamp when the first attempt was made
StartedTimestamp metav1.Time `json:"startedTimestamp,omitempty"`
// Timestamp when the last (final) attempt was made (when the Phase became either 'Completed' or 'Failed'
FinishedTimestamp metav1.Time `json:"finishedTimestamp,omitempty"`
}
// +k8s:openapi-gen=true
type ETCDInstanceBackupStatusIndex struct {
// Name of the tenant cluster or 'Control Plane'
Name string `json:"name"`
// Status of the V2 backup for this instance
V2 ETCDInstanceBackupStatus `json:"v2"`
// Status of the V3 backup for this instance
V3 ETCDInstanceBackupStatus `json:"v3"`
}
// +k8s:openapi-gen=true
type ETCDInstanceBackupStatus struct {
// Status of this isntance's backup job (can be 'Pending', 'Running'. 'Completed', 'Failed')
Status string `json:"status"`
// Timestamp when the first attempt was made
StartedTimestamp metav1.Time `json:"startedTimestamp,omitempty"`
// Timestamp when the last (final) attempt was made (when the Phase became either 'Completed' or 'Failed'
FinishedTimestamp metav1.Time `json:"finishedTimestamp,omitempty"`
// Latest backup error message
LatestError string `json:"latestError,omitempty"`
// Time took by the backup creation process
CreationTime int64 `json:"creationTime,omitempty"`
// Time took by the backup encryption process
EncryptionTime int64 `json:"encryptionTime,omitempty"`
// Time took by the backup upload process
UploadTime int64 `json:"uploadTime,omitempty"`
// Size of the backup file
BackupFileSize int64 `json:"backupFileSize,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type ETCDBackupList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []ETCDBackup `json:"items"`
}