@@ -47,6 +47,8 @@ public class PatchExample {
4747 "{\" metadata\" :{\" $deleteFromPrimitiveList/finalizers\" :[\" example.com/test\" ]}}" ;
4848 static String jsonDeploymentStr =
4949 "{\" kind\" :\" Deployment\" ,\" apiVersion\" :\" extensions/v1beta1\" ,\" metadata\" :{\" name\" :\" hello-node\" ,\" finalizers\" :[\" example.com/test\" ],\" labels\" :{\" run\" :\" hello-node\" }},\" spec\" :{\" replicas\" :1,\" selector\" :{\" matchLabels\" :{\" run\" :\" hello-node\" }},\" template\" :{\" metadata\" :{\" creationTimestamp\" :null,\" labels\" :{\" run\" :\" hello-node\" }},\" spec\" :{\" terminationGracePeriodSeconds\" :30,\" containers\" :[{\" name\" :\" hello-node\" ,\" image\" :\" hello-node:v1\" ,\" ports\" :[{\" containerPort\" :8080}],\" resources\" :{}}]}},\" strategy\" :{}},\" status\" :{}}" ;
50+ static String applyYamlStr =
51+ "{\" kind\" :\" Deployment\" ,\" apiVersion\" :\" extensions/v1beta1\" ,\" metadata\" :{\" name\" :\" hello-node\" ,\" finalizers\" :[\" example.com/test\" ],\" labels\" :{\" run\" :\" hello-node\" }},\" spec\" :{\" replicas\" :1,\" selector\" :{\" matchLabels\" :{\" run\" :\" hello-node\" }},\" template\" :{\" metadata\" :{\" creationTimestamp\" :null,\" labels\" :{\" run\" :\" hello-node\" }},\" spec\" :{\" terminationGracePeriodSeconds\" :30,\" containers\" :[{\" name\" :\" hello-node\" ,\" image\" :\" hello-node:v2\" ,\" ports\" :[{\" containerPort\" :8080}],\" resources\" :{}}]}},\" strategy\" :{}},\" status\" :{}}" ;
5052
5153 public static void main (String [] args ) throws IOException {
5254 try {
@@ -88,6 +90,16 @@ public static void main(String[] args) throws IOException {
8890 null );
8991 System .out .println ("strategic-merge-patched deployment" + deploy3 );
9092
93+ // apply-yaml a deployment
94+ ApiClient applyYamlClient =
95+ ClientBuilder .standard ().setOverridePatchFormat (V1Patch .PATCH_FORMAT_APPLY_YAML ).build ();
96+ applyYamlClient .setDebugging (true );
97+ ExtensionsV1beta1Deployment deploy4 =
98+ new ExtensionsV1beta1Api (applyYamlClient )
99+ .patchNamespacedDeployment (
100+ "hello-node" , "default" , new V1Patch (applyYamlStr ), null , null , null , null );
101+ System .out .println ("application/apply-patch+yaml deployment" + deploy4 );
102+
91103 } catch (ApiException e ) {
92104 System .out .println (e .getResponseBody ());
93105 e .printStackTrace ();
0 commit comments