From d5ed8edcd76a88aa6a1f57d1b6f4e9a02639546a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=B5=B7?= <10402852@qq.com> Date: Thu, 26 Sep 2024 20:15:00 +0800 Subject: [PATCH] 'commit' --- .idea/workspace.xml | 50 +++++++-------- dsBuild/pom.xml | 61 ------------------- dsBuild/src/main/java/Util/K8sClientTest.java | 59 ------------------ 3 files changed, 26 insertions(+), 144 deletions(-) delete mode 100644 dsBuild/src/main/java/Util/K8sClientTest.java diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 1ca19f7b..0c416a64 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,18 +5,8 @@ - - - - - - - - - - - - + + - { - "keyToString": { - "RunOnceActivity.ShowReadmeOnStart": "true", - "git-widget-placeholder": "main", - "kotlin-language-version-configured": "true", - "nodejs_package_manager_path": "npm", - "project.structure.last.edited": "模块", - "project.structure.proportion": "0.0", - "project.structure.side.proportion": "0.0", - "settings.editor.selected.configurable": "reference.settings.project.maven.importing", - "vue.rearranger.settings.migration": "true" + +}]]> + + \ No newline at end of file diff --git a/dsBuild/pom.xml b/dsBuild/pom.xml index 9ce4a7c7..928586f2 100644 --- a/dsBuild/pom.xml +++ b/dsBuild/pom.xml @@ -15,8 +15,6 @@ UTF-8 21 21 - 5.11.0 - 3.3.4 @@ -148,66 +146,7 @@ 1.5.8 runtime - - io.prometheus - simpleclient - 0.15.0 - - - io.prometheus - simpleclient_httpserver - 0.15.0 - - - io.kubernetes - client-java-api - 21.0.1 - - - io.kubernetes - client-java - 21.0.1 - - - - io.kubernetes - client-java-extended - 21.0.1 - - - io.kubernetes - client-java-proto - 21.0.1 - - - commons-cli - commons-cli - 1.9.0 - - - io.kubernetes - client-java-cert-manager-models - 10.0.1 - - - io.kubernetes - client-java-prometheus-operator-models - 10.0.1 - - - - org.junit.jupiter - junit-jupiter - ${junit-jupiter.version} - test - - - org.wiremock - wiremock - 3.9.1 - test - diff --git a/dsBuild/src/main/java/Util/K8sClientTest.java b/dsBuild/src/main/java/Util/K8sClientTest.java deleted file mode 100644 index 481282d1..00000000 --- a/dsBuild/src/main/java/Util/K8sClientTest.java +++ /dev/null @@ -1,59 +0,0 @@ -package Util; - -import com.jfinal.kit.PathKit; -import io.kubernetes.client.openapi.ApiClient; -import io.kubernetes.client.openapi.ApiException; -import io.kubernetes.client.openapi.apis.CoreV1Api; -import io.kubernetes.client.openapi.models.V1Pod; -import io.kubernetes.client.openapi.models.V1PodList; -import io.kubernetes.client.util.ClientBuilder; -import io.kubernetes.client.util.KubeConfig; - -import java.io.FileReader; -import java.io.IOException; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class K8sClientTest { - - //Master /root/.kube/config文件拷贝过来 - public static String kubeConfigPath = PathKit.getRootClassPath() + "\\.kube\\config"; - - public static void getAllPodList() throws IOException, ApiException { - ApiClient apiClient = ClientBuilder.kubeconfig(KubeConfig.loadKubeConfig(new FileReader(kubeConfigPath))).build(); - // new a CoreV1Api - CoreV1Api api = new CoreV1Api(apiClient); - // invokes the CoreV1Api client - V1PodList podList = api.listPodForAllNamespaces().execute(); - for (V1Pod item : podList.getItems()) { - String result = removePrefixAndLastTwoDashes(item.getMetadata().getName()); - if (result.equals("ds-base-web")) { - System.out.println(result); - } - } - } - - - /** - * 功能:去掉前缀和最后一个两个- - * - * @param input - * @return - */ - public static String removePrefixAndLastTwoDashes(String input) { - // 去掉开头的default: - String trimmed = input.replaceFirst("^default:", ""); - - // 去掉最后两个以-开头的字符串 - Pattern pattern = Pattern.compile("-[^-]+(-[^-]+)?$"); - Matcher matcher = pattern.matcher(trimmed); - if (matcher.find()) { - return trimmed.substring(0, trimmed.length() - matcher.group().length()); - } - return trimmed; - } - - public static void main(String[] args) throws IOException, ApiException { - getAllPodList(); - } -}