feat: 🚛 完成了 client 资源创建
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"gitea.loveuer.com/yizhisec/pkg3/logger"
|
||||
"yizhisec.com/hsv2/forge/internal/opt"
|
||||
"yizhisec.com/hsv2/forge/pkg/downloader"
|
||||
"yizhisec.com/hsv2/forge/pkg/model"
|
||||
)
|
||||
|
||||
type MysqlOpt func(*mysqlOpt)
|
||||
@@ -116,9 +117,9 @@ spec:
|
||||
|
||||
err error
|
||||
chartURL = "https://artifactory.yizhisec.com:443/artifactory/filestore/hsv3/charts/mysql-operator-0.6.3.tgz"
|
||||
mysqlDir = filepath.Join(m.workdir, "dependency", "mysql")
|
||||
chartFile = filepath.Join(mysqlDir, "mysql-operator-0.6.3.tgz")
|
||||
clusterFile = filepath.Join(mysqlDir, "cluster.yaml")
|
||||
location = filepath.Join(m.workdir, "dependency", "mysql")
|
||||
chartFile = filepath.Join(location, "mysql-operator-0.6.3.tgz")
|
||||
clusterFile = filepath.Join(location, "cluster.yaml")
|
||||
)
|
||||
|
||||
for _, fn := range opts {
|
||||
@@ -127,13 +128,13 @@ spec:
|
||||
|
||||
logger.Info("☑️ 开始构建 MySQL 资源...")
|
||||
|
||||
if err = os.MkdirAll(mysqlDir, 0755); err != nil {
|
||||
if err = os.MkdirAll(location, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
o.Password = base64.StdEncoding.EncodeToString([]byte(o.Password))
|
||||
|
||||
logger.Debug("正在下载 MySQL operator chart..., url = %s, dir = %s", chartURL, mysqlDir)
|
||||
logger.Debug("正在下载 MySQL operator chart..., url = %s, dir = %s", chartURL, location)
|
||||
if err = downloader.Download(
|
||||
ctx,
|
||||
chartURL,
|
||||
@@ -156,6 +157,31 @@ spec:
|
||||
|
||||
logger.Debug("✅ 成功创建 database.yaml")
|
||||
|
||||
logger.Debug("☑️ MakeMysql: 开始获取所需镜像...")
|
||||
|
||||
var images = []*model.Image{
|
||||
{Name: "docker.io/bitpoke/mysql-operator:v0.6.3", Fallback: "docker-mirror.yizhisec.com/bitpoke/mysql-operator:v0.6.3", Save: "bitpoke.mysql-operator.v0.6.3.tar"},
|
||||
{Name: "docker.io/bitpoke/mysql-operator-orchestrator:v0.6.3", Fallback: "docker-mirror.yizhisec.com/bitpoke/mysql-operator-orchestrator:v0.6.3", Save: "bitpoke.mysql-operator-orchestrator.v0.6.3.tar"},
|
||||
{Name: "docker.io/bitpoke/mysql-operator-sidecar-8.0:v0.6.3", Fallback: "docker-mirror.yizhisec.com/bitpoke/mysql-operator-sidecar-8.0:v0.6.3", Save: "bitpoke.mysql-operator-sidecar-8.0.v0.6.3.tar"},
|
||||
{Name: "docker.io/library/percona:8.0.28-20", Fallback: "docker-mirror.yizhisec.com/library/percona:8.0.28-20", Save: "percona.8.0.28-20.tar"},
|
||||
{Name: "docker.io/prom/mysqld-exporter:v0.13.0", Fallback: "docker-mirror.yizhisec.com/prom/mysqld-exporter:v0.13.0", Save: "prom.mysqld-exporter.v0.13.0.tar"},
|
||||
}
|
||||
|
||||
for _, image := range images {
|
||||
opts := []ImageOpt{
|
||||
WithImageFallback(image.Fallback),
|
||||
WithImageSave(filepath.Join(location, image.Save)),
|
||||
WithImageForcePull(image.Force),
|
||||
}
|
||||
|
||||
if err := m.Image(ctx, image.Name, opts...); err != nil {
|
||||
logger.Error("❌ MakeMysql: 获取镜像失败: %s, 可以手动获取后重试", image.Name)
|
||||
logger.Debug("❌ MakeMysql: 获取镜像失败: %s, %v", image.Name, err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
logger.Debug("✅ MakeMysql: 获取镜像成功!!!")
|
||||
|
||||
logger.Info("✅ MySQL 资源构建成功!!!")
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user