-
Notifications
You must be signed in to change notification settings - Fork 867
/
types.go
227 lines (189 loc) · 8.17 KB
/
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
package v1alpha1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
const (
// ResourceKindCluster is kind name of Cluster.
ResourceKindCluster = "Cluster"
// ResourceSingularCluster is singular name of Cluster.
ResourceSingularCluster = "cluster"
// ResourcePluralCluster is plural name of Cluster.
ResourcePluralCluster = "clusters"
// ResourceNamespaceScopedCluster indicates if Cluster is NamespaceScoped.
ResourceNamespaceScopedCluster = false
)
// +genclient
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:resource:scope="Cluster"
// +kubebuilder:subresource:status
// Cluster represents the desire state and status of a member cluster.
type Cluster struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
// Spec represents the specification of the desired behavior of member cluster.
Spec ClusterSpec `json:"spec"`
// Status represents the status of member cluster.
// +optional
Status ClusterStatus `json:"status,omitempty"`
}
// ClusterSpec defines the desired state of a member cluster.
type ClusterSpec struct {
// SyncMode describes how a cluster sync resources from karmada control plane.
// +kubebuilder:validation:Enum=Push;Pull
// +required
SyncMode ClusterSyncMode `json:"syncMode"`
// The API endpoint of the member cluster. This can be a hostname,
// hostname:port, IP or IP:port.
// +optional
APIEndpoint string `json:"apiEndpoint,omitempty"`
// SecretRef represents the secret contains mandatory credentials to access the member cluster.
// The secret should hold credentials as follows:
// - secret.data.token
// - secret.data.caBundle
// +optional
SecretRef *LocalSecretReference `json:"secretRef,omitempty"`
// ImpersonatorSecretRef represents the secret contains the token of impersonator.
// The secret should hold credentials as follows:
// - secret.data.token
// +optional
ImpersonatorSecretRef *LocalSecretReference `json:"impersonatorSecretRef,omitempty"`
// InsecureSkipTLSVerification indicates that the karmada control plane should not confirm the validity of the serving
// certificate of the cluster it is connecting to. This will make the HTTPS connection between the karmada control
// plane and the member cluster insecure.
// Defaults to false.
// +optional
InsecureSkipTLSVerification bool `json:"insecureSkipTLSVerification,omitempty"`
// ProxyURL is the proxy URL for the cluster.
// If not empty, the karmada control plane will use this proxy to talk to the cluster.
// More details please refer to: https://github.com/kubernetes/client-go/issues/351
// +optional
ProxyURL string `json:"proxyURL,omitempty"`
// Provider represents the cloud provider name of the member cluster.
// +optional
Provider string `json:"provider,omitempty"`
// Region represents the region of the member cluster locate in.
// +optional
Region string `json:"region,omitempty"`
// Zone represents the zone of the member cluster locate in.
// +optional
Zone string `json:"zone,omitempty"`
// Taints attached to the member cluster.
// Taints on the cluster have the "effect" on
// any resource that does not tolerate the Taint.
// +optional
Taints []corev1.Taint `json:"taints,omitempty"`
}
const (
// SecretTokenKey is the name of secret token key.
SecretTokenKey = "token"
// SecretCADataKey is the name of secret caBundle key.
SecretCADataKey = "caBundle"
)
// ClusterSyncMode describes the mode of synchronization between member cluster and karmada control plane.
type ClusterSyncMode string
const (
// Push means that the controller on the karmada control plane will in charge of synchronization.
// The controller watches resources change on karmada control plane then pushes them to member cluster.
Push ClusterSyncMode = "Push"
// Pull means that the controller running on the member cluster will in charge of synchronization.
// The controller, as well known as 'agent', watches resources change on karmada control plane then fetches them
// and applies locally on the member cluster.
Pull ClusterSyncMode = "Pull"
)
// LocalSecretReference is a reference to a secret within the enclosing
// namespace.
type LocalSecretReference struct {
// Namespace is the namespace for the resource being referenced.
Namespace string `json:"namespace"`
// Name is the name of resource being referenced.
Name string `json:"name"`
}
// Define valid conditions of a member cluster.
const (
// ClusterConditionReady means the cluster is healthy and ready to accept workloads.
ClusterConditionReady = "Ready"
)
// ClusterStatus contains information about the current status of a
// cluster updated periodically by cluster controller.
type ClusterStatus struct {
// KubernetesVersion represents version of the member cluster.
// +optional
KubernetesVersion string `json:"kubernetesVersion,omitempty"`
// APIEnablements represents the list of APIs installed in the member cluster.
// +optional
APIEnablements []APIEnablement `json:"apiEnablements,omitempty"`
// Conditions is an array of current cluster conditions.
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty"`
// NodeSummary represents the summary of nodes status in the member cluster.
// +optional
NodeSummary *NodeSummary `json:"nodeSummary,omitempty"`
// ResourceSummary represents the summary of resources in the member cluster.
// +optional
ResourceSummary *ResourceSummary `json:"resourceSummary,omitempty"`
}
// APIEnablement is a list of API resource, it is used to expose the name of the
// resources supported in a specific group and version.
type APIEnablement struct {
// GroupVersion is the group and version this APIEnablement is for.
GroupVersion string `json:"groupVersion"`
// Resources is a list of APIResource.
// +optional
Resources []APIResource `json:"resources,omitempty"`
}
// APIResource specifies the name and kind names for the resource.
type APIResource struct {
// Name is the plural name of the resource.
// +required
Name string `json:"name"`
// Kind is the kind for the resource (e.g. 'Deployment' is the kind for resource 'deployments')
// +required
Kind string `json:"kind"`
}
// NodeSummary represents the summary of nodes status in a specific cluster.
type NodeSummary struct {
// TotalNum is the total number of nodes in the cluster.
// +optional
TotalNum int32 `json:"totalNum,omitempty"`
// ReadyNum is the number of ready nodes in the cluster.
// +optional
ReadyNum int32 `json:"readyNum,omitempty"`
}
// ResourceSummary represents the summary of resources in the member cluster.
type ResourceSummary struct {
// Allocatable represents the resources of a cluster that are available for scheduling.
// Total amount of allocatable resources on all nodes.
// +optional
Allocatable corev1.ResourceList `json:"allocatable,omitempty"`
// Allocating represents the resources of a cluster that are pending for scheduling.
// Total amount of required resources of all Pods that are waiting for scheduling.
// +optional
Allocating corev1.ResourceList `json:"allocating,omitempty"`
// Allocated represents the resources of a cluster that have been scheduled.
// Total amount of required resources of all Pods that have been scheduled to nodes.
// +optional
Allocated corev1.ResourceList `json:"allocated,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ClusterList contains a list of member cluster
type ClusterList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
// Items holds a list of Cluster.
Items []Cluster `json:"items"`
}
// +k8s:conversion-gen:explicit-from=net/url.Values
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ClusterProxyOptions is the query options to a Cluster's proxy call.
type ClusterProxyOptions struct {
metav1.TypeMeta `json:",inline"`
// Path is the part of URLs that include clusters, suffixes,
// and parameters to use for the current proxy request to cluster.
// For example, the whole request URL is
// http://localhost/apis/cluster.karmada.io/v1alpha1/cluster/{clustername}/proxy/api/v1/nodes
// Path is api/v1/nodes
// +optional
Path string `json:"path,omitempty" protobuf:"bytes,1,opt,name=path"`
}