From 56ca90997faf16ea9e122cea91dfd92541e1f86d Mon Sep 17 00:00:00 2001 From: cdmikechen Date: Sat, 11 Nov 2023 21:33:03 +0800 Subject: [PATCH] SUBMARINE-1414. Upgrade java k8s client to 18(k8s-java-client)/6.7(fabric8) ### What is this PR for? Upgrade java k8s client lib to latest version and fix codes when updating the version ### What type of PR is it? Improvement ### Todos * [x] - Update k8s-client to 18 * [x] - Update fabric to 6.7 * [x] - Update java operator sdk to 4.5 * [x] - Fix unit test error ### What is the Jira issue? https://issues.apache.org/jira/browse/SUBMARINE-1414 ### How should this be tested? CI test ### Screenshots (if appropriate) ### Questions: * Do the license files need updating? No * Are there breaking changes for older versions? No * Does this need new documentation? No Author: cdmikechen Author: cdmikechen Signed-off-by: cdmikechen Closes #1115 from cdmikechen/SUBMARINE-1414 and squashes the following commits: 53c108d8 [cdmikechen] update operator test 32a42f23 [cdmikechen] update operator-sdk 3cb06982 [cdmikechen] update protobuf to 3.22.0 0f8d9af8 [cdmikechen] update k8s java version --- pom.xml | 6 +++--- .../server-submitter/submarine-k8s-agent/pom.xml | 2 +- .../server/k8s/agent/SubmarineAgentListener.java | 8 +------- .../server/k8s/agent/SubmitSubmarineAgentTest.java | 12 +++++------- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/pom.xml b/pom.xml index 2a60235284..b49ad04d87 100644 --- a/pom.xml +++ b/pom.xml @@ -135,9 +135,9 @@ 20211205 - 17.0.2 + 18.0.1 1.6.10 - 6.6.1 + 6.7.2 2.27 @@ -149,7 +149,7 @@ 3.0 3.0 - 3.21.10 + 3.22.0 2.10.8 5.6.1 diff --git a/submarine-server/server-submitter/submarine-k8s-agent/pom.xml b/submarine-server/server-submitter/submarine-k8s-agent/pom.xml index 000ac80792..76fd3d8783 100644 --- a/submarine-server/server-submitter/submarine-k8s-agent/pom.xml +++ b/submarine-server/server-submitter/submarine-k8s-agent/pom.xml @@ -37,7 +37,7 @@ io.javaoperatorsdk operator-framework - 4.3.2 + 4.5.0 com.fasterxml.jackson.core diff --git a/submarine-server/server-submitter/submarine-k8s-agent/src/main/java/org/apache/submarine/server/k8s/agent/SubmarineAgentListener.java b/submarine-server/server-submitter/submarine-k8s-agent/src/main/java/org/apache/submarine/server/k8s/agent/SubmarineAgentListener.java index 1ae7ec9c4e..dd0a5992df 100644 --- a/submarine-server/server-submitter/submarine-k8s-agent/src/main/java/org/apache/submarine/server/k8s/agent/SubmarineAgentListener.java +++ b/submarine-server/server-submitter/submarine-k8s-agent/src/main/java/org/apache/submarine/server/k8s/agent/SubmarineAgentListener.java @@ -19,8 +19,6 @@ package org.apache.submarine.server.k8s.agent; -import io.fabric8.kubernetes.client.KubernetesClient; -import io.fabric8.kubernetes.client.KubernetesClientBuilder; import io.javaoperatorsdk.operator.Operator; import io.javaoperatorsdk.operator.api.config.ControllerConfigurationOverrider; import io.javaoperatorsdk.operator.api.reconciler.Reconciler; @@ -49,10 +47,8 @@ public class SubmarineAgentListener { public static final DateTimeFormatter DTF = DateTimeFormatter.ISO_DATE_TIME; public static void main(String[] args) throws IOException { - // create kubernetes client - KubernetesClient client = new KubernetesClientBuilder().build(); // create operator - Operator operator = new Operator(client); + Operator operator = new Operator(); // scan all Reconciler implemented subclasses Reflections reflections = new Reflections("org.apache.submarine.server.k8s.agent"); Set> reconcilers = reflections.getSubTypesOf(Reconciler.class); @@ -69,8 +65,6 @@ public static void main(String[] args) throws IOException { } ); LOGGER.info("Starting agent with SUBMARINE_UID={}", OwnerReferenceConfig.getSubmarineUid()); - // Adds a shutdown hook that automatically calls stop() when the app shuts down. - operator.installShutdownHook(); // start operator operator.start(); // Provide a lightweight service to handle health checks diff --git a/submarine-server/server-submitter/submarine-k8s-agent/src/test/java/org/apache/submarine/server/k8s/agent/SubmitSubmarineAgentTest.java b/submarine-server/server-submitter/submarine-k8s-agent/src/test/java/org/apache/submarine/server/k8s/agent/SubmitSubmarineAgentTest.java index fe20aed134..779bddfa07 100644 --- a/submarine-server/server-submitter/submarine-k8s-agent/src/test/java/org/apache/submarine/server/k8s/agent/SubmitSubmarineAgentTest.java +++ b/submarine-server/server-submitter/submarine-k8s-agent/src/test/java/org/apache/submarine/server/k8s/agent/SubmitSubmarineAgentTest.java @@ -24,9 +24,7 @@ import io.fabric8.kubernetes.api.model.OwnerReferenceBuilder; import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition; import io.fabric8.kubernetes.client.KubernetesClient; -import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext; import io.fabric8.kubernetes.client.server.mock.KubernetesServer; -import io.fabric8.kubernetes.internal.KubernetesDeserializer; import io.javaoperatorsdk.operator.Operator; import org.apache.ibatis.session.SqlSession; import org.apache.submarine.commons.utils.SubmarineConfiguration; @@ -103,10 +101,10 @@ public static void beforeInit() { // set client and operator client = server.getClient(); - operator = new Operator(client); + operator = new Operator(client, null); // create notbook resource - KubernetesDeserializer.registerCustomKind("apiextensions.k8s.io/v1","Notebook", NotebookResource.class); + client.getKubernetesSerialization().registerKubernetesResource("apiextensions.k8s.io/v1","Notebook", NotebookResource.class); CustomResourceDefinition notebookCrd = client .apiextensions().v1() .customResourceDefinitions() @@ -116,7 +114,7 @@ public static void beforeInit() { client.apiextensions().v1().customResourceDefinitions().createOrReplace(notebookCrd); // create tf resource - KubernetesDeserializer.registerCustomKind("apiextensions.k8s.io/v1", "TFJob", TFJob.class); + client.getKubernetesSerialization().registerKubernetesResource("apiextensions.k8s.io/v1", "TFJob", TFJob.class); CustomResourceDefinition tfCrd = client .apiextensions().v1() .customResourceDefinitions() @@ -126,7 +124,7 @@ public static void beforeInit() { client.apiextensions().v1().customResourceDefinitions().create(tfCrd); // create pytorch resource - KubernetesDeserializer.registerCustomKind("apiextensions.k8s.io/v1", "PyTorchJob", PyTorchJob.class); + client.getKubernetesSerialization().registerKubernetesResource("apiextensions.k8s.io/v1", "PyTorchJob", PyTorchJob.class); CustomResourceDefinition ptCrd = client .apiextensions().v1() .customResourceDefinitions() @@ -136,7 +134,7 @@ public static void beforeInit() { client.apiextensions().v1().customResourceDefinitions().create(ptCrd); // create xgboost resource - KubernetesDeserializer.registerCustomKind("apiextensions.k8s.io/v1", "XGBoostJob", XGBoostJob.class); + client.getKubernetesSerialization().registerKubernetesResource("apiextensions.k8s.io/v1", "XGBoostJob", XGBoostJob.class); CustomResourceDefinition xgbCrd = client .apiextensions().v1() .customResourceDefinitions()