CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-io-fabric8--openshift-client

Java client library for OpenShift REST APIs, providing fluent DSL access to OpenShift resources and operations.

Pending
Overview
Eval results
Files

core-resources.mddocs/

Core OpenShift Resources

Essential OpenShift resources including builds, images, routes, templates, and projects. These resources provide the fundamental OpenShift functionality beyond standard Kubernetes capabilities.

Capabilities

Build Management

OpenShift build system for creating container images from source code, with support for various build strategies and triggering mechanisms.

/**
 * Access to Build resources (build.openshift.io/v1)
 * Individual build instances representing a single execution of a BuildConfig
 */
MixedOperation<Build, BuildList, BuildResource> builds();

/**
 * Build resource with log access capabilities
 */
public interface BuildResource extends Resource<Build>, TimestampBytesLimitTerminateTimeTailPrettyLoggable {
    /** Get build logs for a specific version */
    TimestampBytesLimitTerminateTimeTailPrettyLoggable withVersion(Integer version);
}

/**
 * Access to BuildConfig resources (build.openshift.io/v1)
 * Build configurations define how to build container images
 */
MixedOperation<BuildConfig, BuildConfigList, BuildConfigResource<BuildConfig, Void, Build>> buildConfigs();

/**
 * BuildConfig resource with build triggering capabilities
 */
public interface BuildConfigResource<T, D, B> extends Resource<T> {
    /** Trigger a build from this BuildConfig */
    B instantiate(BuildRequest request);
    
    /** Create a binary build with commit metadata support */
    CommitterAuthorMessageAsFileTimeoutInputStreamable<B> instantiateBinary();
}

Usage Examples:

// List all builds in namespace
BuildList builds = client.builds().inNamespace("myproject").list();

// Get specific build and its logs
Build build = client.builds().inNamespace("myproject").withName("myapp-1").get();
if (build != null) {
    String logs = client.builds()
        .inNamespace("myproject")
        .withName("myapp-1")
        .getLog();
}

// Trigger a build from BuildConfig
BuildRequest request = new BuildRequestBuilder()
    .withMetadata(new ObjectMetaBuilder().withName("myapp-2").build())
    .build();

Build newBuild = client.buildConfigs()
    .inNamespace("myproject")
    .withName("myapp")
    .instantiate(request);

// Create binary build with metadata
Build binaryBuild = client.buildConfigs()
    .inNamespace("myproject")
    .withName("myapp")
    .instantiateBinary()
    .withAuthorName("John Doe")
    .withAuthorEmail("john@example.com")
    .withMessage("Binary build from local source")
    .fromFile(new File("app.tar.gz"));

Image Management

OpenShift image registry integration with image streams, tags, and metadata management.

/**
 * Access to Image resources (image.openshift.io/v1)
 * Individual container images in the integrated registry
 */
NonNamespaceOperation<Image, ImageList, Resource<Image>> images();

/**
 * Access to ImageStream resources (image.openshift.io/v1)
 * Named collections of related container images
 */
MixedOperation<ImageStream, ImageStreamList, Resource<ImageStream>> imageStreams();

/**
 * Access to ImageStreamTag resources (image.openshift.io/v1)
 * Tagged references to specific images in an ImageStream
 */
MixedOperation<ImageStreamTag, ImageStreamTagList, Resource<ImageStreamTag>> imageStreamTags();

/**
 * Access to ImageTag resources (image.openshift.io/v1)
 * Image tag resources for tagging operations
 */
MixedOperation<ImageTag, ImageTagList, Resource<ImageTag>> imageTags();

/**
 * Access to ImageStreamImport operations (image.openshift.io/v1)
 * Import images from external registries into ImageStreams
 */
NamespacedInOutCreateable<ImageStreamImport, ImageStreamImport> imageStreamImports();

/**
 * Access to ImageStreamMapping operations (image.openshift.io/v1)
 * Map images to ImageStreams
 */
NamespacedInOutCreateable<ImageStreamMapping, ImageStreamMapping> imageStreamMappings();

/**
 * Access to ImageStreamImage operations (image.openshift.io/v1)
 * Reference specific images within ImageStreams
 */
