-
Notifications
You must be signed in to change notification settings - Fork 74
/
types_klusterlet.go
246 lines (207 loc) · 11.6 KB
/
types_klusterlet.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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
package v1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +genclient
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster
// Klusterlet represents controllers to install the resources for a managed cluster.
// When configured, the Klusterlet requires a secret named bootstrap-hub-kubeconfig in the
// agent namespace to allow API requests to the hub for the registration protocol.
// In Hosted mode, the Klusterlet requires an additional secret named external-managed-kubeconfig
// in the agent namespace to allow API requests to the managed cluster for resources installation.
type Klusterlet struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
// Spec represents the desired deployment configuration of Klusterlet agent.
Spec KlusterletSpec `json:"spec,omitempty"`
// Status represents the current status of Klusterlet agent.
Status KlusterletStatus `json:"status,omitempty"`
}
// KlusterletSpec represents the desired deployment configuration of Klusterlet agent.
type KlusterletSpec struct {
// Namespace is the namespace to deploy the agent on the managed cluster.
// The namespace must have a prefix of "open-cluster-management-", and if it is not set,
// the namespace of "open-cluster-management-agent" is used to deploy agent.
// In addition, the add-ons are deployed to the namespace of "{Namespace}-addon".
// In the Hosted mode, this namespace still exists on the managed cluster to contain
// necessary resources, like service accounts, roles and rolebindings, while the agent
// is deployed to the namespace with the same name as klusterlet on the management cluster.
// +optional
// +kubebuilder:validation:MaxLength=63
// +kubebuilder:validation:Pattern=^open-cluster-management-[-a-z0-9]*[a-z0-9]$
Namespace string `json:"namespace,omitempty"`
// RegistrationImagePullSpec represents the desired image configuration of registration agent.
// quay.io/open-cluster-management.io/registration:latest will be used if unspecified.
// +optional
RegistrationImagePullSpec string `json:"registrationImagePullSpec,omitempty"`
// WorkImagePullSpec represents the desired image configuration of work agent.
// quay.io/open-cluster-management.io/work:latest will be used if unspecified.
// +optional
WorkImagePullSpec string `json:"workImagePullSpec,omitempty"`
// ImagePullSpec represents the desired image configuration of agent, it takes effect only when
// singleton mode is set. quay.io/open-cluster-management.io/registration-operator:latest will
// be used if unspecified
// +optional
ImagePullSpec string `json:"imagePullSpec,omitempty"`
// ClusterName is the name of the managed cluster to be created on hub.
// The Klusterlet agent generates a random name if it is not set, or discovers the appropriate cluster name on OpenShift.
// +optional
// +kubebuilder:validation:MaxLength=63
// +kubebuilder:validation:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
ClusterName string `json:"clusterName,omitempty"`
// ExternalServerURLs represents a list of apiserver urls and ca bundles that is accessible externally
// If it is set empty, managed cluster has no externally accessible url that hub cluster can visit.
// +optional
ExternalServerURLs []ServerURL `json:"externalServerURLs,omitempty"`
// NodePlacement enables explicit control over the scheduling of the deployed pods.
// +optional
NodePlacement NodePlacement `json:"nodePlacement,omitempty"`
// DeployOption contains the options of deploying a klusterlet
// +optional
DeployOption KlusterletDeployOption `json:"deployOption,omitempty"`
// RegistrationConfiguration contains the configuration of registration
// +optional
RegistrationConfiguration *RegistrationConfiguration `json:"registrationConfiguration,omitempty"`
// WorkConfiguration contains the configuration of work
// +optional
WorkConfiguration *WorkAgentConfiguration `json:"workConfiguration,omitempty"`
// HubApiServerHostAlias contains the host alias for hub api server.
// registration-agent and work-agent will use it to communicate with hub api server.
// +optional
HubApiServerHostAlias *HubApiServerHostAlias `json:"hubApiServerHostAlias,omitempty"`
// ResourceRequirement specify QoS classes of deployments managed by klusterlet.
// It applies to all the containers in the deployments.
// +optional
ResourceRequirement *ResourceRequirement `json:"resourceRequirement,omitempty"`
// PriorityClassName is the name of the PriorityClass that will be used by the
// deployed klusterlet agent. It will be ignored when the PriorityClass/v1 API
// is not available on the managed cluster.
// +optional
PriorityClassName string `json:"priorityClassName,omitempty"`
}
// ServerURL represents the apiserver url and ca bundle that is accessible externally
type ServerURL struct {
// URL is the url of apiserver endpoint of the managed cluster.
// +required
URL string `json:"url"`
// CABundle is the ca bundle to connect to apiserver of the managed cluster.
// System certs are used if it is not set.
// +optional
CABundle []byte `json:"caBundle,omitempty"`
}
// HubApiServerHostAlias holds the mapping between IP and hostname that will be injected as an entry in the
// pod's hosts file.
type HubApiServerHostAlias struct {
// IP address of the host file entry.
// +required
// +kubebuilder:validation:Required
// +kubebuilder:validation:Pattern=`^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$`
IP string `json:"ip"`
// Hostname for the above IP address.
// +required
// +kubebuilder:validation:Required
// +kubebuilder:validation:Pattern=`^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$`
Hostname string `json:"hostname"`
}
type RegistrationConfiguration struct {
// clientCertExpirationSeconds represents the seconds of a client certificate to expire. If it is not set or 0, the default
// duration seconds will be set by the hub cluster. If the value is larger than the max signing duration seconds set on
// the hub cluster, the max signing duration seconds will be set.
// +optional
ClientCertExpirationSeconds int32 `json:"clientCertExpirationSeconds,omitempty"`
// FeatureGates represents the list of feature gates for registration
// If it is set empty, default feature gates will be used.
// If it is set, featuregate/Foo is an example of one item in FeatureGates:
// 1. If featuregate/Foo does not exist, registration-operator will discard it
// 2. If featuregate/Foo exists and is false by default. It is now possible to set featuregate/Foo=[false|true]
// 3. If featuregate/Foo exists and is true by default. If a cluster-admin upgrading from 1 to 2 wants to continue having featuregate/Foo=false,
// he can set featuregate/Foo=false before upgrading. Let's say the cluster-admin wants featuregate/Foo=false.
// +optional
FeatureGates []FeatureGate `json:"featureGates,omitempty"`
// ClusterAnnotations is annotations with the reserve prefix "agent.open-cluster-management.io" set on
// ManagedCluster when creating only, other actors can update it afterwards.
// +optional
ClusterAnnotations map[string]string `json:"clusterAnnotations,omitempty"`
// KubeAPIQPS indicates the maximum QPS while talking with apiserver of hub cluster from the spoke cluster.
// If it is set empty, use the default value: 50
// +optional
// +kubebuilder:default:=50
KubeAPIQPS int32 `json:"kubeAPIQPS,omitempty"`
// KubeAPIBurst indicates the maximum burst of the throttle while talking with apiserver of hub cluster from the spoke cluster.
// If it is set empty, use the default value: 100
// +optional
// +kubebuilder:default:=100
KubeAPIBurst int32 `json:"kubeAPIBurst,omitempty"`
}
type WorkAgentConfiguration struct {
// FeatureGates represents the list of feature gates for work
// If it is set empty, default feature gates will be used.
// If it is set, featuregate/Foo is an example of one item in FeatureGates:
// 1. If featuregate/Foo does not exist, registration-operator will discard it
// 2. If featuregate/Foo exists and is false by default. It is now possible to set featuregate/Foo=[false|true]
// 3. If featuregate/Foo exists and is true by default. If a cluster-admin upgrading from 1 to 2 wants to continue having featuregate/Foo=false,
// he can set featuregate/Foo=false before upgrading. Let's say the cluster-admin wants featuregate/Foo=false.
// +optional
FeatureGates []FeatureGate `json:"featureGates,omitempty"`
// KubeAPIQPS indicates the maximum QPS while talking with apiserver of hub cluster from the spoke cluster.
// If it is set empty, use the default value: 50
// +optional
// +kubebuilder:default:=50
KubeAPIQPS int32 `json:"kubeAPIQPS,omitempty"`
// KubeAPIBurst indicates the maximum burst of the throttle while talking with apiserver of hub cluster from the spoke cluster.
// If it is set empty, use the default value: 100
// +optional
// +kubebuilder:default:=100
KubeAPIBurst int32 `json:"kubeAPIBurst,omitempty"`
}
const (
// ClusterAnnotationsKeyPrefix is the prefix of annotations set on ManagedCluster when creating only.
ClusterAnnotationsKeyPrefix = "agent.open-cluster-management.io"
)
// KlusterletDeployOption describes the deployment options for klusterlet
type KlusterletDeployOption struct {
// Mode can be Default, Hosted, Singleton or SingletonHosted. It is Default mode if not specified
// In Default mode, all klusterlet related resources are deployed on the managed cluster.
// In Hosted mode, only crd and configurations are installed on the spoke/managed cluster. Controllers run in another
// cluster (defined as management-cluster) and connect to the mangaged cluster with the kubeconfig in secret of
// "external-managed-kubeconfig"(a kubeconfig of managed-cluster with cluster-admin permission).
// In Singleton mode, registration/work agent is started as a single deployment.
// In SingletonHosted mode, agent is started as a single deployment in hosted mode.
// Note: Do not modify the Mode field once it's applied.
// +optional
Mode InstallMode `json:"mode"`
}
// KlusterletStatus represents the current status of Klusterlet agent.
type KlusterletStatus struct {
// ObservedGeneration is the last generation change you've dealt with
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
// Conditions contain the different condition statuses for this Klusterlet.
// Valid condition types are:
// Applied: Components have been applied in the managed cluster.
// Available: Components in the managed cluster are available and ready to serve.
// Progressing: Components in the managed cluster are in a transitioning state.
// Degraded: Components in the managed cluster do not match the desired configuration and only provide
// degraded service.
Conditions []metav1.Condition `json:"conditions"`
// Generations are used to determine when an item needs to be reconciled or has changed in a way that needs a reaction.
// +optional
Generations []GenerationStatus `json:"generations,omitempty"`
// RelatedResources are used to track the resources that are related to this Klusterlet.
// +optional
RelatedResources []RelatedResourceMeta `json:"relatedResources,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// KlusterletList is a collection of Klusterlet agents.
type KlusterletList struct {
metav1.TypeMeta `json:",inline"`
// Standard list metadata.
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds
// +optional
metav1.ListMeta `json:"metadata,omitempty"`
// Items is a list of Klusterlet agents.
Items []Klusterlet `json:"items"`
}