0
# Core OpenShift Resources
1
2
Essential OpenShift resources including builds, images, routes, templates, and projects. These resources provide the fundamental OpenShift functionality beyond standard Kubernetes capabilities.
3
4
## Capabilities
5
6
### Build Management
7
8
OpenShift build system for creating container images from source code, with support for various build strategies and triggering mechanisms.
9
10
```java { .api }
11
/**
12
* Access to Build resources (build.openshift.io/v1)
13
* Individual build instances representing a single execution of a BuildConfig
14
*/
15
MixedOperation<Build, BuildList, BuildResource> builds();
16
17
/**
18
* Build resource with log access capabilities
19
*/
20
public interface BuildResource extends Resource<Build>, TimestampBytesLimitTerminateTimeTailPrettyLoggable {
21
/** Get build logs for a specific version */
22
TimestampBytesLimitTerminateTimeTailPrettyLoggable withVersion(Integer version);
23
}
24
25
/**
26
* Access to BuildConfig resources (build.openshift.io/v1)
27
* Build configurations define how to build container images
28
*/
29
MixedOperation<BuildConfig, BuildConfigList, BuildConfigResource<BuildConfig, Void, Build>> buildConfigs();
30
31
/**
32
* BuildConfig resource with build triggering capabilities
33
*/
34
public interface BuildConfigResource<T, D, B> extends Resource<T> {
35
/** Trigger a build from this BuildConfig */
36
B instantiate(BuildRequest request);
37
38
/** Create a binary build with commit metadata support */
39
CommitterAuthorMessageAsFileTimeoutInputStreamable<B> instantiateBinary();
40
}
41
```
42
43
**Usage Examples:**
44
45
```java
46
// List all builds in namespace
47
BuildList builds = client.builds().inNamespace("myproject").list();
48
49
// Get specific build and its logs
50
Build build = client.builds().inNamespace("myproject").withName("myapp-1").get();
51
if (build != null) {
52
String logs = client.builds()
53
.inNamespace("myproject")
54
.withName("myapp-1")
55
.getLog();
56
}
57
58
// Trigger a build from BuildConfig
59
BuildRequest request = new BuildRequestBuilder()
60
.withMetadata(new ObjectMetaBuilder().withName("myapp-2").build())
61
.build();
62
63
Build newBuild = client.buildConfigs()
64
.inNamespace("myproject")
65
.withName("myapp")
66
.instantiate(request);
67
68
// Create binary build with metadata
69
Build binaryBuild = client.buildConfigs()
70
.inNamespace("myproject")
71
.withName("myapp")
72
.instantiateBinary()
73
.withAuthorName("John Doe")
74
.withAuthorEmail("john@example.com")
75
.withMessage("Binary build from local source")
76
.fromFile(new File("app.tar.gz"));
77
```
78
79
### Image Management
80
81
OpenShift image registry integration with image streams, tags, and metadata management.
82
83
```java { .api }
84
/**
85
* Access to Image resources (image.openshift.io/v1)
86
* Individual container images in the integrated registry
87
*/
88
NonNamespaceOperation<Image, ImageList, Resource<Image>> images();
89
90
/**
91
* Access to ImageStream resources (image.openshift.io/v1)
92
* Named collections of related container images
93
*/
94
MixedOperation<ImageStream, ImageStreamList, Resource<ImageStream>> imageStreams();
95
96
/**
97
* Access to ImageStreamTag resources (image.openshift.io/v1)
98
* Tagged references to specific images in an ImageStream
99
*/
100
MixedOperation<ImageStreamTag, ImageStreamTagList, Resource<ImageStreamTag>> imageStreamTags();
101
102
/**
103
* Access to ImageTag resources (image.openshift.io/v1)
104
* Image tag resources for tagging operations
105
*/
106
MixedOperation<ImageTag, ImageTagList, Resource<ImageTag>> imageTags();
107
108
/**
109
* Access to ImageStreamImport operations (image.openshift.io/v1)
110
* Import images from external registries into ImageStreams
111
*/
112
NamespacedInOutCreateable<ImageStreamImport, ImageStreamImport> imageStreamImports();
113
114
/**
115
* Access to ImageStreamMapping operations (image.openshift.io/v1)
116
* Map images to ImageStreams
117
*/
118
NamespacedInOutCreateable<ImageStreamMapping, ImageStreamMapping> imageStreamMappings();
119
120
/**
121
* Access to ImageStreamImage operations (image.openshift.io/v1)
122
* Reference specific images within ImageStreams
123
*/
124
Namespaceable<Nameable<? extends Gettable<ImageStreamImage>>> imageStreamImages();
125
126
/**
127
* Access to ImageSignature operations (image.openshift.io/v1)
128
* Manage image signatures for verification
129
*/
130
NameableCreateOrDeleteable imageSignatures();
131
```
132
133
**Usage Examples:**
134
135
```java
136
// List image streams in namespace
137
ImageStreamList imageStreams = client.imageStreams().inNamespace("myproject").list();
138
139
// Get specific image stream
140
ImageStream myAppImages = client.imageStreams()
141
.inNamespace("myproject")
142
.withName("myapp")
143
.get();
144
145
// List image stream tags
146
ImageStreamTagList tags = client.imageStreamTags()
147
.inNamespace("myproject")
148
.list();
149
150
// Import external image into image stream
151
ImageStreamImport importRequest = new ImageStreamImportBuilder()
152
.withMetadata(new ObjectMetaBuilder()
153
.withName("myapp")
154
.withNamespace("myproject")
155
.build())
156
.withSpec(new ImageStreamImportSpecBuilder()
157
.addNewImage()
158
.withFrom(new ObjectReferenceBuilder()
159
.withKind("DockerImage")
160
.withName("docker.io/myorg/myapp:latest")
161
.build())
162
.withTo(new LocalObjectReferenceBuilder().withName("latest").build())
163
.endImage()
164
.build())
165
.build();
166
167
ImageStreamImport result = client.imageStreamImports()
168
.inNamespace("myproject")
169
.create(importRequest);
170
```
171
172
### Application Deployment
173
174
OpenShift deployment configurations providing enhanced deployment capabilities beyond Kubernetes Deployments.
175
176
```java { .api }
177
/**
178
* Access to DeploymentConfig resources (apps.openshift.io/v1)
179
* OpenShift deployment configurations with advanced deployment strategies
180
*/
181
MixedOperation<DeploymentConfig, DeploymentConfigList, DeployableScalableResource<DeploymentConfig>> deploymentConfigs();
182
183
/**
184
* DeploymentConfig resource with deployment and scaling capabilities
185
*/
186
public interface DeployableScalableResource<T> extends ScalableResource<T>, TimeoutDeployable<T> {
187
/** Deploy latest version (deprecated) */
188
@Deprecated
189
T deployLatest(boolean wait);
190
}
191
192
/**
193
* Deployment operations with timeout support
194
*/
195
public interface TimeoutDeployable<T> extends TimeoutableScalable<T> {
196
/** Deploy latest version */
197
T deployLatest();
198
199
/** Set timeout for deployment operations */
200
TimeoutDeployable<T> withTimeout(long timeout, TimeUnit unit);
201
202
/** Set timeout in milliseconds */
203
TimeoutDeployable<T> withTimeoutInMillis(long timeoutInMillis);
204
}
205
```
206
207
**Usage Examples:**
208
209
```java
210
// List deployment configurations
211
DeploymentConfigList deploymentConfigs = client.deploymentConfigs()
212
.inNamespace("myproject")
213
.list();
214
215
// Get specific deployment config
216
DeploymentConfig myAppDC = client.deploymentConfigs()
217
.inNamespace("myproject")
218
.withName("myapp")
219
.get();
220
221
// Scale deployment config
222
client.deploymentConfigs()
223
.inNamespace("myproject")
224
.withName("myapp")
225
.scale(3);
226
227
// Trigger new deployment
228
client.deploymentConfigs()
229
.inNamespace("myproject")
230
.withName("myapp")
231
.deployLatest();
232
233
// Deploy with timeout
234
client.deploymentConfigs()
235
.inNamespace("myproject")
236
.withName("myapp")
237
.withTimeout(5, TimeUnit.MINUTES)
238
.deployLatest();
239
```
240
241
### Route Management
242
243
OpenShift routes provide HTTP/HTTPS ingress to services with advanced routing features.
244
245
```java { .api }
246
/**
247
* Access to Route resources (route.openshift.io/v1)
248
* HTTP/HTTPS routing to services with SSL termination and load balancing
249
*/
250
MixedOperation<Route, RouteList, Resource<Route>> routes();
251
```
252
253
**Usage Examples:**
254
255
```java
256
// List routes in namespace
257
RouteList routes = client.routes().inNamespace("myproject").list();
258
259
// Create a route
260
Route route = new RouteBuilder()
261
.withMetadata(new ObjectMetaBuilder()
262
.withName("myapp-route")
263
.withNamespace("myproject")
264
.build())
265
.withSpec(new RouteSpecBuilder()
266
.withHost("myapp.apps.cluster.com")
267
.withTo(new RouteTargetReferenceBuilder()
268
.withKind("Service")
269
.withName("myapp-service")
270
.build())
271
.withTls(new TLSConfigBuilder()
272
.withTermination("edge")
273
.build())
274
.build())
275
.build();
276
277
Route createdRoute = client.routes().inNamespace("myproject").create(route);
278
279
// Get route URL
280
String routeURL = "https://" + createdRoute.getSpec().getHost();
281
```
282
283
### Template Processing
284
285
OpenShift templates provide parameterized resource definitions for application deployment.
286
287
```java { .api }
288
/**
289
* Access to Template resources (template.openshift.io/v1)
290
* Parameterized resource definitions for repeatable deployments
291
*/
292
ParameterMixedOperation<Template, TemplateList, TemplateResource> templates();
293
294
/**
295
* Template resource with parameter processing capabilities
296
*/
297
public interface TemplateResource extends Resource<Template> {
298
/** Process template with parameters from file */
299
KubernetesResourceList<HasMetadata> process(File f);
300
301
/** Process template with parameters from input stream */
302
KubernetesResourceList<HasMetadata> process(InputStream is);
303
304
/** Process template with parameter map */
305
KubernetesResourceList<HasMetadata> process(Map<String, String> map);
306
307
/** Process template with parameter values */
308
KubernetesResourceList<HasMetadata> process(ParameterValue... values);
309
310
/** Process template locally (client-side) with parameters from file */
311
KubernetesResourceList<HasMetadata> processLocally(File f);
312
313
/** Process template locally with parameters from input stream */
314
KubernetesResourceList<HasMetadata> processLocally(InputStream is);
315
316
/** Process template locally with parameter map */
317
KubernetesResourceList<HasMetadata> processLocally(Map<String, String> map);
318
319
/** Process template locally with parameter values */
320
KubernetesResourceList<HasMetadata> processLocally(ParameterValue... values);
321
}
322
323
/**
324
* Access to TemplateInstance resources (template.openshift.io/v1)
325
* Template instantiation records
326
*/
327
MixedOperation<TemplateInstance, TemplateInstanceList, Resource<TemplateInstance>> templateInstances();
328
329
/**
330
* Access to BrokerTemplateInstance resources (template.openshift.io/v1)
331
* Broker-managed template instances
332
*/
333
NonNamespaceOperation<BrokerTemplateInstance, BrokerTemplateInstanceList, Resource<BrokerTemplateInstance>> brokerTemplateInstances();
334
```
335
336
**Usage Examples:**
337
338
```java
339
// Process template with parameters
340
Map<String, String> parameters = new HashMap<>();
341
parameters.put("APPLICATION_NAME", "myapp");
342
parameters.put("DATABASE_USER", "admin");
343
parameters.put("DATABASE_PASSWORD", "secret");
344
345
KubernetesResourceList<HasMetadata> processedObjects = client.templates()
346
.inNamespace("myproject")
347
.withName("myapp-template")
348
.process(parameters);
349
350
// Create the processed objects
351
client.resourceList(processedObjects).inNamespace("myproject").createOrReplace();
352
353
// Process template with ParameterValue objects
354
ParameterValue[] params = {
355
ParameterValue.pair("APPLICATION_NAME", "myapp"),
356
ParameterValue.pair("REPLICAS", "3")
357
};
358
359
KubernetesResourceList<HasMetadata> objects = client.templates()
360
.inNamespace("myproject")
361
.withName("myapp-template")
362
.process(params);
363
364
// Process locally (client-side processing)
365
KubernetesResourceList<HasMetadata> localProcessed = client.templates()
366
.inNamespace("myproject")
367
.withName("myapp-template")
368
.processLocally(parameters);
369
```
370
371
### Project Management
372
373
OpenShift projects provide namespace isolation with additional RBAC and resource management features.
374
375
```java { .api }
376
/**
377
* Access to Project operations (project.openshift.io/v1)
378
* OpenShift projects with enhanced namespace management
379
*/
380
ProjectOperation projects();
381
382
/**
383
* Project operations with RBAC integration
384
*/
385
public interface ProjectOperation extends NonNamespaceOperation<Project, ProjectList, Resource<Project>> {
386
/** Create project with role bindings */
387
Project createProjectAndRoleBindings(String name, String description, String displayName,
388
String adminUser, String requestingUser);
389
}
390
391
/**
392
* Access to ProjectRequest operations (project.openshift.io/v1)
393
* Project creation request workflow
394
*/
395
ProjectRequestOperation projectrequests();
396
397
/**
398
* Project request operations
399
*/
400
public interface ProjectRequestOperation extends InOutCreateable<ProjectRequest, ProjectRequest> {
401
}
402
```
403
404
**Usage Examples:**
405
406
```java
407
// List projects
408
ProjectList projects = client.projects().list();
409
410
// Create project with role bindings
411
Project newProject = client.projects().createProjectAndRoleBindings(
412
"myproject",
413
"My Application Project",
414
"My Application",
415
"admin-user",
416
"developer-user"
417
);
418
419
// Create project request
420
ProjectRequest request = new ProjectRequestBuilder()
421
.withMetadata(new ObjectMetaBuilder()
422
.withName("myproject")
423
.build())
424
.withDisplayName("My Application")
425
.withDescription("Project for my application")
426
.build();
427
428
ProjectRequest createdRequest = client.projectrequests().create(request);
429
430
// Get current project
431
try (NamespacedOpenShiftClient namespacedClient = client.inNamespace("myproject")) {
432
String currentNamespace = namespacedClient.getNamespace();
433
Project currentProject = client.projects().withName(currentNamespace).get();
434
}
435
```
436
437
## Type Definitions
438
439
```java { .api }
440
/**
441
* Parameter value for template processing
442
*/
443
public class ParameterValue {
444
public static ParameterValue pair(String name, String value);
445
public String getName();
446
public String getValue();
447
}
448
449
/**
450
* Build request for triggering builds
451
*/
452
public class BuildRequest {
453
public ObjectMeta getMetadata();
454
public void setMetadata(ObjectMeta metadata);
455
public BuildSpec getTriggeredBy();
456
public void setTriggeredBy(BuildSpec triggeredBy);
457
}
458
459
/**
460
* Binary build configuration interfaces
461
*/
462
public interface CommitterAuthorMessageAsFileTimeoutInputStreamable<T>
463
extends AuthorMessageAsFileTimeoutInputStreamable<T> {
464
CommitterEmailable<AuthorMessageAsFileTimeoutInputStreamable<T>> withCommitterName(String committerName);
465
}
466
467
public interface AuthorMessageAsFileTimeoutInputStreamable<T>
468
extends MessageAsFileTimeoutInputStreamable<T> {
469
AuthorEmailable<MessageAsFileTimeoutInputStreamable<T>> withAuthorName(String authorName);
470
}
471
472
public interface MessageAsFileTimeoutInputStreamable<T> extends AsFileTimeoutInputStreamable<T> {
473
AuthorMessageAsFileTimeoutInputStreamable<T> withMessage(String message);
474
}
475
476
/**
477
* Additional Core Resource Methods from OpenShiftClient interface
478
*/
479
480
// Credential Management
481
MixedOperation<CredentialsRequest, CredentialsRequestList, Resource<CredentialsRequest>> credentialsRequests();
482
483
// Helm Chart Repository Management
484
NonNamespaceOperation<HelmChartRepository, HelmChartRepositoryList, Resource<HelmChartRepository>> helmChartRepositories();
485
MixedOperation<ProjectHelmChartRepository, ProjectHelmChartRepositoryList, Resource<ProjectHelmChartRepository>> projectHelmChartRepositories();
486
487
// Network Attachment Definitions
488
MixedOperation<NetworkAttachmentDefinition, NetworkAttachmentDefinitionList, Resource<NetworkAttachmentDefinition>> networkAttachmentDefinitions();
489
490
// API Request Count Monitoring
491
NonNamespaceOperation<APIRequestCount, APIRequestCountList, Resource<APIRequestCount>> apiRequestCounts();
492
493
// Image Registry Operator Configuration
494
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();
495
496
// Bare Metal Host Management (Metal3)
497
MixedOperation<BareMetalHost, BareMetalHostList, Resource<BareMetalHost>> bareMetalHosts();
498
499
// Metal3 Remediation Resources
500
MixedOperation<Metal3Remediation, Metal3RemediationList, Resource<Metal3Remediation>> metal3Remediations();
501
MixedOperation<Metal3RemediationTemplate, Metal3RemediationTemplateList, Resource<Metal3RemediationTemplate>> metal3RemediationTemplates();
502
503
// Network Operator Resources
504
MixedOperation<OperatorPKI, OperatorPKIList, Resource<OperatorPKI>> operatorPKIs();
505
MixedOperation<EgressRouter, EgressRouterList, Resource<EgressRouter>> egressRouters();
506
```