Namespaceable<Nameable<? extends Gettable<ImageStreamImage>>> imageStreamImages();

/**
 * Access to ImageSignature operations (image.openshift.io/v1)
 * Manage image signatures for verification
 */
NameableCreateOrDeleteable imageSignatures();

Usage Examples:

// List image streams in namespace
ImageStreamList imageStreams = client.imageStreams().inNamespace("myproject").list();

// Get specific image stream
ImageStream myAppImages = client.imageStreams()
    .inNamespace("myproject")
    .withName("myapp")
    .get();

// List image stream tags
ImageStreamTagList tags = client.imageStreamTags()
    .inNamespace("myproject")
    .list();

// Import external image into image stream
ImageStreamImport importRequest = new ImageStreamImportBuilder()
    .withMetadata(new ObjectMetaBuilder()
        .withName("myapp")
        .withNamespace("myproject")
        .build())
    .withSpec(new ImageStreamImportSpecBuilder()
        .addNewImage()
            .withFrom(new ObjectReferenceBuilder()
                .withKind("DockerImage")
                .withName("docker.io/myorg/myapp:latest")
                .build())
            .withTo(new LocalObjectReferenceBuilder().withName("latest").build())
        .endImage()
        .build())
    .build();

ImageStreamImport result = client.imageStreamImports()
    .inNamespace("myproject")
    .create(importRequest);

Application Deployment

OpenShift deployment configurations providing enhanced deployment capabilities beyond Kubernetes Deployments.

/**
 * Access to DeploymentConfig resources (apps.openshift.io/v1)
 * OpenShift deployment configurations with advanced deployment strategies
 */
MixedOperation<DeploymentConfig, DeploymentConfigList, DeployableScalableResource<DeploymentConfig>> deploymentConfigs();

/**
 * DeploymentConfig resource with deployment and scaling capabilities
 */
public interface DeployableScalableResource<T> extends ScalableResource<T>, TimeoutDeployable<T> {
    /** Deploy latest version (deprecated) */
    @Deprecated
    T deployLatest(boolean wait);
}

/**
 * Deployment operations with timeout support
 */
public interface TimeoutDeployable<T> extends TimeoutableScalable<T> {
    /** Deploy latest version */
    T deployLatest();
    
    /** Set timeout for deployment operations */
    TimeoutDeployable<T> withTimeout(long timeout, TimeUnit unit);
    
    /** Set timeout in milliseconds */
    TimeoutDeployable<T> withTimeoutInMillis(long timeoutInMillis);
}

Usage Examples:

// List deployment configurations
DeploymentConfigList deploymentConfigs = client.deploymentConfigs()
    .inNamespace("myproject")
    .list();

// Get specific deployment config
DeploymentConfig myAppDC = client.deploymentConfigs()
    .inNamespace("myproject")
    .withName("myapp")
    .get();

// Scale deployment config
client.deploymentConfigs()
    .inNamespace("myproject")
    .withName("myapp")
    .scale(3);

// Trigger new deployment
client.deploymentConfigs()
    .inNamespace("myproject")
    .withName("myapp")
    .deployLatest();

// Deploy with timeout
client.deploymentConfigs()
    .inNamespace("myproject")
    .withName("myapp")
    .withTimeout(5, TimeUnit.MINUTES)
    .deployLatest();

Route Management

OpenShift routes provide HTTP/HTTPS ingress to services with advanced routing features.

/**
 * Access to Route resources (route.openshift.io/v1)
 * HTTP/HTTPS routing to services with SSL termination and load balancing
 */
MixedOperation<Route, RouteList, Resource<Route>> routes();

Usage Examples:

// List routes in namespace
RouteList routes = client.routes().inNamespace("myproject").list();

// Create a route
Route route = new RouteBuilder()
    .withMetadata(new ObjectMetaBuilder()
        .withName("myapp-route")
        .withNamespace("myproject")
        .build())
    .withSpec(new RouteSpecBuilder()
        .withHost("myapp.apps.cluster.com")
        .withTo(new RouteTargetReferenceBuilder()
            .withKind("Service")
            .withName("myapp-service")
            .build())
        .withTls(new TLSConfigBuilder()
            .withTermination("edge")
            .build())
        .build())
    .build();

