0
# Multi-cluster Management
1
2
Hive-based multi-cluster management for provisioning, configuring, and managing multiple OpenShift clusters through the hive.openshift.io API group. Provides comprehensive cluster lifecycle management with automated provisioning, configuration synchronization, and cluster pool management.
3
4
## Capabilities
5
6
### Hive Cluster Management
7
8
```java { .api }
9
/**
10
* Access to Hive API Group (hive.openshift.io/v1)
11
* Multi-cluster provisioning and management platform
12
*/
13
OpenShiftHiveAPIGroupDSL hive();
14
15
interface OpenShiftHiveAPIGroupDSL {
16
/** Cluster deployment definitions and lifecycle */
17
NonNamespaceOperation<ClusterDeployment, ClusterDeploymentList, Resource<ClusterDeployment>> clusterDeployments();
18
19
/** Cluster image set definitions for OpenShift versions */
20
NonNamespaceOperation<ClusterImageSet, ClusterImageSetList, Resource<ClusterImageSet>> clusterImageSets();
21
22
/** Cluster pool management for on-demand clusters */
23
NonNamespaceOperation<ClusterPool, ClusterPoolList, Resource<ClusterPool>> clusterPools();
24
25
/** Cluster claim requests from pools */
26
MixedOperation<ClusterClaim, ClusterClaimList, Resource<ClusterClaim>> clusterClaims();
27
28
/** Machine pool definitions for worker nodes */
29
MixedOperation<MachinePool, MachinePoolList, Resource<MachinePool>> machinePools();
30
31
/** Configuration synchronization sets */
32
NonNamespaceOperation<SyncSet, SyncSetList, Resource<SyncSet>> syncSets();
33
34
/** Selector-based sync sets */
35
NonNamespaceOperation<SelectorSyncSet, SelectorSyncSetList, Resource<SelectorSyncSet>> selectorSyncSets();
36
37
/** DNS zone management */
38
NonNamespaceOperation<DNSZone, DNSZoneList, Resource<DNSZone>> dnsZones();
39
40
/** Hive operator configuration */
41
NonNamespaceOperation<HiveConfig, HiveConfigList, Resource<HiveConfig>> hiveConfigs();
42
}
43
```
44
45
### Cluster Provisioning and Lifecycle
46
47
Deploy and manage OpenShift clusters with automated provisioning and lifecycle management.
48
49
```java { .api }
50
/**
51
* Cluster deployment resources for individual cluster management
52
*/
53
NonNamespaceOperation<ClusterDeployment, ClusterDeploymentList, Resource<ClusterDeployment>> clusterDeployments();
54
55
/**
56
* Cluster image sets defining OpenShift versions
57
*/
58
NonNamespaceOperation<ClusterImageSet, ClusterImageSetList, Resource<ClusterImageSet>> clusterImageSets();
59
```
60
61
**Usage Examples:**
62
63
```java
64
// Create cluster image set for OpenShift version
65
ClusterImageSet imageSet = new ClusterImageSetBuilder()
66
.withMetadata(new ObjectMetaBuilder()
67
.withName("openshift-v4.12.0")
68
.build())
69
.withSpec(new ClusterImageSetSpecBuilder()
70
.withReleaseImage("quay.io/openshift-release-dev/ocp-release:4.12.0-x86_64")
71
.build())
72
.build();
73
74
client.hive().clusterImageSets().create(imageSet);
75
76
// Create cluster deployment
77
ClusterDeployment cluster = new ClusterDeploymentBuilder()
78
.withMetadata(new ObjectMetaBuilder()
79
.withName("my-cluster")
80
.withNamespace("my-cluster")
81
.build())
82
.withSpec(new ClusterDeploymentSpecBuilder()
83
.withClusterName("my-cluster")
84
.withBaseDomain("example.com")
85
.withClusterImageSetRef(new ClusterImageSetReferenceBuilder()
86
.withName("openshift-v4.12.0")
87
.build())
88
.withPlatform(new PlatformBuilder()
89
.withAws(new AWSPlatformBuilder()
90
.withCredentialsSecretRef(new LocalObjectReferenceBuilder()
91
.withName("aws-creds")
92
.build())
93
.withRegion("us-east-1")
94
.build())
95
.build())
96
.withProvisioning(new ProvisioningBuilder()
97
.withInstallConfigSecretRef(new LocalObjectReferenceBuilder()
98
.withName("install-config")
99
.build())
100
.withSshPrivateKeySecretRef(new LocalObjectReferenceBuilder()
101
.withName("ssh-key")
102
.build())
103
.build())
104
.withPullSecretRef(new LocalObjectReferenceBuilder()
105
.withName("pull-secret")
106
.build())
107
.build())
108
.build();
109
110
client.hive().clusterDeployments().create(cluster);
111
112
// Check cluster status
113
ClusterDeployment deployed = client.hive().clusterDeployments()
114
.withName("my-cluster")
115
.get();
116
117
if (deployed != null) {
118
boolean installed = deployed.getSpec().getInstalled();
119
String apiURL = deployed.getStatus().getApiURL();
120
String webConsoleURL = deployed.getStatus().getWebConsoleURL();
121
122
System.out.println("Cluster installed: " + installed);
123
if (apiURL != null) {
124
System.out.println("API URL: " + apiURL);
125
System.out.println("Console URL: " + webConsoleURL);
126
}
127
}
128
```
129
130
### Cluster Pools and On-Demand Provisioning
131
132
Manage cluster pools for rapid cluster provisioning and on-demand cluster allocation.
133
134
```java { .api }
135
/**
136
* Cluster pools for pre-provisioned cluster management
137
*/
138
NonNamespaceOperation<ClusterPool, ClusterPoolList, Resource<ClusterPool>> clusterPools();
139
140
/**
141
* Cluster claims for requesting clusters from pools
142
*/
143
MixedOperation<ClusterClaim, ClusterClaimList, Resource<ClusterClaim>> clusterClaims();
144
```
145
146
**Usage Examples:**
147
148
```java
149
// Create cluster pool
150
ClusterPool pool = new ClusterPoolBuilder()
151
.withMetadata(new ObjectMetaBuilder()
152
.withName("aws-pool")
153
.withNamespace("cluster-pools")
154
.build())
155
.withSpec(new ClusterPoolSpecBuilder()
156
.withSize(3) // Maintain 3 ready clusters
157
.withMaxSize(10)
158
.withBaseDomain("pool.example.com")
159
.withClusterImageSetRef(new ClusterImageSetReferenceBuilder()
160
.withName("openshift-v4.12.0")
161
.build())
162
.withPlatform(new PlatformBuilder()
163
.withAws(new AWSPlatformBuilder()
164
.withCredentialsSecretRef(new LocalObjectReferenceBuilder()
165
.withName("aws-pool-creds")
166
.build())
167
.withRegion("us-west-2")
168
.build())
169
.build())
170
.withPullSecretRef(new LocalObjectReferenceBuilder()
171
.withName("pull-secret")
172
.build())
173
.withInstallConfigSecretTemplateRef(new LocalObjectReferenceBuilder()
174
.withName("install-config-template")
175
.build())
176
.build())
177
.build();
178
179
client.hive().clusterPools().create(pool);
180
181
// Claim cluster from pool
182
ClusterClaim claim = new ClusterClaimBuilder()
183
.withMetadata(new ObjectMetaBuilder()
184
.withName("my-dev-cluster")
185
.withNamespace("development")
186
.build())
187
.withSpec(new ClusterClaimSpecBuilder()
188
.withClusterPoolName("aws-pool")
189
.withLifetime("8h") // Auto-delete after 8 hours
190
.build())
191
.build();
192
193
client.hive().clusterClaims()
194
.inNamespace("development")
195
.create(claim);
196
197
// Check claim status
198
ClusterClaim activeClaim = client.hive().clusterClaims()
199
.inNamespace("development")
200
.withName("my-dev-cluster")
201
.get();
202
203
if (activeClaim != null && activeClaim.getSpec().getClusterDeploymentRef() != null) {
204
String clusterName = activeClaim.getSpec().getClusterDeploymentRef().getName();
205
System.out.println("Claimed cluster: " + clusterName);
206
}
207
```
208
209
### Configuration Synchronization
210
211
Synchronize configuration and resources across managed clusters using SyncSets and SelectorSyncSets.
212
213
```java { .api }
214
/**
215
* Sync sets for configuration synchronization to specific clusters
216
*/
217
NonNamespaceOperation<SyncSet, SyncSetList, Resource<SyncSet>> syncSets();
218
219
/**
220
* Selector sync sets for configuration synchronization based on cluster labels
221
*/
222
NonNamespaceOperation<SelectorSyncSet, SelectorSyncSetList, Resource<SelectorSyncSet>> selectorSyncSets();
223
```
224
225
**Usage Examples:**
226
227
```java
228
// Create sync set for specific cluster
229
SyncSet syncSet = new SyncSetBuilder()
230
.withMetadata(new ObjectMetaBuilder()
231
.withName("monitoring-config")
232
.build())
233
.withSpec(new SyncSetSpecBuilder()
234
.withClusterDeploymentRefs(
235
new LocalObjectReferenceBuilder().withName("cluster1").build(),
236
new LocalObjectReferenceBuilder().withName("cluster2").build()
237
)
238
.withResources(
239
// ConfigMap for monitoring configuration
240
new RawExtensionBuilder()
241
.withRaw("{\"apiVersion\":\"v1\",\"kind\":\"ConfigMap\",\"metadata\":{\"name\":\"monitoring-config\",\"namespace\":\"openshift-monitoring\"},\"data\":{\"config.yaml\":\"retention: 30d\"}}")
242
.build()
243
)
244
.build())
245
.build();
246
247
client.hive().syncSets().create(syncSet);
248
249
// Create selector sync set for label-based targeting
250
SelectorSyncSet selectorSyncSet = new SelectorSyncSetBuilder()
251
.withMetadata(new ObjectMetaBuilder()
252
.withName("development-tooling")
253
.build())
254
.withSpec(new SelectorSyncSetSpecBuilder()
255
.withClusterDeploymentSelector(new LabelSelectorBuilder()
256
.addToMatchLabels("environment", "development")
257
.addToMatchLabels("team", "backend")
258
.build())
259
.withResources(
260
// Development tools namespace
261
new RawExtensionBuilder()
262
.withRaw("{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"name\":\"dev-tools\"}}")
263
.build(),
264
// Development RBAC
265
new RawExtensionBuilder()
266
.withRaw("{\"apiVersion\":\"rbac.authorization.k8s.io/v1\",\"kind\":\"ClusterRole\",\"metadata\":{\"name\":\"dev-tools-access\"},\"rules\":[{\"apiGroups\":[\"\"],\"resources\":[\"pods\",\"services\"],\"verbs\":[\"get\",\"list\",\"create\"]}]}")
267
.build()
268
)
269
.build())
270
.build();
271
272
client.hive().selectorSyncSets().create(selectorSyncSet);
273
```
274
275
### Machine Pool Management
276
277
Configure and manage worker node pools for clusters with different machine types and scaling requirements.
278
279
```java { .api }
280
/**
281
* Machine pools for cluster worker node management
282
*/
283
MixedOperation<MachinePool, MachinePoolList, Resource<MachinePool>> machinePools();
284
```
285
286
**Usage Examples:**
287
288
```java
289
// Create machine pool for additional worker nodes
290
MachinePool machinePool = new MachinePoolBuilder()
291
.withMetadata(new ObjectMetaBuilder()
292
.withName("gpu-workers")
293
.withNamespace("my-cluster")
294
.build())
295
.withSpec(new MachinePoolSpecBuilder()
296
.withClusterDeploymentRef(new LocalObjectReferenceBuilder()
297
.withName("my-cluster")
298
.build())
299
.withName("gpu-workers")
300
.withReplicas(2)
301
.withPlatform(new MachinePoolPlatformBuilder()
302
.withAws(new AWSMachinePoolPlatformBuilder()
303
.withInstanceType("p3.2xlarge")
304
.withEc2RootVolume(new EC2RootVolumeBuilder()
305
.withSize(100)
306
.withType("gp3")
307
.build())
308
.build())
309
.build())
310
.addNewTaint()
311
.withKey("nvidia.com/gpu")
312
.withValue("true")
313
.withEffect("NoSchedule")
314
.endTaint()
315
.addToLabels("node-type", "gpu")
316
.build())
317
.build();
318
319
client.hive().machinePools()
320
.inNamespace("my-cluster")
321
.create(machinePool);
322
```
323
324
### DNS Zone Management
325
326
Manage DNS zones for cluster domains and routing configuration.
327
328
```java { .api }
329
/**
330
* DNS zones for cluster domain management
331
*/
332
NonNamespaceOperation<DNSZone, DNSZoneList, Resource<DNSZone>> dnsZones();
333
```
334
335
**Usage Examples:**
336
337
```java
338
// Create DNS zone for cluster domain
339
DNSZone dnsZone = new DNSZoneBuilder()
340
.withMetadata(new ObjectMetaBuilder()
341
.withName("cluster-domain")
342
.build())
343
.withSpec(new DNSZoneSpecBuilder()
344
.withZone("clusters.example.com")
345
.withAwsCredentialsSecretRef(new LocalObjectReferenceBuilder()
346
.withName("aws-route53-creds")
347
.build())
348
.build())
349
.build();
350
351
client.hive().dnsZones().create(dnsZone);
352
```
353
354
## Usage Patterns
355
356
### Complete Multi-cluster Setup
357
358
```java
359
try (OpenShiftClient client = new KubernetesClientBuilder().build().adapt(OpenShiftClient.class)) {
360
// 1. Create cluster image set
361
ClusterImageSet imageSet = new ClusterImageSetBuilder()
362
.withMetadata(new ObjectMetaBuilder()
363
.withName("openshift-4.12.0")
364
.build())
365
.withSpec(new ClusterImageSetSpecBuilder()
366
.withReleaseImage("quay.io/openshift-release-dev/ocp-release:4.12.0-x86_64")
367
.build())
368
.build();
369
370
client.hive().clusterImageSets().createOrReplace(imageSet);
371
372
// 2. Create cluster pool for development clusters
373
ClusterPool devPool = new ClusterPoolBuilder()
374
.withMetadata(new ObjectMetaBuilder()
375
.withName("dev-cluster-pool")
376
.withNamespace("hive")
377
.addToLabels("purpose", "development")
378
.build())
379
.withSpec(new ClusterPoolSpecBuilder()
380
.withSize(2)
381
.withMaxSize(5)
382
.withBaseDomain("dev.example.com")
383
.withClusterImageSetRef(new ClusterImageSetReferenceBuilder()
384
.withName("openshift-4.12.0")
385
.build())
386
.withPlatform(new PlatformBuilder()
387
.withAws(new AWSPlatformBuilder()
388
.withCredentialsSecretRef(new LocalObjectReferenceBuilder()
389
.withName("aws-credentials")
390
.build())
391
.withRegion("us-east-1")
392
.build())
393
.build())
394
.withPullSecretRef(new LocalObjectReferenceBuilder()
395
.withName("pull-secret")
396
.build())
397
.build())
398
.build();
399
400
client.hive().clusterPools().createOrReplace(devPool);
401
402
// 3. Create selector sync set for all development clusters
403
SelectorSyncSet devConfig = new SelectorSyncSetBuilder()
404
.withMetadata(new ObjectMetaBuilder()
405
.withName("dev-cluster-config")
406
.build())
407
.withSpec(new SelectorSyncSetSpecBuilder()
408
.withClusterDeploymentSelector(new LabelSelectorBuilder()
409
.addToMatchLabels("purpose", "development")
410
.build())
411
.withResources(
412
// Create development namespace
413
createNamespaceResource("development"),
414
// Create development RBAC
415
createDeveloperRBACResource()
416
)
417
.build())
418
.build();
419
420
client.hive().selectorSyncSets().createOrReplace(devConfig);
421
422
System.out.println("Multi-cluster infrastructure configured successfully");
423
}
424
```