Skip to content

Commit 731e49d

Browse files
committed
adding example for release-20 and remove release-16 example
Signed-off-by: Min Jin <[email protected]>
1 parent e8dc2a9 commit 731e49d

File tree

95 files changed

+3377
-231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+3377
-231
lines changed

examples/examples-release-19/pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,27 @@
3232
<dependency>
3333
<groupId>io.kubernetes</groupId>
3434
<artifactId>client-java-api</artifactId>
35-
<version>${project.version}</version>
35+
<version>19.0.0</version>
3636
</dependency>
3737
<dependency>
3838
<groupId>io.kubernetes</groupId>
3939
<artifactId>client-java</artifactId>
40-
<version>${project.version}</version>
40+
<version>19.0.0</version>
4141
</dependency>
4242
<dependency>
4343
<groupId>io.kubernetes</groupId>
4444
<artifactId>client-java-extended</artifactId>
45-
<version>${project.version}</version>
45+
<version>19.0.0</version>
4646
</dependency>
4747
<dependency>
4848
<groupId>io.kubernetes</groupId>
4949
<artifactId>client-java-spring-integration</artifactId>
50-
<version>${project.version}</version>
50+
<version>19.0.0</version>
5151
</dependency>
5252
<dependency>
5353
<groupId>io.kubernetes</groupId>
5454
<artifactId>client-java-proto</artifactId>
55-
<version>${project.version}</version>
55+
<version>19.0.0</version>
5656
</dependency>
5757
<dependency>
5858
<groupId>commons-cli</groupId>

examples/examples-release-19/src/main/java/io/kubernetes/client/examples/ControllerExample.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,19 @@ public static void main(String[] args) throws IOException {
5656
SharedIndexInformer<V1Node> nodeInformer =
5757
informerFactory.sharedIndexInformerFor(
5858
(CallGeneratorParams params) -> {
59-
return coreV1Api.listNode()
60-
.resourceVersion(params.resourceVersion)
61-
.timeoutSeconds(params.timeoutSeconds)
62-
.watch(params.watch)
63-
.buildCall(null);
59+
return coreV1Api.listNodeCall(
60+
null,
61+
null,
62+
null,
63+
null,
64+
null,
65+
null,
66+
params.resourceVersion,
67+
null,
68+
null,
69+
params.timeoutSeconds,
70+
params.watch,
71+
null);
6472
},
6573
V1Node.class,
6674
V1NodeList.class);

examples/examples-release-19/src/main/java/io/kubernetes/client/examples/DeployRolloutRestartExample.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public static void main(String[] args) throws IOException, ApiException {
6464
.name(deploymentName)
6565
.image(imageName))))));
6666
appsV1Api.createNamespacedDeployment(
67-
namespace, deploymentBuilder.build()).execute();
67+
namespace, deploymentBuilder.build(), null, null, null, null);
6868