Route createdRoute = client.routes().inNamespace("myproject").create(route);

// Get route URL
String routeURL = "https://" + createdRoute.getSpec().getHost();

Template Processing

OpenShift templates provide parameterized resource definitions for application deployment.

/**
 * Access to Template resources (template.openshift.io/v1)
 * Parameterized resource definitions for repeatable deployments
 */
ParameterMixedOperation<Template, TemplateList, TemplateResource> templates();

/**
 * Template resource with parameter processing capabilities
 */
public interface TemplateResource extends Resource<Template> {
    /** Process template with parameters from file */
    KubernetesResourceList<HasMetadata> process(File f);
    
    /** Process template with parameters from input stream */
    KubernetesResourceList<HasMetadata> process(InputStream is);
    
    /** Process template with parameter map */
    KubernetesResourceList<HasMetadata> process(Map<String, String> map);
    
    /** Process template with parameter values */
    KubernetesResourceList<HasMetadata> process(ParameterValue... values);
    
    /** Process template locally (client-side) with parameters from file */
    KubernetesResourceList<HasMetadata> processLocally(File f);
    
    /** Process template locally with parameters from input stream */
    KubernetesResourceList<HasMetadata> processLocally(InputStream is);
    
    /** Process template locally with parameter map */
    KubernetesResourceList<HasMetadata> processLocally(Map<String, String> map);
    
    /** Process template locally with parameter values */
    KubernetesResourceList<HasMetadata> processLocally(ParameterValue... values);
}

/**
 * Access to TemplateInstance resources (template.openshift.io/v1)
 * Template instantiation records
 */
MixedOperation<TemplateInstance, TemplateInstanceList, Resource<TemplateInstance>> templateInstances();

/**
 * Access to BrokerTemplateInstance resources (template.openshift.io/v1)
 * Broker-managed template instances
 */
NonNamespaceOperation<BrokerTemplateInstance, BrokerTemplateInstanceList, Resource<BrokerTemplateInstance>> brokerTemplateInstances();

Usage Examples:

// Process template with parameters
Map<String, String> parameters = new HashMap<>();
parameters.put("APPLICATION_NAME", "myapp");
parameters.put("DATABASE_USER", "admin");
parameters.put("DATABASE_PASSWORD", "secret");

KubernetesResourceList<HasMetadata> processedObjects = client.templates()
    .inNamespace("myproject")
    .withName("myapp-template")
    .process(parameters);

// Create the processed objects
client.resourceList(processedObjects).inNamespace("myproject").createOrReplace();

// Process template with ParameterValue objects
ParameterValue[] params = {
    ParameterValue.pair("APPLICATION_NAME", "myapp"),
    ParameterValue.pair("REPLICAS", "3")
};

KubernetesResourceList<HasMetadata> objects = client.templates()
    .inNamespace("myproject")
    .withName("myapp-template")
    .process(params);

// Process locally (client-side processing)
KubernetesResourceList<HasMetadata> localProcessed = client.templates()
    .inNamespace("myproject")
    .withName("myapp-template")
    .processLocally(parameters);

Project Management

OpenShift projects provide namespace isolation with additional RBAC and resource management features.

/**
 * Access to Project operations (project.openshift.io/v1)
 * OpenShift projects with enhanced namespace management
 */
ProjectOperation projects();

/**
 * Project operations with RBAC integration
 */
public interface ProjectOperation extends NonNamespaceOperation<Project, ProjectList, Resource<Project>> {
    /** Create project with role bindings */
    Project createProjectAndRoleBindings(String name, String description, String displayName, 
                                       String adminUser, String requestingUser);
}

/**
 * Access to ProjectRequest operations (project.openshift.io/v1)
 * Project creation request workflow
 */
ProjectRequestOperation projectrequests();

/**
 * Project request operations
 */
public interface ProjectRequestOperation extends InOutCreateable<ProjectRequest, ProjectRequest> {
}

Usage Examples:

// List projects
ProjectList projects = client.projects().list();

// Create project with role bindings
Project newProject = client.projects().createProjectAndRoleBindings(
    "myproject",
    "My Application Project", 
    "My Application",
    "admin-user",
    "developer-user"
);

