Interface NonDeletingOperation<T>
-
- All Superinterfaces:
CreateOrReplaceable<T>,Deletable,DeletableWithOptions,EditReplacePatchable<T>,GracePeriodConfigurable<PropagationPolicyConfigurable<? extends Deletable>>,ItemReplacable<T>,ItemWritableOperation<T>,PropagationPolicyConfigurable<GracePeriodConfigurable<? extends Deletable>>,Replaceable<T>,ServerSideApplicable<T>,Timeoutable,Updatable<T>
- All Known Subinterfaces:
CertificateSigningRequestResource<T>,ExtensibleResource<T>,NamespaceableResource<T>,PodResource,Resource<T>,RollableScalableResource<T>,ScalableResource<T>,ServiceAccountResource,ServiceResource<T>,V1beta1CertificateSigningRequestResource<T>,WritableOperation<T>
- All Known Implementing Classes:
ExtensibleResourceAdapter,ResourceAdapter
public interface NonDeletingOperation<T> extends CreateOrReplaceable<T>, EditReplacePatchable<T>, Replaceable<T>, ItemReplacable<T>, ItemWritableOperation<T>, ServerSideApplicable<T>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description TcreateOr(Function<NonDeletingOperation<T>,T> conflictAction)Alternative toCreateOrReplaceable.createOrReplace().TeditStatus(UnaryOperator<T> function)Edit the status subresourceTpatchStatus()Does a PATCH request to the /status subresource ignoring changes to anything except the status stanza.default EditReplacePatchable<T>status()Provides edit, patch, and replace methods for the status subresource.EditReplacePatchable<T>subresource(String subresource)Provides edit, patch, and replace methods for the given subresource.NonDeletingOperation<T>unlock()Removes the resource version from the current item.-
Methods inherited from interface io.fabric8.kubernetes.client.dsl.CreateOrReplaceable
create, createOrReplace
-
Methods inherited from interface io.fabric8.kubernetes.client.dsl.Deletable
delete, withTimeout, withTimeoutInMillis
-
Methods inherited from interface io.fabric8.kubernetes.client.dsl.EditReplacePatchable
accept, edit, edit, edit, patch, patch, patch, patch, patch, patch
-
Methods inherited from interface io.fabric8.kubernetes.client.GracePeriodConfigurable
withGracePeriod
-
Methods inherited from interface io.fabric8.kubernetes.client.dsl.ItemReplacable
replace, replaceStatus
-
Methods inherited from interface io.fabric8.kubernetes.client.dsl.ItemWritableOperation
create, createOrReplace, delete, patchStatus, updateStatus
-
Methods inherited from interface io.fabric8.kubernetes.client.PropagationPolicyConfigurable
withPropagationPolicy
-
Methods inherited from interface io.fabric8.kubernetes.client.dsl.Replaceable
replaceStatus, updateStatus
-
Methods inherited from interface io.fabric8.kubernetes.client.dsl.ServerSideApplicable
fieldManager, forceConflicts, serverSideApply
-
-
-
-
Method Detail
-
createOr
T createOr(Function<NonDeletingOperation<T>,T> conflictAction)
Alternative toCreateOrReplaceable.createOrReplace().Will attempt a create, and if that fails will perform the conflictAction.
Most commonly the conflictAction will be NonDeletingOperation::update or NonDeletingOperation::patch, but you are free to provide whatever Function suits your needs.
- Parameters:
conflictAction- to be performed it the create fails with a conflict- Returns:
-
unlock
NonDeletingOperation<T> unlock()
Removes the resource version from the current item. If the operation context was created by name, and without an item, this will fetch the item from the api server first.- Returns:
- NonDeletingOperation that may act on the unlocked item
-
editStatus
T editStatus(UnaryOperator<T> function)
Edit the status subresource- Parameters:
function- to produce a modified status- Returns:
- updated object
-
patchStatus
T patchStatus()
Does a PATCH request to the /status subresource ignoring changes to anything except the status stanza.This method has the same patching behavior as
EditReplacePatchable.patch(PatchContext), withPatchType.JSON_MERGEbut against the status subresource.Set the resourceVersion to null to prevent optimistic locking.
- Returns:
- updated object
-
subresource
EditReplacePatchable<T> subresource(String subresource)
Provides edit, patch, and replace methods for the given subresource.This method allows you to perform operations on any subresource of a Kubernetes resource, similar to kubectl's
--subresourceflag. Subresources are specialized endpoints that provide additional operations beyond standard CRUD operations.Common Kubernetes Subresources:
- status - Updates the status stanza independently (use
status()convenience method) - scale - Manages replica counts for scalable resources (Deployment, ReplicaSet, StatefulSet, etc.)
- ephemeralcontainers - Manages ephemeral containers for debugging Pods
- binding - Binds Pods to Nodes (typically handled by the Kubernetes scheduler)
- approval - Approves CertificateSigningRequests
- token - Requests bound service account tokens (use ServiceAccountResource#tokenRequest())
- Custom subresources - Defined by CustomResourceDefinitions (CRDs)
Example usage:
// 1. Update ephemeral containers subresource (for debugging) client.pods().withName("my-pod") .subresource("ephemeralcontainers") .edit(pod -> new PodBuilder(pod) .editSpec() .addNewEphemeralContainer() .withName("debugger") .withImage("busybox:latest") .withCommand("sh") .endEphemeralContainer() .endSpec() .build()); // 2. Patch scale subresource to change replica count // (alternative to using the Scalable interface) client.apps().deployments() .inNamespace("default") .withName("my-deployment") .subresource("scale") .patch(PatchContext.of(PatchType.JSON_MERGE), "{\"spec\":{\"replicas\":5}}"); // 3. Update status subresource (prefer using status() method) client.pods().resource(myPod) .subresource("status") .patch(); // 4. Work with custom subresources on CRDs client.resources(MyCustomResource.class) .inNamespace("default") .withName("my-resource") .subresource("my-custom-subresource") .patch();Note: For common operations, consider using specialized methods or interfaces:
- For status updates, use
status(),editStatus(UnaryOperator), orpatchStatus() - For scaling operations, use
Scalableinterface methods - For Pod ephemeral containers, use
PodResource.ephemeralContainers() - For CertificateSigningRequest approval/denial, use
subresource("approval")
- Parameters:
subresource- the name of the subresource (e.g., "status", "scale", "ephemeralcontainers", "binding", "approval")- Returns:
- an operation context for the specified subresource that supports edit, patch, and replace operations
- See Also:
status(),Scalable, Kubernetes API Concepts - Subresources
- status - Updates the status stanza independently (use
-
status
default EditReplacePatchable<T> status()
Provides edit, patch, and replace methods for the status subresource.This is a convenience method equivalent to
subresource("status"). The status subresource is used to update the status stanza of a Kubernetes resource without modifying the spec or metadata.Example usage:
// Update custom resource status client.resources(MyCustomResource.class) .withName("my-resource") .status() .edit(resource -> { resource.setStatus(new MyCustomResourceStatus()); return resource; }); // Patch status directly myResource.getStatus().setPhase("Ready"); client.resource(myResource) .status() .patch();- Returns:
- an operation context for the status subresource
- See Also:
subresource(String),editStatus(UnaryOperator),patchStatus()
-
-