|
|
@@ -67,18 +67,23 @@ public class K8sJobHandler extends AbstractHandler{
|
|
|
job.setLabel(K8sConstants.JOB_LABEL, deployName);
|
|
|
|
|
|
context.appendSuccessResult("Job配置完成,开始检查仓库Secret");
|
|
|
- // 2 检查和配置 Secret
|
|
|
- SecretVO secretVO = secretApi.getSecretByName(namespace, DEFAULT_IMAGE_PULL_SECRET_NAME);
|
|
|
- if (secretVO == null) {
|
|
|
- secretApi.createPrivateRegistrySecret(
|
|
|
- namespace,
|
|
|
- DEFAULT_IMAGE_PULL_SECRET_NAME,
|
|
|
- applicationProperties.getDocker().getRegistry(),
|
|
|
- applicationProperties.getDocker().getRegistryUsername(),
|
|
|
- applicationProperties.getDocker().getRegistryPassword()
|
|
|
- );
|
|
|
+ try {
|
|
|
+ // 2 检查和配置 Secret
|
|
|
+ SecretVO secretVO = secretApi.getSecretByName(namespace, DEFAULT_IMAGE_PULL_SECRET_NAME);
|
|
|
+ if (secretVO == null) {
|
|
|
+ context.appendSuccessResult("secret null, 创建secret中");
|
|
|
+ secretApi.createPrivateRegistrySecret(
|
|
|
+ namespace,
|
|
|
+ DEFAULT_IMAGE_PULL_SECRET_NAME,
|
|
|
+ applicationProperties.getDocker().getRegistry(),
|
|
|
+ applicationProperties.getDocker().getRegistryUsername(),
|
|
|
+ applicationProperties.getDocker().getRegistryPassword()
|
|
|
+ );
|
|
|
+ }
|
|
|
+ job.setImagePullSecrets(Collections.singletonList(DEFAULT_IMAGE_PULL_SECRET_NAME));
|
|
|
+ } catch (Exception e){
|
|
|
+ context.appendErrorResult("检查仓库Secret出错", e);
|
|
|
}
|
|
|
- job.setImagePullSecrets(Collections.singletonList(DEFAULT_IMAGE_PULL_SECRET_NAME));
|
|
|
|
|
|
context.appendSuccessResult("Secret已确认,开始创建Job");
|
|
|
// 3 创建Job
|