// Create project request
ProjectRequest request = new ProjectRequestBuilder()
    .withMetadata(new ObjectMetaBuilder()
        .withName("myproject")
        .build())
    .withDisplayName("My Application")
    .withDescription("Project for my application")
    .build();

ProjectRequest createdRequest = client.projectrequests().create(request);

// Get current project
try (NamespacedOpenShiftClient namespacedClient = client.inNamespace("myproject")) {
    String currentNamespace = namespacedClient.getNamespace();
    Project currentProject = client.projects().withName(currentNamespace).get();
}

Type Definitions

/**
 * Parameter value for template processing
 */
public class ParameterValue {
    public static ParameterValue pair(String name, String value);
    public String getName();
    public String getValue();
}

/**
 * Build request for triggering builds
 */
public class BuildRequest {
    public ObjectMeta getMetadata();
    public void setMetadata(ObjectMeta metadata);
    public BuildSpec getTriggeredBy();
    public void setTriggeredBy(BuildSpec triggeredBy);
}

/**
 * Binary build configuration interfaces
 */
public interface CommitterAuthorMessageAsFileTimeoutInputStreamable<T> 
    extends AuthorMessageAsFileTimeoutInputStreamable<T> {
    CommitterEmailable<AuthorMessageAsFileTimeoutInputStreamable<T>> withCommitterName(String committerName);
}

public interface AuthorMessageAsFileTimeoutInputStreamable<T> 
    extends MessageAsFileTimeoutInputStreamable<T> {
    AuthorEmailable<MessageAsFileTimeoutInputStreamable<T>> withAuthorName(String authorName);
}

public interface MessageAsFileTimeoutInputStreamable<T> extends AsFileTimeoutInputStreamable<T> {
    AuthorMessageAsFileTimeoutInputStreamable<T> withMessage(String message);
}

/**
 * Additional Core Resource Methods from OpenShiftClient interface
 */

// Credential Management
MixedOperation<CredentialsRequest, CredentialsRequestList, Resource<CredentialsRequest>> credentialsRequests();

// Helm Chart Repository Management  
NonNamespaceOperation<HelmChartRepository, HelmChartRepositoryList, Resource<HelmChartRepository>> helmChartRepositories();
MixedOperation<ProjectHelmChartRepository, ProjectHelmChartRepositoryList, Resource<ProjectHelmChartRepository>> projectHelmChartRepositories();

// Network Attachment Definitions
MixedOperation<NetworkAttachmentDefinition, NetworkAttachmentDefinitionList, Resource<NetworkAttachmentDefinition>> networkAttachmentDefinitions();

// API Request Count Monitoring
NonNamespaceOperation<APIRequestCount, APIRequestCountList, Resource<APIRequestCount>> apiRequestCounts();

// Image Registry Operator Configuration
NonNamespaceOperation<io.fabric8.openshift.api.model.operator.imageregistry.v1.Config, io.fabric8.openshift.api.model.operator.imageregistry.v1.ConfigList, Resource<io.fabric8.openshift.api.model.operator.imageregistry.v1.Config>> imageRegistryOperatorConfigs();

// Bare Metal Host Management (Metal3)
MixedOperation<BareMetalHost, BareMetalHostList, Resource<BareMetalHost>> bareMetalHosts();

// Metal3 Remediation Resources
MixedOperation<Metal3Remediation, Metal3RemediationList, Resource<Metal3Remediation>> metal3Remediations();
MixedOperation<Metal3RemediationTemplate, Metal3RemediationTemplateList, Resource<Metal3RemediationTemplate>> metal3RemediationTemplates();

// Network Operator Resources
MixedOperation<OperatorPKI, OperatorPKIList, Resource<OperatorPKI>> operatorPKIs();
MixedOperation<EgressRouter, EgressRouterList, Resource<EgressRouter>> egressRouters();

Install with Tessl CLI

npx tessl i tessl/maven-io-fabric8--openshift-client

docs

client-setup.md

configuration-management.md

core-resources.md

index.md

machine-management.md

monitoring.md

multicluster-management.md

operator-management.md

security-rbac.md

tile.json