File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed
examples/src/main/java/io/kubernetes/client/examples
extended/src/main/java/io/kubernetes/client/extended/generic Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -104,6 +104,8 @@ We prepared a few examples for common use-cases which are shown below:
104
104
Leader election utilities to help implement HA controllers.
105
105
- ([ 9.0.0+] ( https://github.com/kubernetes-client/java/tree/client-java-parent-9.0.0 ) ) [ SpringIntegrationControllerExample] ( https://github.com/kubernetes-client/java/blob/master/examples/src/main/java/io/kubernetes/client/examples/SpringControllerExample.java ) :
106
106
Building a kubernetes controller based on spring framework's bean injection.
107
+ - ([ 9.0.0+] ( https://github.com/kubernetes-client/java/tree/client-java-parent-9.0.0 ) ) [ GenericKubernetesClientExample] ( https://github.com/kubernetes-client/java/blob/master/extended/src/main/java/io/kubernetes/client/extended/generic/GenericKubernetesApi.java ) :
108
+ Construct a generic client interface for any kubernetes types, including CRDs.
107
109
108
110
109
111
__ list all pods__ :
Original file line number Diff line number Diff line change 1
1
package io .kubernetes .client .examples ;
2
2
3
3
import com .google .common .annotations .Beta ;
4
+ import io .kubernetes .client .custom .V1Patch ;
4
5
import io .kubernetes .client .extended .generic .GenericKubernetesApi ;
5
6
import io .kubernetes .client .extended .generic .KubernetesApiResponse ;
6
7
import io .kubernetes .client .openapi .ApiClient ;
@@ -17,6 +18,7 @@ public class GenericClientExample {
17
18
18
19
public static void main (String [] args ) throws Exception {
19
20
21
+ // The following codes demonstrates using generic client to manipulate pods
20
22
V1Pod pod =
21
23
new V1Pod ()
22
24
.metadata (new V1ObjectMeta ().name ("foo" ).namespace ("default" ))
@@ -33,6 +35,17 @@ public static void main(String[] args) throws Exception {
33
35
}
34
36
System .out .println ("Created!" );
35
37
38
+ KubernetesApiResponse <V1Pod > patchResponse =
39
+ podClient .patch (
40
+ "default" ,
41
+ "foo" ,
42
+ V1Patch .PATCH_FORMAT_STRATEGIC_MERGE_PATCH ,
43
+ new V1Patch ("{\" metadata\" :{\" finalizers\" :[\" example.io/foo\" ]}}" ));
44
+ if (!patchResponse .isSuccess ()) {
45
+ throw new RuntimeException (patchResponse .getStatus ().toString ());
46
+ }
47
+ System .out .println ("Patched!" );
48
+
36
49
KubernetesApiResponse <V1Pod > deleteResponse = podClient .delete ("default" , "foo" );
37
50
if (!deleteResponse .isSuccess ()) {
38
51
throw new RuntimeException (deleteResponse .getStatus ().toString ());
Original file line number Diff line number Diff line change 1
1
package io .kubernetes .client .extended .generic ;
2
2
3
- import com .google .common .annotations .Beta ;
4
3
import com .google .common .base .Strings ;
5
4
import com .google .gson .Gson ;
6
5
import com .google .gson .JsonElement ;
40
39
* @param <ApiType> the api type parameter
41
40
* @param <ApiListType> the api list type parameter
42
41
*/
43
- @ Beta
44
42
public class GenericKubernetesApi <ApiType , ApiListType > {
45
43
46
44
// TODO(yue9944882): supports status operations..
You can’t perform that action at this time.
0 commit comments