From 3ad685fa1ba79e9c7d656078fc2a4c92d5a2acb1 Mon Sep 17 00:00:00 2001 From: Gili Tzabari Date: Mon, 13 Jan 2025 10:55:03 -0500 Subject: [PATCH 1/2] Updated ServerSideApply section of CHEATSHEET.md --- doc/CHEATSHEET.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/doc/CHEATSHEET.md b/doc/CHEATSHEET.md index ecb0c21445c..3c85c506627 100644 --- a/doc/CHEATSHEET.md +++ b/doc/CHEATSHEET.md @@ -2393,18 +2393,16 @@ try (KubernetesClient client = new KubernetesClientBuilder().build()) { #### Server Side Apply -Basic usage of server side apply is available via Patchable. At it's simplest you just need to call: +To create a new resource or update an existing one, you just need to call: ```java -client.services().withName("name").patch(PatchContext.of(PatchType.SERVER_SIDE_APPLY), service); +DeploymentConfig dc = client.deploymentConfigs().inNamespace("default").resource(dcToCreate).serverSideApply(); ``` -For any create or update. This can be a good alternative to using createOrReplace as it is always a single api call and does not issue a replace/PUT which can be problematic. - -If the resources may be created or modified by something other than a fabric8 patch, you will need to force your modifications: +For resources that are updated by other [FieldManagers](https://kubernetes.io/docs/reference/using-api/server-side-apply/#managers), you will need to force your modifications: ```java -client.services().withName("name").patch(new PatchContext.Builder().withPatchType(PatchType.SERVER_SIDE_APPLY).withForce(true).build(), service); +DeploymentConfig dc = client.deploymentConfigs().inNamespace("default").resource(dcToCreate).forceConflicts().serverSideApply(); ``` Please consult the Kubernetes server side apply documentation if you want to do more detailed field management or want to understand the full semantics of how the patches are merged. From f2bf1116843ffb7fa6ca4940a566ff9de1d3920f Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Tue, 14 Jan 2025 12:38:52 +0100 Subject: [PATCH 2/2] Update doc/CHEATSHEET.md Co-authored-by: Steven Hawkins --- doc/CHEATSHEET.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/CHEATSHEET.md b/doc/CHEATSHEET.md index 3c85c506627..63270dabf67 100644 --- a/doc/CHEATSHEET.md +++ b/doc/CHEATSHEET.md @@ -2399,7 +2399,7 @@ To create a new resource or update an existing one, you just need to call: DeploymentConfig dc = client.deploymentConfigs().inNamespace("default").resource(dcToCreate).serverSideApply(); ``` -For resources that are updated by other [FieldManagers](https://kubernetes.io/docs/reference/using-api/server-side-apply/#managers), you will need to force your modifications: +For resources that are updated by other [FieldManagers](https://kubernetes.io/docs/reference/using-api/server-side-apply/#managers), you will need to force your modifications when there is a conflict: ```java DeploymentConfig dc = client.deploymentConfigs().inNamespace("default").resource(dcToCreate).forceConflicts().serverSideApply();