[ Cmii ] [ Octopus ] - project a lot

This commit is contained in:
zeaslity
2024-03-08 17:23:41 +08:00
parent 52c360eb49
commit 5e80d7baad
56 changed files with 1112 additions and 240 deletions

View File

@@ -17,6 +17,7 @@ import (
"time"
"wdd.io/agent-go/logger"
"wdd.io/agent-go/utils"
"wdd.io/cmii_operator/image"
)
var log = logger.Log
@@ -397,10 +398,19 @@ func (op *CmiiK8sOperator) DeploymentUpdateTag(cmiiEnv, appName, newTag string)
if len(containers) == 1 {
// only update this kind
container := containers[0]
split := strings.Split(container.Image, ":")
container.Image = split[0] + ":" + newTag
log.InfoF("[DeploymentUpdateTag] - update [%s] [%s] from [%s] to [%s]", op.CurrentNamespace, appName, split[1], container.Image)
oldName := container.Image
split := strings.Split(container.Image, ":")
if strings.HasPrefix(container.Image, image.CmiiHarborPrefix) {
// harbor
container.Image = split[0] + ":" + newTag
} else if strings.Contains(container.Image, "8033") {
// 192.168.6.6:8033/rancher/k8s-dns-sidecar:v1.0.2
container.Image = split[0] + ":" + split[1] + ":" + newTag
}
log.DebugF("[DeploymentUpdateTag] - update [%s] [%s] from [%s] to [%s]", op.CurrentNamespace, appName, oldName, container.Image)
// re assign
deployment.Spec.Template.Spec.Containers[0] = container
@@ -411,6 +421,9 @@ func (op *CmiiK8sOperator) DeploymentUpdateTag(cmiiEnv, appName, newTag string)
log.ErrorF("[DeploymentUpdateTag] - update [%s] [%s] from [%s] to [%s] error ! %s", op.CurrentNamespace, appName, split[1], container.Image, err.Error())
return false
}
} else if len(containers) == 2 {
log.ErrorF("[DeploymentUpdateTag] - cant update app with 2 containers !")
return false
}
return true