Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Tencent/bk-job into issue…
Browse files Browse the repository at this point in the history
…_3037
  • Loading branch information
wangyu096 committed Jun 6, 2024
2 parents 414aa97 + d159507 commit 7ed1992
Showing 1 changed file with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,12 @@ public class StartupController {
public static final String POD_PHASE_RUNNING = "Running";

// K8s API
private static final CoreV1Api api;

static {
ApiClient client = null;
try {
client = Config.defaultClient();
} catch (IOException e) {
log.error("Fail to get k8s api defaultClient", e);
}
Configuration.setDefaultApiClient(client);
api = new CoreV1Api();
}
private static CoreV1Api api;

// 主程序入口
public static void main(String[] args) {
// 初始化K8s API
initK8sApi();
// 解析需要的依赖参数
ServiceDependModel serviceDependModel = parseDependModelFromArgsOrEnv(args);
String namespace = serviceDependModel.getNamespace();
Expand Down Expand Up @@ -123,6 +114,20 @@ public static void main(String[] args) {
log.info("all depend services are ready, it`s time for {} to start", currentService);
}

/**
* 初始化K8s API
*/
private static void initK8sApi() {
ApiClient client = null;
try {
client = Config.defaultClient();
} catch (IOException e) {
log.error("Fail to get k8s api defaultClient", e);
}
Configuration.setDefaultApiClient(client);
api = new CoreV1Api();
}

/**
* 从命令行参数或环境变量解析出程序运行需要的服务依赖参数
*
Expand Down

0 comments on commit 7ed1992

Please sign in to comment.