/
drainer_types.go
120 lines (100 loc) · 3.23 KB
/
drainer_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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
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 (
DrainerConfigStatusStatusTrue = "True"
)
const (
DrainerConfigStatusTypeDrained = "Drained"
)
const (
DrainerConfigStatusTypeTimeout = "Timeout"
)
const (
kindDrainerConfig = "DrainerConfig"
)
func NewDrainerConfigCRD() *v1.CustomResourceDefinition {
return crd.LoadV1(group, kindDrainerConfig)
}
func NewDrainerTypeMeta() metav1.TypeMeta {
return metav1.TypeMeta{
APIVersion: version,
Kind: kindDrainerConfig,
}
}
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:storageversion
// +kubebuilder:subresource:status
// +kubebuilder:resource:categories=common;giantswarm
// +k8s:openapi-gen=true
type DrainerConfig struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Spec DrainerConfigSpec `json:"spec"`
// +kubebuilder:validation:Optional
Status DrainerConfigStatus `json:"status"`
}
// +k8s:openapi-gen=true
type DrainerConfigSpec struct {
Guest DrainerConfigSpecGuest `json:"guest"`
VersionBundle DrainerConfigSpecVersionBundle `json:"versionBundle"`
}
// +k8s:openapi-gen=true
type DrainerConfigSpecGuest struct {
Cluster DrainerConfigSpecGuestCluster `json:"cluster"`
Node DrainerConfigSpecGuestNode `json:"node"`
}
// +k8s:openapi-gen=true
type DrainerConfigSpecGuestCluster struct {
API DrainerConfigSpecGuestClusterAPI `json:"api"`
// ID is the guest cluster ID of which a node should be drained.
ID string `json:"id"`
}
// +k8s:openapi-gen=true
type DrainerConfigSpecGuestClusterAPI struct {
// Endpoint is the guest cluster API endpoint.
Endpoint string `json:"endpoint"`
}
// +k8s:openapi-gen=true
type DrainerConfigSpecGuestNode struct {
// Name is the identifier of the guest cluster's master and worker nodes. In
// Kubernetes/Kubectl they are represented as node names. The names are manage
// in an abstracted way because of provider specific differences.
//
// AWS: EC2 instance DNS.
// Azure: VM name.
// KVM: host cluster pod name.
//
Name string `json:"name"`
}
// +k8s:openapi-gen=true
type DrainerConfigSpecVersionBundle struct {
Version string `json:"version"`
}
// +k8s:openapi-gen=true
type DrainerConfigStatus struct {
Conditions []DrainerConfigStatusCondition `json:"conditions"`
}
// DrainerConfigStatusCondition expresses a condition in which a node may is.
// +k8s:openapi-gen=true
type DrainerConfigStatusCondition struct {
// LastHeartbeatTime is the last time we got an update on a given condition.
LastHeartbeatTime metav1.Time `json:"lastHeartbeatTime"`
// LastTransitionTime is the last time the condition transitioned from one
// status to another.
LastTransitionTime metav1.Time `json:"lastTransitionTime"`
// Status may be True, False or Unknown.
Status string `json:"status"`
// Type may be Pending, Ready, Draining, Drained.
Type string `json:"type"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type DrainerConfigList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []DrainerConfig `json:"items"`
}