|
29 | 29 | import java.util.concurrent.TimeUnit; |
30 | 30 | import java.util.stream.Collectors; |
31 | 31 |
|
32 | | -import io.kubernetes.client.custom.V1Patch; |
33 | 32 | import io.kubernetes.client.openapi.ApiClient; |
34 | 33 | import io.kubernetes.client.openapi.ApiException; |
35 | 34 | import io.kubernetes.client.openapi.Configuration; |
|
40 | 39 | import io.kubernetes.client.openapi.apis.RbacAuthorizationV1Api; |
41 | 40 | import io.kubernetes.client.openapi.models.V1APIService; |
42 | 41 | import io.kubernetes.client.openapi.models.V1ClusterRole; |
43 | | -import io.kubernetes.client.openapi.models.V1ClusterRoleBinding; |
44 | 42 | import io.kubernetes.client.openapi.models.V1ConfigMap; |
45 | 43 | import io.kubernetes.client.openapi.models.V1Deployment; |
46 | 44 | import io.kubernetes.client.openapi.models.V1DeploymentCondition; |
|
55 | 53 | import io.kubernetes.client.openapi.models.V1Service; |
56 | 54 | import io.kubernetes.client.openapi.models.V1ServiceAccount; |
57 | 55 | import io.kubernetes.client.util.Config; |
58 | | -import io.kubernetes.client.util.PatchUtils; |
59 | 56 | import io.kubernetes.client.util.Yaml; |
60 | 57 | import jakarta.annotation.Nullable; |
61 | 58 | import org.apache.commons.logging.Log; |
@@ -335,49 +332,6 @@ public void setUp(String namespace) { |
335 | 332 |
|
336 | 333 | } |
337 | 334 |
|
338 | | - public void setUpClusterWideClusterRoleBinding(String serviceAccountNamespace) { |
339 | | - |
340 | | - try { |
341 | | - V1ServiceAccount serviceAccount = (V1ServiceAccount) yaml("cluster/service-account.yaml"); |
342 | | - CheckedSupplier<V1ServiceAccount> accountSupplier = () -> coreV1Api |
343 | | - .readNamespacedServiceAccount(serviceAccount.getMetadata().getName(), serviceAccountNamespace, null); |
344 | | - CheckedSupplier<V1ServiceAccount> accountDefaulter = () -> coreV1Api |
345 | | - .createNamespacedServiceAccount(serviceAccountNamespace, serviceAccount, null, null, null, null); |
346 | | - notExistsHandler(accountSupplier, accountDefaulter); |
347 | | - |
348 | | - V1ClusterRole clusterRole = (V1ClusterRole) yaml("cluster/cluster-role.yaml"); |
349 | | - notExistsHandler(() -> rbacApi.readClusterRole(clusterRole.getMetadata().getName(), null), |
350 | | - () -> rbacApi.createClusterRole(clusterRole, null, null, null, null)); |
351 | | - |
352 | | - V1ClusterRoleBinding clusterRoleBinding = (V1ClusterRoleBinding) yaml("cluster/cluster-role-binding.yaml"); |
353 | | - notExistsHandler(() -> rbacApi.readClusterRoleBinding(clusterRoleBinding.getMetadata().getName(), null), |
354 | | - () -> rbacApi.createClusterRoleBinding(clusterRoleBinding, null, null, null, null)); |
355 | | - } |
356 | | - catch (Exception e) { |
357 | | - e.printStackTrace(); |
358 | | - throw new RuntimeException(e); |
359 | | - } |
360 | | - |
361 | | - } |
362 | | - |
363 | | - public void deleteClusterWideClusterRoleBinding(String serviceAccountNamespace) { |
364 | | - try { |
365 | | - V1ServiceAccount serviceAccount = (V1ServiceAccount) yaml("cluster/service-account.yaml"); |
366 | | - V1ClusterRole clusterRole = (V1ClusterRole) yaml("cluster/cluster-role.yaml"); |
367 | | - V1ClusterRoleBinding clusterRoleBinding = (V1ClusterRoleBinding) yaml("cluster/cluster-role-binding.yaml"); |
368 | | - |
369 | | - coreV1Api.deleteNamespacedServiceAccount(serviceAccount.getMetadata().getName(), serviceAccountNamespace, |
370 | | - null, null, null, null, null, null); |
371 | | - rbacApi.deleteClusterRole(clusterRole.getMetadata().getName(), null, null, null, null, null, null); |
372 | | - rbacApi.deleteClusterRoleBinding(clusterRoleBinding.getMetadata().getName(), null, null, null, null, null, |
373 | | - null); |
374 | | - } |
375 | | - catch (Exception e) { |
376 | | - e.printStackTrace(); |
377 | | - throw new RuntimeException(e); |
378 | | - } |
379 | | - } |
380 | | - |
381 | 335 | public void setUpClusterWide(String serviceAccountNamespace, Set<String> namespaces) { |
382 | 336 |
|
383 | 337 | try { |
@@ -517,41 +471,6 @@ public void wiremock(String namespace, String path, Phase phase, boolean withIng |
517 | 471 |
|
518 | 472 | } |
519 | 473 |
|
520 | | - public static void patchWithMerge(String deploymentName, String namespace, String patchBody, |
521 | | - Map<String, String> podLabels) { |
522 | | - try { |
523 | | - PatchUtils.patch(V1Deployment.class, |
524 | | - () -> new AppsV1Api().patchNamespacedDeploymentCall(deploymentName, namespace, |
525 | | - new V1Patch(patchBody), null, null, null, null, null, null), |
526 | | - V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH, new CoreV1Api().getApiClient()); |
527 | | - } |
528 | | - catch (ApiException e) { |
529 | | - LOG.error("error : " + e.getResponseBody()); |
530 | | - throw new RuntimeException(e); |
531 | | - } |
532 | | - |
533 | | - waitForDeploymentAfterPatch(deploymentName, namespace, podLabels); |
534 | | - } |
535 | | - |
536 | | - public static void patchWithReplace(String imageName, String deploymentName, String namespace, String patchBody, |
537 | | - Map<String, String> podLabels) { |
538 | | - String body = patchBody.replace("image_name_here", imageName); |
539 | | - |
540 | | - try { |
541 | | - PatchUtils.patch(V1Deployment.class, |
542 | | - () -> new AppsV1Api().patchNamespacedDeploymentCall(deploymentName, namespace, new V1Patch(body), |
543 | | - null, null, null, null, null, null), |
544 | | - V1Patch.PATCH_FORMAT_JSON_MERGE_PATCH, new CoreV1Api().getApiClient()); |
545 | | - } |
546 | | - catch (ApiException e) { |
547 | | - LOG.error("error : " + e.getResponseBody()); |
548 | | - throw new RuntimeException(e); |
549 | | - } |
550 | | - |
551 | | - waitForDeploymentAfterPatch(deploymentName, namespace, podLabels); |
552 | | - |
553 | | - } |
554 | | - |
555 | 474 | private String deploymentName(V1Deployment deployment) { |
556 | 475 | return deployment.getMetadata().getName(); |
557 | 476 | } |
|
0 commit comments