|
|
|
@@ -1,26 +1,20 @@ |
|
|
|
package com.ruoyi.platform.utils; |
|
|
|
|
|
|
|
import com.alibaba.nacos.shaded.com.google.gson.reflect.TypeToken; |
|
|
|
import io.kubernetes.client.Exec; |
|
|
|
import io.kubernetes.client.custom.IntOrString; |
|
|
|
import io.kubernetes.client.custom.Quantity; |
|
|
|
import io.kubernetes.client.openapi.ApiClient; |
|
|
|
import io.kubernetes.client.openapi.ApiException; |
|
|
|
import io.kubernetes.client.openapi.ApiResponse; |
|
|
|
import io.kubernetes.client.openapi.Configuration; |
|
|
|
import io.kubernetes.client.openapi.apis.CoreV1Api; |
|
|
|
import io.kubernetes.client.openapi.models.*; |
|
|
|
import io.kubernetes.client.util.ClientBuilder; |
|
|
|
import io.kubernetes.client.util.Watch; |
|
|
|
import io.kubernetes.client.util.credentials.AccessTokenAuthentication; |
|
|
|
import io.kubernetes.client.util.Config; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
import org.apache.poi.ss.formula.functions.T; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import javax.annotation.PostConstruct; |
|
|
|
import java.io.BufferedReader; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStreamReader; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.LinkedHashMap; |
|
|
|
@@ -35,8 +29,6 @@ import java.util.Map; |
|
|
|
@Slf4j |
|
|
|
@Component |
|
|
|
public class K8sClientUtil { |
|
|
|
private String http; |
|
|
|
private String token; |
|
|
|
/** |
|
|
|
* k8s-api客户端 |
|
|
|
*/ |
|
|
|
@@ -51,14 +43,11 @@ public class K8sClientUtil { |
|
|
|
* 4. master endpoints(ip, port) from pre-set environment variables |
|
|
|
*/ |
|
|
|
// @Autowired |
|
|
|
public K8sClientUtil(@Value("${k8s.http}") String http, @Value("${k8s.token}") String token) { |
|
|
|
this.http = http; |
|
|
|
this.token = token; |
|
|
|
public K8sClientUtil() { |
|
|
|
try { |
|
|
|
this.apiClient = new ClientBuilder(). |
|
|
|
setBasePath(http).setVerifyingSsl(false). |
|
|
|
setAuthentication(new AccessTokenAuthentication(token)).build(); |
|
|
|
} catch (Exception e) { |
|
|
|
apiClient = Config.defaultClient(); |
|
|
|
Configuration.setDefaultApiClient(apiClient); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("构建K8s-Client异常", e); |
|
|
|
throw new RuntimeException("构建K8s-Client异常"); |
|
|
|
} |
|
|
|
|