6969
// Wait until example deployment is ready
7070
Wait.poll(
@@ -74,8 +74,7 @@ public static void main(String[] args) throws IOException, ApiException {
7474
try {
7575
System.out.println("Waiting until example deployment is ready...");
7676
return appsV1Api
77-
.readNamespacedDeployment(deploymentName, namespace)
78-
.execute()
77+
.readNamespacedDeployment(deploymentName, namespace, null)
7978
.getStatus()
8079
.getReadyReplicas()
8180
> 0;
@@ -88,7 +87,7 @@ public static void main(String[] args) throws IOException, ApiException {
8887

8988
// Trigger a rollout restart of the example deployment
9089
V1Deployment runningDeployment =
91-
appsV1Api.readNamespacedDeployment(deploymentName, namespace).execute();
90+
appsV1Api.readNamespacedDeployment(deploymentName, namespace, null);
9291

9392
// Explicitly set "restartedAt" annotation with current date/time to trigger rollout when patch
9493
// is applied
@@ -103,12 +102,16 @@ public static void main(String[] args) throws IOException, ApiException {
103102
PatchUtils.patch(
104103
V1Deployment.class,
105104
() ->
106-
appsV1Api.patchNamespacedDeployment(
105+
appsV1Api.patchNamespacedDeploymentCall(
107106
deploymentName,
108107
namespace,
109-
new V1Patch(deploymentJson))
110-
.fieldManager("kubectl-rollout")
111-
.buildCall(null),
108+
new V1Patch(deploymentJson),
109+
null,
110+
null,
111+
"kubectl-rollout",
112+
null,
113+
null,
114+
null),
112115
V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH,
113116
client);
114117

@@ -120,8 +123,7 @@ public static void main(String[] args) throws IOException, ApiException {
120123
try {
121124
System.out.println("Waiting until example deployment restarted successfully...");
122125
return appsV1Api
123-
.readNamespacedDeployment(deploymentName, namespace)
124-
.execute()
126+
.readNamespacedDeployment(deploymentName, namespace, null)
125127
.getStatus()
126128
.getReadyReplicas()
127129
> 0;

examples/examples-release-19/src/main/java/io/kubernetes/client/examples/Example.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public static void main(String[] args) throws IOException, ApiException {
3535
Configuration.setDefaultApiClient(client);
3636

3737
CoreV1Api api = new CoreV1Api();
38-
V1PodList list = api.listPodForAllNamespaces()
39-
.execute();
38+
V1PodList list =
39+
api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null, null, null);
4040
for (V1Pod item : list.getItems()) {
4141
System.out.println(item.getMetadata().getName());
4242
}

examples/examples-release-19/src/main/java/io/kubernetes/client/examples/ExpandedExample.java

Lines changed: 54 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ public static void main(String[] args) {
101101
*/
102102
public static List<String> getAllNameSpaces() throws ApiException {
103103
V1NamespaceList listNamespace =
104-
COREV1_API.listNamespace().execute();
104+
COREV1_API.listNamespace(
105+
null, null, null, null, null, null, null, null, null, null, null);
105106
List<String> list =
106107
listNamespace.getItems().stream()
107108
.map(v1Namespace -> v1Namespace.getMetadata().getName())
@@ -117,7 +118,8 @@ public static List<String> getAllNameSpaces() throws ApiException {
117118
*/
118119
public static List<String> getPods() throws ApiException {
119120
V1PodList v1podList =
120-
COREV1_API.listPodForAllNamespaces().execute();
121+
COREV1_API.listPodForAllNamespaces(
122+
null, null, null, null, null, null, null, null, null, null, null);
121123
List<String> podList =
122124
v1podList.getItems().stream()
123125
.map(v1Pod -> v1Pod.getMetadata().getName())
@@ -157,11 +159,18 @@ public static List<String> getNamespacedPod(String namespace) throws ApiExceptio
157159
public static List<String> getNamespacedPod(String namespace, String label) throws ApiException {
158160
V1PodList listNamespacedPod =
159161
COREV1_API.listNamespacedPod(
160-
namespace)
161-
.labelSelector(label)
162-
.timeoutSeconds(TIME_OUT_VALUE)
163-
.watch(false)
164-
.execute();
162+
namespace,
163+
null,
164+
null,
165+
null,
166+
null,
167+
label,
168+
null,
169+
null,
170+
null,
171+
null,
172+
TIME_OUT_VALUE,
173+
Boolean.FALSE);
165174
List<String> listPods =
166175
listNamespacedPod.getItems().stream()
167176
.map(v1pod -> v1pod.getMetadata().getName())
@@ -177,10 +186,19 @@ public static List<String> getNamespacedPod(String namespace, String label) thro
177186
*/
178187
public static List<String> getServices() throws ApiException {
179188
V1ServiceList listNamespacedService =
180-
COREV1_API.listNamespacedService(DEFAULT_NAME_SPACE)
181-
.timeoutSeconds(TIME_OUT_VALUE)
182-
.watch(false)
183-
.execute();
189+
COREV1_API.listNamespacedService(
190+
DEFAULT_NAME_SPACE,
191+
null,
192+
null,
193+
null,
194+
null,
195+
null,
196+
null,
197+
null,
198+
null,
199+
null,
200+
TIME_OUT_VALUE,
201+
Boolean.FALSE);
184202
return listNamespacedService.getItems().stream()
185203
.map(v1service -> v1service.getMetadata().getName())
186204
.collect(Collectors.toList());
@@ -199,9 +217,18 @@ public static void scaleDeployment(String deploymentName, int numberOfReplicas)
199217
appsV1Api.setApiClient(COREV1_API.getApiClient());
200218
V1DeploymentList listNamespacedDeployment =
201219
appsV1Api.listNamespacedDeployment(
202-
DEFAULT_NAME_SPACE)
203-
.watch(false)
204-
.execute();
220+
DEFAULT_NAME_SPACE,
221+
null,
222+
null,
223+
null,
224+
null,
225+
null,
226+
null,
227+
null,
228+
null,
229+
null,
230+
null,
231+
Boolean.FALSE);
205232

206233
List<V1Deployment> appsV1DeploymentItems = listNamespacedDeployment.getItems();
207234
Optional<V1Deployment> findedDeployment =
@@ -216,7 +243,7 @@ public static void scaleDeployment(String deploymentName, int numberOfReplicas)
216243
V1DeploymentSpec newSpec = deploy.getSpec().replicas(numberOfReplicas);
217244
V1Deployment newDeploy = deploy.spec(newSpec);
218245
appsV1Api.replaceNamespacedDeployment(
219-
deploymentName, DEFAULT_NAME_SPACE, newDeploy).execute();
246+
deploymentName, DEFAULT_NAME_SPACE, newDeploy, null, null, null, null);
220247
} catch (ApiException ex) {
221248
LOGGER.warn("Scale the pod failed for Deployment:" + deploymentName, ex);
222249
}
@@ -233,12 +260,18 @@ public static void scaleDeployment(String deploymentName, int numberOfReplicas)
233260
public static void printLog(String namespace, String podName) throws ApiException {
234261
// https://github.com/kubernetes-client/java/blob/master/kubernetes/docs/CoreV1Api.md#readNamespacedPodLog
235262
String readNamespacedPodLog =
236-
COREV1_API.readNamespacedPodLog(podName, namespace)
237-
.follow(false)
238-
.limitBytes(Integer.MAX_VALUE)
239-
.sinceSeconds(Integer.MAX_VALUE)
240-
.tailLines(40)
241-
.execute();
263+
COREV1_API.readNamespacedPodLog(
264+
podName,
265+
namespace,
266+
null,
267+
Boolean.FALSE,
268+
null,
269+
Integer.MAX_VALUE,
270+
null,
271+
Boolean.FALSE,
272+
Integer.MAX_VALUE,
273+
40,
274+
Boolean.FALSE);
242275
System.out.println(readNamespacedPodLog);
243276
}
244277
}

examples/examples-release-19/src/main/java/io/kubernetes/client/examples/FluentExample.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public static void main(String[] args) throws IOException, ApiException {
5454
.endSpec()
5555
.build();
5656

57-
api.createNamespacedPod("default", pod).execute();
57+
api.createNamespacedPod("default", pod, null, null, null, null);
5858

5959
V1Pod pod2 =
6060
new V1Pod()
@@ -63,10 +63,11 @@ public static void main(String[] args) throws IOException, ApiException {
6363
new V1PodSpec()
6464
.containers(Arrays.asList(new V1Container().name("www").image("nginx"))));
6565

66-
api.createNamespacedPod("default", pod2).execute();
66+
api.createNamespacedPod("default", pod2, null, null, null, null);
6767

6868
V1PodList list =
69-
api.listNamespacedPod("default").execute();
69+
api.listNamespacedPod(
70+
"default", null, null, null, null, null, null, null, null, null, null, null);
7071
for (V1Pod item : list.getItems()) {
7172
System.out.println(item.getMetadata().getName());
7273
}

examples/examples-release-19/src/main/java/io/kubernetes/client/examples/InClusterClientExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static void main(String[] args) throws IOException, ApiException {
5050

5151
// invokes the CoreV1Api client
5252
V1PodList list =
53-
api.listPodForAllNamespaces().execute();
53+
api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null, null, null);
5454
for (V1Pod item : list.getItems()) {
5555
System.out.println(item.getMetadata().getName());
5656
}

examples/examples-release-19/src/main/java/io/kubernetes/client/examples/InformerExample.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,19 @@ public static void main(String[] args) throws Exception {
5151
// HTTPs requests, the effective apiClient is the one specified when constructing
5252
// the informer-factory.
5353
(CallGeneratorParams params) -> {
54-
return coreV1Api.listNode()
55-
.resourceVersion(params.resourceVersion)
56-
.watch(params.watch)
57-
.timeoutSeconds(params.timeoutSeconds)
58-
.buildCall(null);
54+
return coreV1Api.listNodeCall(
55+
null,
56+
null,
57+
null,
58+
null,
59+
null,
60+
null,
61+
params.resourceVersion,
62+
null,
63+
null,
64+
params.timeoutSeconds,
65+
params.watch,
66+
null);
5967
},
6068
V1Node.class,
6169
V1NodeList.class);
@@ -86,7 +94,7 @@ public void onDelete(V1Node node, boolean deletedFinalStateUnknown) {
8694
V1ObjectMeta metadata = new V1ObjectMeta();
8795
metadata.setName("noxu");
8896
nodeToCreate.setMetadata(metadata);
89-
V1Node createdNode = coreV1Api.createNode(nodeToCreate).execute();
97+
V1Node createdNode = coreV1Api.createNode(nodeToCreate, null, null, null, null);
9098
Thread.sleep(3000);
9199

92100
Lister<V1Node> nodeLister = new Lister<V1Node>(nodeInformer.getIndexer());

examples/examples-release-19/src/main/java/io/kubernetes/client/examples/KubeConfigFileClientExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static void main(String[] args) throws IOException, ApiException {
5050

5151
// invokes the CoreV1Api client
5252
V1PodList list =
53-
api.listPodForAllNamespaces().execute();
53+
api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null, null, null);
5454
for (V1Pod item : list.getItems()) {
5555
System.out.println(item.getMetadata().getName());
5656
}

examples/examples-release-19/src/main/java/io/kubernetes/client/examples/LogsExample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public static void main(String[] args) throws IOException, ApiException, Interru
4040
PodLogs logs = new PodLogs();
4141
V1Pod pod =
4242
coreApi
43-
.listNamespacedPod("default")
44-
.execute()
43+
.listNamespacedPod(
44+
"default", "false", null, null, null, null, null, null, null, null, null, null)
4545
.getItems()
4646
.get(0);
4747

0 commit comments

Comments
 (0)