main
黄海 10 months ago
parent da0e3259b7
commit d5ed8edcd7

@ -5,18 +5,8 @@
</component>
<component name="ChangeListManager">
<list default="true" id="8a61ce26-c938-4ad4-aa09-565c63cde7d7" name="更改" comment="">
<change beforePath="$PROJECT_DIR$/.idea/.gitignore" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/compiler.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/encodings.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/jarRepositories.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/uiDesigner.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ds-base/dsBase.iml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/dsBase/dsBase.iml" beforeDir="false" afterPath="$PROJECT_DIR$/dsBase/dsBase.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dsBuild/dsBuild.iml" beforeDir="false" afterPath="$PROJECT_DIR$/dsBuild/dsBuild.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dsGw/dsGw.iml" beforeDir="false" afterPath="$PROJECT_DIR$/dsGw/dsGw.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dsRes.iml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/dsBuild/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/dsBuild/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dsBuild/src/main/java/Util/K8sClientTest.java" beforeDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -48,19 +38,24 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;main&quot;,
&quot;kotlin-language-version-configured&quot;: &quot;true&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;project.structure.last.edited&quot;: &quot;模块&quot;,
&quot;project.structure.proportion&quot;: &quot;0.0&quot;,
&quot;project.structure.side.proportion&quot;: &quot;0.0&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;reference.settings.project.maven.importing&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.ShowReadmeOnStart": "true",
"git-widget-placeholder": "main",
"kotlin-language-version-configured": "true",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"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",
"应用程序.GwApplication.executor": "Run"
}
}</component>
}]]></component>
<component name="RunManager">
<configuration name="GwApplication" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="com.dsideal.gw.GwApplication" />
@ -98,10 +93,17 @@
<option name="presentableId" value="Default" />
<updated>1727339918298</updated>
<workItem from="1727339920435" duration="293000" />
<workItem from="1727340224328" duration="1570000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="UnknownFeatures">
<option featureType="dependencySupport" implementationName="java:jakarta.ws.rs:jakarta.ws.rs-api" />
<option featureType="dependencySupport" implementationName="javascript:npm:vue" />
<option featureType="dependencySupport" implementationName="java:org.projectlombok:lombok" />
<option featureType="dependencySupport" implementationName="java:org.wiremock:wiremock" />
</component>
</project>

@ -15,8 +15,6 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<junit-jupiter.version>5.11.0</junit-jupiter.version>
<spring.boot.version>3.3.4</spring.boot.version>
</properties>
<dependencies>
@ -148,66 +146,7 @@
<version>1.5.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient</artifactId>
<version>0.15.0</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_httpserver</artifactId>
<version>0.15.0</version>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java-api</artifactId>
<version>21.0.1</version>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java</artifactId>
<version>21.0.1</version>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java-extended</artifactId>
<version>21.0.1</version>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java-proto</artifactId>
<version>21.0.1</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java-cert-manager-models</artifactId>
<version>10.0.1</version>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java-prometheus-operator-models</artifactId>
<version>10.0.1</version>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<version>3.9.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>

@ -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();
}
}
Loading…
Cancel
Save