Java client library for OpenShift REST APIs, providing fluent DSL access to OpenShift resources and operations.
—
Comprehensive operator management through Operator Lifecycle Manager (OLM), OpenShift operators, and OperatorHub integration. Enables installation, configuration, and lifecycle management of operators across the cluster.
Core OLM functionality for managing operator installations, subscriptions, and catalog sources.
/**
* Access to OperatorHub API Group (operators.coreos.com)
* Operator Lifecycle Manager resources
*/
OpenShiftOperatorHubAPIGroupDSL operatorHub();
interface OpenShiftOperatorHubAPIGroupDSL {
/** Operator catalog sources (v1alpha1) */
MixedOperation<CatalogSource, CatalogSourceList, Resource<CatalogSource>> catalogSources();
/** Cluster Service Versions - installed operators (v1alpha1) */
MixedOperation<ClusterServiceVersion, ClusterServiceVersionList, Resource<ClusterServiceVersion>> clusterServiceVersions();
/** Installation plans for operator deployments (v1alpha1) */
MixedOperation<InstallPlan, InstallPlanList, Resource<InstallPlan>> installPlans();
/** Operator subscriptions for automatic updates (v1alpha1) */
MixedOperation<Subscription, SubscriptionList, Resource<Subscription>> subscriptions();
/** OLM configuration (v1) */
NonNamespaceOperation<OLMConfig, OLMConfigList, Resource<OLMConfig>> olmConfigs();
/** Operator conditions (v1) */
MixedOperation<OperatorCondition, OperatorConditionList, Resource<OperatorCondition>> operatorConditions();
/** Operator groups for namespace organization (v1) */
MixedOperation<OperatorGroup, OperatorGroupList, Resource<OperatorGroup>> operatorGroups();
/** Installed operators (v1) */
NonNamespaceOperation<Operator, OperatorList, Resource<Operator>> operators();
/** Package manifests for available operators (packages.operators.coreos.com/v1) */
MixedOperation<PackageManifest, PackageManifestList, Resource<PackageManifest>> packageManifests();
}Usage Examples:
// List available operators from catalog
PackageManifestList packages = client.operatorHub().packageManifests()
.inNamespace("openshift-marketplace")
.list();
// Install operator via subscription
Subscription subscription = new SubscriptionBuilder()
.withMetadata(new ObjectMetaBuilder()
.withName("my-operator")
.withNamespace("operators")
.build())
.withSpec(new SubscriptionSpecBuilder()
.withChannel("stable")
.withName("my-operator")
.withSource("community-operators")
.withSourceNamespace("openshift-marketplace")
.withInstallPlanApproval("Automatic")
.build())
.build();
client.operatorHub().subscriptions().inNamespace("operators").create(subscription);
// List installed operators
ClusterServiceVersionList csvs = client.operatorHub().clusterServiceVersions()
.inNamespace("operators")
.list();
// Check installation status
InstallPlanList installPlans = client.operatorHub().installPlans()
.inNamespace("operators")
.list();OpenShift-specific operators for cluster services and infrastructure management.
/**
* Access to OpenShift Operator API Group (operator.openshift.io/v1)
* OpenShift platform operators and services
*/
OpenShiftOperatorAPIGroupDSL operator();
interface OpenShiftOperatorAPIGroupDSL {
/** Authentication operator */
NonNamespaceOperation<Authentication, AuthenticationList, Resource<Authentication>> authentications();
/** Cloud credential management */
NonNamespaceOperation<CloudCredential, CloudCredentialList, Resource<CloudCredential>> cloudCredentials();
/** Console operator */
NonNamespaceOperation<Console, ConsoleList, Resource<Console>> consoles();
/** DNS operator and records */
NonNamespaceOperation<DNS, DNSList, Resource<DNS>> dnses();
MixedOperation<DNSRecord, DNSRecordList, Resource<DNSRecord>> dnsRecords();
/** etcd operator */
NonNamespaceOperation<Etcd, EtcdList, Resource<Etcd>> etcds();
/** Image pruning operations */
NonNamespaceOperation<ImagePruner, ImagePrunerList, Resource<ImagePruner>> imagePruners();
/** Ingress controller management */
MixedOperation<IngressController, IngressControllerList, Resource<IngressController>> ingressControllers();
/** Kubernetes API server operator */
NonNamespaceOperation<KubeAPIServer, KubeAPIServerList, Resource<KubeAPIServer>> kubeAPIServers();
/** Kubernetes controller manager operator */
NonNamespaceOperation<KubeControllerManager, KubeControllerManagerList, Resource<KubeControllerManager>> kubeControllerManagers();
/** Kubernetes scheduler operator */
NonNamespaceOperation<KubeScheduler, KubeSchedulerList, Resource<KubeScheduler>> kubeSchedulers();
/** Network operator */
NonNamespaceOperation<Network, NetworkList, Resource<Network>> networks();
/** OpenShift API server operator */
NonNamespaceOperation<OpenShiftAPIServer, OpenShiftAPIServerList, Resource<OpenShiftAPIServer>> openShiftAPIServers();
/** OpenShift controller manager */
NonNamespaceOperation<OpenShiftControllerManager, OpenShiftControllerManagerList, Resource<OpenShiftControllerManager>> openShiftControllerManagers();
/** Service certificate authority */
NonNamespaceOperation<ServiceCA, ServiceCAList, Resource<ServiceCA>> serviceCAs();
/** Storage operator */
NonNamespaceOperation<Storage, StorageList, Resource<Storage>> storages();
}Usage Examples:
// Get authentication operator status
Authentication auth = client.operator().authentications().withName("cluster").get();
// List ingress controllers
IngressControllerList ingressControllers = client.operator().ingressControllers()
.inNamespace("openshift-ingress-operator")
.list();
// Get console operator status
Console console = client.operator().consoles().withName("cluster").get();
String consoleURL = console.getStatus().getConsoleURL();
// Configure image pruning
ImagePruner pruner = new ImagePrunerBuilder()
.withMetadata(new ObjectMetaBuilder()
.withName("cluster")
.build())
.withSpec(new ImagePrunerSpecBuilder()
.withSchedule("0 0 * * *") // Daily at midnight
.withKeepYoungerThan("24h")
.withKeepTagRevisions(5)
.withSuccessfulJobsHistoryLimit(3)
.withFailedJobsHistoryLimit(3)
.build())
.build();
client.operator().imagePruners().createOrReplace(pruner);Management of operator catalogs, package manifests, and catalog sources for operator discovery.
/**
* Catalog source management for operator repositories
*/
MixedOperation<CatalogSource, CatalogSourceList, Resource<CatalogSource>> catalogSources();
/**
* Package manifest access for operator metadata
*/
MixedOperation<PackageManifest, PackageManifestList, Resource<PackageManifest>> packageManifests();Usage Examples:
// List catalog sources
CatalogSourceList catalogs = client.operatorHub().catalogSources()
.inNamespace("openshift-marketplace")
.list();
// Create custom catalog source
CatalogSource customCatalog = new CatalogSourceBuilder()
.withMetadata(new ObjectMetaBuilder()
.withName("my-catalog")
.withNamespace("openshift-marketplace")
.build())
.withSpec(new CatalogSourceSpecBuilder()
.withSourceType("grpc")
.withImage("quay.io/my-org/my-catalog:latest")
.withDisplayName("My Custom Catalog")
.withPublisher("My Organization")
.build())
.build();
client.operatorHub().catalogSources()
.inNamespace("openshift-marketplace")
.create(customCatalog);
// Search for specific operator
PackageManifest prometheus = client.operatorHub().packageManifests()
.inNamespace("openshift-marketplace")
.withName("prometheus")
.get();
if (prometheus != null) {
List<String> channels = prometheus.getStatus().getChannels().stream()
.map(c -> c.getName())
.collect(Collectors.toList());
System.out.println("Available channels: " + channels);
}Operator group configuration for controlling operator installation scope and permissions.
/**
* Operator groups for namespace-scoped operator management
*/
MixedOperation<OperatorGroup, OperatorGroupList, Resource<OperatorGroup>> operatorGroups();Usage Examples:
// Create operator group for namespace
OperatorGroup operatorGroup = new OperatorGroupBuilder()
.withMetadata(new ObjectMetaBuilder()
.withName("my-operators")
.withNamespace("my-operators")
.build())
.withSpec(new OperatorGroupSpecBuilder()
.withTargetNamespaces("my-app-namespace")
.build())
.build();
client.operatorHub().operatorGroups()
.inNamespace("my-operators")
.create(operatorGroup);
// List operator groups
OperatorGroupList groups = client.operatorHub().operatorGroups()
.inAnyNamespace()
.list();Manage operator installation plans, approvals, and upgrade processes.
/**
* Installation plans for operator deployment coordination
*/
MixedOperation<InstallPlan, InstallPlanList, Resource<InstallPlan>> installPlans();
/**
* Operator subscriptions for automated updates
*/
MixedOperation<Subscription, SubscriptionList, Resource<Subscription>> subscriptions();Usage Examples:
// List pending install plans
InstallPlanList pendingPlans = client.operatorHub().installPlans()
.inAnyNamespace()
.withField("spec.approved", "false")
.list();
// Approve install plan
InstallPlan plan = client.operatorHub().installPlans()
.inNamespace("operators")
.withName("install-plan-name")
.get();
if (plan != null && !plan.getSpec().getApproved()) {
plan.getSpec().setApproved(true);
client.operatorHub().installPlans()
.inNamespace("operators")
.withName("install-plan-name")
.replace(plan);
}
// Update subscription channel
Subscription sub = client.operatorHub().subscriptions()
.inNamespace("operators")
.withName("my-operator")
.get();
if (sub != null) {
sub.getSpec().setChannel("stable-v2");
client.operatorHub().subscriptions()
.inNamespace("operators")
.withName("my-operator")
.replace(sub);
}try (OpenShiftClient client = new KubernetesClientBuilder().build().adapt(OpenShiftClient.class)) {
String operatorNamespace = "my-operators";
String operatorName = "prometheus";
// 1. Create operator group (if needed)
OperatorGroup og = new OperatorGroupBuilder()
.withMetadata(new ObjectMetaBuilder()
.withName("my-operators")
.withNamespace(operatorNamespace)
.build())
.build();
client.operatorHub().operatorGroups()
.inNamespace(operatorNamespace)
.createOrReplace(og);
// 2. Create subscription
Subscription subscription = new SubscriptionBuilder()
.withMetadata(new ObjectMetaBuilder()
.withName(operatorName)
.withNamespace(operatorNamespace)
.build())
.withSpec(new SubscriptionSpecBuilder()
.withChannel("stable")
.withName(operatorName)
.withSource("community-operators")
.withSourceNamespace("openshift-marketplace")
.withInstallPlanApproval("Manual") // or "Automatic"
.build())
.build();
client.operatorHub().subscriptions()
.inNamespace(operatorNamespace)
.create(subscription);
// 3. Wait for and approve install plan (if manual approval)
// This would typically be done in a loop with proper timeout handling
InstallPlan installPlan = waitForInstallPlan(client, operatorNamespace, operatorName);
if (installPlan != null && !installPlan.getSpec().getApproved()) {
installPlan.getSpec().setApproved(true);
client.operatorHub().installPlans()
.inNamespace(operatorNamespace)
.replace(installPlan);
}
// 4. Wait for CSV to be ready
ClusterServiceVersion csv = waitForCSV(client, operatorNamespace, operatorName);
System.out.println("Operator installed: " + csv.getMetadata().getName());
}Install with Tessl CLI
npx tessl i tessl/maven-io-fabric8--openshift-client