Java client library for OpenShift REST APIs, providing fluent DSL access to OpenShift resources and operations.
—
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.
/**
* Access to Hive API Group (hive.openshift.io/v1)
* Multi-cluster provisioning and management platform
*/
OpenShiftHiveAPIGroupDSL hive();
interface OpenShiftHiveAPIGroupDSL {
/** Cluster deployment definitions and lifecycle */
NonNamespaceOperation<ClusterDeployment, ClusterDeploymentList, Resource<ClusterDeployment>> clusterDeployments();
/** Cluster image set definitions for OpenShift versions */
NonNamespaceOperation<ClusterImageSet, ClusterImageSetList, Resource<ClusterImageSet>> clusterImageSets();
/** Cluster pool management for on-demand clusters */
NonNamespaceOperation<ClusterPool, ClusterPoolList, Resource<ClusterPool>> clusterPools();
/** Cluster claim requests from pools */
MixedOperation<ClusterClaim, ClusterClaimList, Resource<ClusterClaim>> clusterClaims();
/** Machine pool definitions for worker nodes */
MixedOperation<MachinePool, MachinePoolList, Resource<MachinePool>> machinePools();
/** Configuration synchronization sets */
NonNamespaceOperation<SyncSet, SyncSetList, Resource<SyncSet>> syncSets();
/** Selector-based sync sets */
NonNamespaceOperation<SelectorSyncSet, SelectorSyncSetList, Resource<SelectorSyncSet>> selectorSyncSets();
/** DNS zone management */
NonNamespaceOperation<DNSZone, DNSZoneList, Resource<DNSZone>> dnsZones();
/** Hive operator configuration */
NonNamespaceOperation<HiveConfig, HiveConfigList, Resource<HiveConfig>> hiveConfigs();
}Deploy and manage OpenShift clusters with automated provisioning and lifecycle management.
/**
* Cluster deployment resources for individual cluster management
*/
NonNamespaceOperation<ClusterDeployment, ClusterDeploymentList, Resource<ClusterDeployment>> clusterDeployments();
/**
* Cluster image sets defining OpenShift versions
*/
NonNamespaceOperation<ClusterImageSet, ClusterImageSetList, Resource<ClusterImageSet>> clusterImageSets();Usage Examples:
// Create cluster image set for OpenShift version
ClusterImageSet imageSet = new ClusterImageSetBuilder()
.withMetadata(new ObjectMetaBuilder()
.withName("openshift-v4.12.0")
.build())
.withSpec(new ClusterImageSetSpecBuilder()
.withReleaseImage("quay.io/openshift-release-dev/ocp-release:4.12.0-x86_64")
.build())
.build();
client.hive().clusterImageSets().create(imageSet);
// Create cluster deployment
ClusterDeployment cluster = new ClusterDeploymentBuilder()
.withMetadata(new ObjectMetaBuilder()
.withName("my-cluster")
.withNamespace("my-cluster")
.build())
.withSpec(new ClusterDeploymentSpecBuilder()
.withClusterName("my-cluster")
.withBaseDomain("example.com")
.withClusterImageSetRef(new ClusterImageSetReferenceBuilder()
.withName("openshift-v4.12.0")
.build())
.withPlatform(new PlatformBuilder()
.withAws(new AWSPlatformBuilder()
.withCredentialsSecretRef(new LocalObjectReferenceBuilder()
.withName("aws-creds")
.build())
.withRegion("us-east-1")
.build())
.build())
.withProvisioning(new ProvisioningBuilder()
.withInstallConfigSecretRef(new LocalObjectReferenceBuilder()
.withName("install-config")
.build())
.withSshPrivateKeySecretRef(new LocalObjectReferenceBuilder()
.withName("ssh-key")
.build())
.build())
.withPullSecretRef(new LocalObjectReferenceBuilder()
.withName("pull-secret")
.build())
.build())
.build();
client.hive().clusterDeployments().create(cluster);
// Check cluster status
ClusterDeployment deployed = client.hive().clusterDeployments()
.withName("my-cluster")
.get();
if (deployed != null) {
boolean installed = deployed.getSpec().getInstalled();
String apiURL = deployed.getStatus().getApiURL();
String webConsoleURL = deployed.getStatus().getWebConsoleURL();
System.out.println("Cluster installed: " + installed);
if (apiURL != null) {
System.out.println("API URL: " + apiURL);
System.out.println("Console URL: " + webConsoleURL);
}
}Manage cluster pools for rapid cluster provisioning and on-demand cluster allocation.
/**
* Cluster pools for pre-provisioned cluster management
*/
NonNamespaceOperation<ClusterPool, ClusterPoolList, Resource<ClusterPool>> clusterPools();
/**
* Cluster claims for requesting clusters from pools
*/
MixedOperation<ClusterClaim, ClusterClaimList, Resource<ClusterClaim>> clusterClaims();Usage Examples:
// Create cluster pool
ClusterPool pool = new ClusterPoolBuilder()
.withMetadata(new ObjectMetaBuilder()
.withName("aws-pool")
.withNamespace("cluster-pools")
.build())
.withSpec(new ClusterPoolSpecBuilder()
.withSize(3) // Maintain 3 ready clusters
.withMaxSize(10)
.withBaseDomain("pool.example.com")
.withClusterImageSetRef(new ClusterImageSetReferenceBuilder()
.withName("openshift-v4.12.0")
.build())
.withPlatform(new PlatformBuilder()
.withAws(new AWSPlatformBuilder()
.withCredentialsSecretRef(new LocalObjectReferenceBuilder()
.withName("aws-pool-creds")
.build())
.withRegion("us-west-2")
.build())
.build())
.withPullSecretRef(new LocalObjectReferenceBuilder()
.withName("pull-secret")
.build())
.withInstallConfigSecretTemplateRef(new LocalObjectReferenceBuilder()
.withName("install-config-template")
.build())
.build())
.build();
client.hive().clusterPools().create(pool);
// Claim cluster from pool
ClusterClaim claim = new ClusterClaimBuilder()
.withMetadata(new ObjectMetaBuilder()
.withName("my-dev-cluster")
.withNamespace("development")
.build())
.withSpec(new ClusterClaimSpecBuilder()
.withClusterPoolName("aws-pool")
.withLifetime("8h") // Auto-delete after 8 hours
.build())
.build();
client.hive().clusterClaims()
.inNamespace("development")
.create(claim);
// Check claim status
ClusterClaim activeClaim = client.hive().clusterClaims()
.inNamespace("development")
.withName("my-dev-cluster")
.get();
if (activeClaim != null && activeClaim.getSpec().getClusterDeploymentRef() != null) {
String clusterName = activeClaim.getSpec().getClusterDeploymentRef().getName();
System.out.println("Claimed cluster: " + clusterName);
}Synchronize configuration and resources across managed clusters using SyncSets and SelectorSyncSets.
/**
* Sync sets for configuration synchronization to specific clusters
*/
NonNamespaceOperation<SyncSet, SyncSetList, Resource<SyncSet>> syncSets();
/**
* Selector sync sets for configuration synchronization based on cluster labels
*/
NonNamespaceOperation<SelectorSyncSet, SelectorSyncSetList, Resource<SelectorSyncSet>> selectorSyncSets();Usage Examples:
// Create sync set for specific cluster
SyncSet syncSet = new SyncSetBuilder()
.withMetadata(new ObjectMetaBuilder()
.withName("monitoring-config")
.build())
.withSpec(new SyncSetSpecBuilder()
.withClusterDeploymentRefs(
new LocalObjectReferenceBuilder().withName("cluster1").build(),
new LocalObjectReferenceBuilder().withName("cluster2").build()
)
.withResources(
// ConfigMap for monitoring configuration
new RawExtensionBuilder()
.withRaw("{\"apiVersion\":\"v1\",\"kind\":\"ConfigMap\",\"metadata\":{\"name\":\"monitoring-config\",\"namespace\":\"openshift-monitoring\"},\"data\":{\"config.yaml\":\"retention: 30d\"}}")
.build()
)
.build())
.build();
client.hive().syncSets().create(syncSet);
// Create selector sync set for label-based targeting
SelectorSyncSet selectorSyncSet = new SelectorSyncSetBuilder()
.withMetadata(new ObjectMetaBuilder()
.withName("development-tooling")
.build())
.withSpec(new SelectorSyncSetSpecBuilder()
.withClusterDeploymentSelector(new LabelSelectorBuilder()
.addToMatchLabels("environment", "development")
.addToMatchLabels("team", "backend")
.build())
.withResources(
// Development tools namespace
new RawExtensionBuilder()
.withRaw("{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"name\":\"dev-tools\"}}")
.build(),
// Development RBAC
new RawExtensionBuilder()
.withRaw("{\"apiVersion\":\"rbac.authorization.k8s.io/v1\",\"kind\":\"ClusterRole\",\"metadata\":{\"name\":\"dev-tools-access\"},\"rules\":[{\"apiGroups\":[\"\"],\"resources\":[\"pods\",\"services\"],\"verbs\":[\"get\",\"list\",\"create\"]}]}")
.build()
)
.build())
.build();
client.hive().selectorSyncSets().create(selectorSyncSet);Configure and manage worker node pools for clusters with different machine types and scaling requirements.
/**
* Machine pools for cluster worker node management
*/
MixedOperation<MachinePool, MachinePoolList, Resource<MachinePool>> machinePools();Usage Examples:
// Create machine pool for additional worker nodes
MachinePool machinePool = new MachinePoolBuilder()
.withMetadata(new ObjectMetaBuilder()
.withName("gpu-workers")
.withNamespace("my-cluster")
.build())
.withSpec(new MachinePoolSpecBuilder()
.withClusterDeploymentRef(new LocalObjectReferenceBuilder()
.withName("my-cluster")
.build())
.withName("gpu-workers")
.withReplicas(2)
.withPlatform(new MachinePoolPlatformBuilder()
.withAws(new AWSMachinePoolPlatformBuilder()
.withInstanceType("p3.2xlarge")
.withEc2RootVolume(new EC2RootVolumeBuilder()
.withSize(100)
.withType("gp3")
.build())
.build())
.build())
.addNewTaint()
.withKey("nvidia.com/gpu")
.withValue("true")
.withEffect("NoSchedule")
.endTaint()
.addToLabels("node-type", "gpu")
.build())
.build();
client.hive().machinePools()
.inNamespace("my-cluster")
.create(machinePool);Manage DNS zones for cluster domains and routing configuration.
/**
* DNS zones for cluster domain management
*/
NonNamespaceOperation<DNSZone, DNSZoneList, Resource<DNSZone>> dnsZones();Usage Examples:
// Create DNS zone for cluster domain
DNSZone dnsZone = new DNSZoneBuilder()
.withMetadata(new ObjectMetaBuilder()
.withName("cluster-domain")
.build())
.withSpec(new DNSZoneSpecBuilder()
.withZone("clusters.example.com")
.withAwsCredentialsSecretRef(new LocalObjectReferenceBuilder()
.withName("aws-route53-creds")
.build())
.build())
.build();
client.hive().dnsZones().create(dnsZone);try (OpenShiftClient client = new KubernetesClientBuilder().build().adapt(OpenShiftClient.class)) {
// 1. Create cluster image set
ClusterImageSet imageSet = new ClusterImageSetBuilder()
.withMetadata(new ObjectMetaBuilder()
.withName("openshift-4.12.0")
.build())
.withSpec(new ClusterImageSetSpecBuilder()
.withReleaseImage("quay.io/openshift-release-dev/ocp-release:4.12.0-x86_64")
.build())
.build();
client.hive().clusterImageSets().createOrReplace(imageSet);
// 2. Create cluster pool for development clusters
ClusterPool devPool = new ClusterPoolBuilder()
.withMetadata(new ObjectMetaBuilder()
.withName("dev-cluster-pool")
.withNamespace("hive")
.addToLabels("purpose", "development")
.build())
.withSpec(new ClusterPoolSpecBuilder()
.withSize(2)
.withMaxSize(5)
.withBaseDomain("dev.example.com")
.withClusterImageSetRef(new ClusterImageSetReferenceBuilder()
.withName("openshift-4.12.0")
.build())
.withPlatform(new PlatformBuilder()
.withAws(new AWSPlatformBuilder()
.withCredentialsSecretRef(new LocalObjectReferenceBuilder()
.withName("aws-credentials")
.build())
.withRegion("us-east-1")
.build())
.build())
.withPullSecretRef(new LocalObjectReferenceBuilder()
.withName("pull-secret")
.build())
.build())
.build();
client.hive().clusterPools().createOrReplace(devPool);
// 3. Create selector sync set for all development clusters
SelectorSyncSet devConfig = new SelectorSyncSetBuilder()
.withMetadata(new ObjectMetaBuilder()
.withName("dev-cluster-config")
.build())
.withSpec(new SelectorSyncSetSpecBuilder()
.withClusterDeploymentSelector(new LabelSelectorBuilder()
.addToMatchLabels("purpose", "development")
.build())
.withResources(
// Create development namespace
createNamespaceResource("development"),
// Create development RBAC
createDeveloperRBACResource()
)
.build())
.build();
client.hive().selectorSyncSets().createOrReplace(devConfig);
System.out.println("Multi-cluster infrastructure configured successfully");
}Install with Tessl CLI
npx tessl i tessl/maven-io-fabric8--openshift-client