194 lines
5.2 KiB
Go
194 lines
5.2 KiB
Go
package agent_deploy
|
|
|
|
import (
|
|
"os"
|
|
image2 "wdd.io/agent-common/image"
|
|
"wdd.io/agent-common/logger"
|
|
"wdd.io/agent-deploy/a_dashboard"
|
|
"wdd.io/agent-deploy/a_nfs"
|
|
"wdd.io/agent-deploy/b_middle"
|
|
"wdd.io/agent-deploy/c_app"
|
|
"wdd.io/agent-deploy/z_dep"
|
|
)
|
|
|
|
var log = logger.Log
|
|
|
|
func OctopusDeploy() {
|
|
|
|
// common environment
|
|
common := &z_dep.CommonEnvironmentConfig{
|
|
WebIP: "10.250.0.110",
|
|
WebPort: "8888",
|
|
HarborIP: "10.250.0.110",
|
|
HarborPort: "8033",
|
|
Namespace: "bjtg",
|
|
TagVersion: "5.5.0",
|
|
TenantEnv: "",
|
|
MinioPublicIP: "10.250.0.110",
|
|
MinioInnerIP: "10.250.0.110",
|
|
NFSServerIP: "10.250.0.110",
|
|
}
|
|
|
|
// kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')
|
|
a_dashboard.K8sDashboardDeploy(common)
|
|
|
|
a_nfs.NFSDeploy(common)
|
|
a_nfs.NFSTestDeploy(common)
|
|
|
|
// pvc
|
|
b_middle.PVCDeploy(common)
|
|
|
|
// middlewares
|
|
b_middle.MidMySQlDeploy(common)
|
|
b_middle.MidRedisDeploy(common)
|
|
b_middle.MidEmqxDeploy(common)
|
|
b_middle.MidMongoDeploy(common)
|
|
b_middle.MidRabbitMQDeploy(common)
|
|
b_middle.MidRabbitMQDeploy(common)
|
|
b_middle.MidNacosDeploy(common)
|
|
|
|
configMapDeploy(common)
|
|
c_app.IngressDeploy(common)
|
|
|
|
gzipFilePrefix := "/root/octopus_image/xjyd/"
|
|
frontendImageVersionMap, backendImageVersionMap, _ := image2.GzipFolderPathToCmiiImageTagMaps(gzipFilePrefix)
|
|
|
|
backendDeploy(common, backendImageVersionMap)
|
|
frontendDeploy(common, frontendImageVersionMap)
|
|
c_app.SRSDeploy(common)
|
|
}
|
|
|
|
func CmiiAppDeploy() {
|
|
|
|
// common environment
|
|
common := &z_dep.CommonEnvironmentConfig{
|
|
WebIP: "36.133.201.78",
|
|
WebPort: "8888",
|
|
HarborIP: "192.168.0.14",
|
|
HarborPort: "",
|
|
Namespace: "xjyd",
|
|
TagVersion: "5.5.0",
|
|
TenantEnv: "",
|
|
MinioPublicIP: "36.133.201.146",
|
|
MinioInnerIP: "192.168.0.21",
|
|
NFSServerIP: "192.168.0.14",
|
|
}
|
|
|
|
//frontendImageVersionMap, backendImageVersionMap, _ := image.FrontendBackendSrsImageMapFromCmiiImageMap(zjjt.CmiiImageMap)
|
|
gzipFilePrefix := "/root/octopus_image/xjyd/"
|
|
frontendImageVersionMap, backendImageVersionMap, _ := image2.GzipFolderPathToCmiiImageTagMaps(gzipFilePrefix)
|
|
|
|
backendDeploy(common, backendImageVersionMap)
|
|
frontendDeploy(common, frontendImageVersionMap)
|
|
//utils.BeautifulPrint(frontendImageVersionMap)
|
|
|
|
//configMapDeploy(common)
|
|
//c_app.IngressDeploy(common)
|
|
|
|
}
|
|
|
|
var IgnoreCmiiBackendAppName = map[string]string{
|
|
"cmii-uav-grid-datasource": "0",
|
|
"cmii-uav-grid-manage": "",
|
|
"cmii-uav-grid-engine": "",
|
|
"cmii-uav-kpi-monitor": "",
|
|
"cmii-uav-gis-server": "",
|
|
"cmii-app-release": "",
|
|
"cmii-uav-autowaypoint": "",
|
|
"cmii-uav-integration": "",
|
|
"cmii-uav-developer": "",
|
|
"cmii-open-gateway": "",
|
|
"cmii-uav-brain": "",
|
|
"cmii-uav-data-post-process": "",
|
|
"cmii-uav-multilink": "",
|
|
"cmii-uav-alarm": "",
|
|
"cmii-uav-tower": "",
|
|
}
|
|
|
|
func backendDeploy(common *z_dep.CommonEnvironmentConfig, backendImageVersionMap map[string]string) {
|
|
|
|
os.Remove(c_app.BackendApplyFilePath)
|
|
|
|
for appName, tag := range backendImageVersionMap {
|
|
c_app.DefaultCmiiBackendConfig.AppName = appName
|
|
c_app.DefaultCmiiBackendConfig.ImageTag = tag
|
|
_, ok := IgnoreCmiiBackendAppName[appName]
|
|
if ok {
|
|
c_app.DefaultCmiiBackendConfig.Replicas = "0"
|
|
} else {
|
|
c_app.DefaultCmiiBackendConfig.Replicas = "1"
|
|
}
|
|
|
|
c_app.DefaultCmiiBackendConfig.BackendDeploy(common)
|
|
}
|
|
}
|
|
|
|
func frontendDeploy(common *z_dep.CommonEnvironmentConfig, frontendImageVersionMap map[string]string) {
|
|
|
|
os.Remove(c_app.FrontendApplyFilePath)
|
|
|
|
c_app.FrontendDefaultNginxDeploy(common)
|
|
|
|
for appName, tag := range frontendImageVersionMap {
|
|
c_app.DefaultCmiiFrontendConfig.AppName = appName
|
|
c_app.DefaultCmiiFrontendConfig.ImageTag = tag
|
|
c_app.DefaultCmiiFrontendConfig.Replicas = "1"
|
|
|
|
value, ok := c_app.FrontendShortNameMaps[appName]
|
|
if !ok {
|
|
log.ErrorF("FrontendShortNameMaps error ! not contains %s", appName)
|
|
continue
|
|
}
|
|
|
|
c_app.DefaultCmiiFrontendConfig.ShortName = value
|
|
|
|
c_app.DefaultCmiiFrontendConfig.FrontendDeploy(common)
|
|
}
|
|
}
|
|
|
|
func configMapDeploy(common *z_dep.CommonEnvironmentConfig) {
|
|
os.Remove(c_app.ConfigMapApplyFilePath)
|
|
|
|
for frontendName, shortName := range c_app.FrontendShortNameMaps {
|
|
c_app.DefaultCmiiFrontendConfig.AppName = frontendName
|
|
c_app.DefaultCmiiFrontendConfig.ShortName = shortName
|
|
|
|
value, ok := c_app.FrontendClientIdMaps[frontendName]
|
|
if !ok {
|
|
log.ErrorF("FrontendClientIdMaps error ! not contains %s", frontendName)
|
|
continue
|
|
}
|
|
|
|
c_app.DefaultCmiiFrontendConfig.ClientId = value
|
|
|
|
c_app.DefaultCmiiFrontendConfig.ConfigMapDeploy(common)
|
|
}
|
|
}
|
|
|
|
// CmiiEnvironmentDeploy 部署完整的CMII环境的所有组件
|
|
func CmiiEnvironmentDeploy() {
|
|
|
|
// common environment
|
|
common := &z_dep.CommonEnvironmentConfig{
|
|
WebIP: "lab.uavcmlc.com",
|
|
WebPort: "",
|
|
HarborIP: image2.CmiiHarborPrefix,
|
|
HarborPort: "",
|
|
Namespace: "devflight",
|
|
TagVersion: "5.5.0",
|
|
TenantEnv: "devflight",
|
|
}
|
|
|
|
folderPrefix := "/home/wdd/IdeaProjects/ProjectOctopus/agent-deploy/"
|
|
|
|
// clear old apply file
|
|
|
|
// clear all middleware data
|
|
// ignore redis rabbitmq mongo nacos emqx
|
|
// sync mysql-data
|
|
|
|
// generate new apply file for specific environment
|
|
|
|
// apply for them
|
|
}
|