[ Agent ] [ App ] - k8s-pvc
This commit is contained in:
@@ -44,7 +44,7 @@ func (op *AgentOsOperator) Deploy(appFuncName string, funcArgs ...string) (bool,
|
||||
case "DEPLOY_TEST_NFS":
|
||||
resultOK, result = op.deployTestNFS(funcArgs)
|
||||
break
|
||||
case "deployPVC":
|
||||
case "DEPLOY_K8S_PVC":
|
||||
resultOK, result = op.deployPVC(funcArgs)
|
||||
break
|
||||
case "DEPLOY_STORAGE_CLASS":
|
||||
@@ -198,7 +198,7 @@ func (op *AgentOsOperator) deployK8sDashboard(funcArgs []string) (bool, []string
|
||||
}
|
||||
|
||||
// check deployment ok
|
||||
if !CheckDeploymentStatusTimeout("kubernetes-dashboard", "kube-system", 120) {
|
||||
if !K8sCheckDeploymentStatusTimeout("kubernetes-dashboard", "kube-system", 120) {
|
||||
return false, []string{
|
||||
"[deployK8sDashboard] - deployment run error !",
|
||||
}
|
||||
@@ -209,14 +209,14 @@ func (op *AgentOsOperator) deployK8sDashboard(funcArgs []string) (bool, []string
|
||||
|
||||
func (op *AgentOsOperator) deployK8sNamespace(funcArgs []string) (bool, []string) {
|
||||
|
||||
if !CreateK8sNamespace(funcArgs[1]) {
|
||||
if !K8sCreateNamespace(funcArgs[1]) {
|
||||
return false, []string{
|
||||
fmt.Sprintf("Namespace of %s create error!", funcArgs[1]),
|
||||
fmt.Sprintf("Namespace of [%s] create error!", funcArgs[1]),
|
||||
}
|
||||
}
|
||||
|
||||
return true, []string{
|
||||
fmt.Sprintf("Namespace of %s create success !", funcArgs[1]),
|
||||
fmt.Sprintf("Namespace of [%s]create success !", funcArgs[1]),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ func (op *AgentOsOperator) deployNFS(funcArgs []string) (bool, []string) {
|
||||
}
|
||||
|
||||
// check running status
|
||||
if !CheckDeploymentStatusTimeout("nfs-client-provisioner", "kube-system", 60) {
|
||||
if !K8sCheckDeploymentStatusTimeout("nfs-client-provisioner", "kube-system", 60) {
|
||||
return false, []string{
|
||||
"[deployNFS] - nfs running error !",
|
||||
}
|
||||
@@ -365,7 +365,7 @@ func (op *AgentOsOperator) deployTestNFS(funcArgs []string) (bool, []string) {
|
||||
result = append(result, "NFS 文件写入 异常!!")
|
||||
}
|
||||
|
||||
if !CheckPodStatusTimeout("test-pod", "default", 30) {
|
||||
if !K8sCheckPodStatusTimeout("test-pod", "default", 30) {
|
||||
return false, []string{
|
||||
"[deployTestNFS] - test pod create failed !",
|
||||
}
|
||||
@@ -389,27 +389,41 @@ func (op *AgentOsOperator) deployPVC(funcArgs []string) (bool, []string) {
|
||||
}
|
||||
|
||||
// 下载模板文件
|
||||
k8sNFSYamlFile := "/root/wdd/install/k8s-pvc.yaml"
|
||||
ok, resultLog := BasicDownloadFile(op.OssOfflinePrefix+pvcTemplateFile, k8sNFSYamlFile)
|
||||
k8sPvcYamlFile := "/root/wdd/install/k8s-pvc.yaml"
|
||||
ok, resultLog := BasicDownloadFile(op.OssOfflinePrefix+pvcTemplateFile, k8sPvcYamlFile)
|
||||
if !ok {
|
||||
return false, resultLog
|
||||
}
|
||||
// 根据参数 A1C2IP 替换
|
||||
if !BasicReplace(k8sNFSYamlFile, "SUPREME", funcArgs[1]) {
|
||||
if !BasicReplace(k8sPvcYamlFile, "SUPREME", funcArgs[1]) {
|
||||
result = append(result, "替换SUPREME信息")
|
||||
return false, result
|
||||
}
|
||||
|
||||
// 启动服务
|
||||
exec, strings := KubectlApplyExec(k8sNFSYamlFile)
|
||||
exec, strings := KubectlApplyExec(k8sPvcYamlFile)
|
||||
if !exec {
|
||||
return false, strings
|
||||
}
|
||||
|
||||
// 成功启动
|
||||
return true, []string{
|
||||
"PVC部署成功!",
|
||||
// check status
|
||||
ok, pvcList := K8sListPVCInNamespace(funcArgs[1])
|
||||
if !ok {
|
||||
return false, []string{
|
||||
"[deployPVC] - pvc list error ! can not check status !",
|
||||
}
|
||||
}
|
||||
|
||||
for _, pvcName := range pvcList {
|
||||
if !K8sCheckPVCStatusTimeOut(pvcName, funcArgs[1], 30) {
|
||||
return false, []string{
|
||||
fmt.Sprintf("[deployPVC] - pvc [%s] in namepsace [%s] running error !", pvcName, funcArgs[1]),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 成功启动
|
||||
return true, append(pvcList, "PVC部署成功!")
|
||||
}
|
||||
|
||||
func (op *AgentOsOperator) deployMySQL(funcArgs []string) (bool, []string) {
|
||||
@@ -452,6 +466,13 @@ func (op *AgentOsOperator) deployMySQL(funcArgs []string) (bool, []string) {
|
||||
return false, append(result, strings...)
|
||||
}
|
||||
|
||||
// check mysql
|
||||
if !K8sCheckPodStatusTimeout("helm-mysql-0", funcArgs[0], 180) {
|
||||
return false, []string{
|
||||
"helm-mysql-0 启动失败!",
|
||||
}
|
||||
}
|
||||
|
||||
// 成功启动
|
||||
return true, []string{
|
||||
"MySQL部署成功!",
|
||||
@@ -464,7 +485,7 @@ func (op *AgentOsOperator) loadMysqlInitScript(funcArgs []string) (bool, []strin
|
||||
|
||||
func (op *AgentOsOperator) checkMySQL(funcArgs []string) (bool, []string) {
|
||||
|
||||
if !CheckPodStatusTimeout("helm-mysql-0", funcArgs[0], 180) {
|
||||
if !K8sCheckPodStatusTimeout("helm-mysql-0", funcArgs[0], 180) {
|
||||
return false, []string{
|
||||
"helm-mysql 启动失败!",
|
||||
}
|
||||
@@ -560,6 +581,19 @@ func (op *AgentOsOperator) deployRedis(funcArgs []string) (bool, []string) {
|
||||
return false, append(result, strings...)
|
||||
}
|
||||
|
||||
// check status
|
||||
if !K8sCheckPodStatusTimeout("helm-redis-master-0", funcArgs[1], 120) {
|
||||
return false, []string{
|
||||
"[deployRedis] - redis-master running failed ! please cheak !",
|
||||
}
|
||||
}
|
||||
|
||||
if !K8sCheckPodStatusTimeout("helm-redis-replicas-0", funcArgs[1], 120) {
|
||||
return false, []string{
|
||||
"[deployRedis] - redis-replicas running failed ! please check !",
|
||||
}
|
||||
}
|
||||
|
||||
// 成功启动
|
||||
return true, []string{
|
||||
"Redis 部署成功!",
|
||||
|
||||
Reference in New Issue
Block a user