部署集
更新时间:2024-07-02
创建部署集
通过以下代码可以根据指定的部署集策略创建部署集。
package main
import (
"fmt"
"github.com/baidubce/bce-sdk-go/services/bcc"
"github.com/baidubce/bce-sdk-go/services/bcc/api"
)
func main() {
// 设置您的ak、sk和要访问的endpoint
ak := "ak"
sk := "sk"
endpoint := "bcc.bj.baidubce.com"
// 创建bcc client
bccClient, _ := bcc.NewClient(ak, sk, endpoint)
CreateDploySetArgs := &api.CreateDeploySetArgs{
// 部署集策略,默认为HOST_HA
Strategy: "HOST_HA",
// 部署集名称
Name: "testDeploySetName",
// 部署集描述
Desc: "test Deploy Desc",
// 部署集并发度
Concurrency: 2,
}
result, err := bccClient.CreateDeploySet(CreateDploySetArgs)
fmt.Println(err)
fmt.Println(result)
}
查询部署集列表
通过以下代码可以查询所有部署集实例的列表及详情信息。
package main
import (
"fmt"
"github.com/baidubce/bce-sdk-go/services/bcc"
)
func main() {
// 设置您的ak、sk和要访问的endpoint
ak := "ak"
sk := "sk"
endpoint := "bcc.bj.baidubce.com"
// 创建bcc client
bccClient, _ := bcc.NewClient(ak, sk, endpoint)
result, err := bccClient.ListDeploySets()
fmt.Println(err)
fmt.Println(result)
}
修改部署集属性
使用以下代码可以修改指定部署集的属性。
package main
import (
"fmt"
"github.com/baidubce/bce-sdk-go/services/bcc"
"github.com/baidubce/bce-sdk-go/services/bcc/api"
)
func main() {
// 设置您的ak、sk和要访问的endpoint
ak := "ak"
sk := "sk"
endpoint := "bcc.bj.baidubce.com"
// 创建bcc client
bccClient, _ := bcc.NewClient(ak, sk, endpoint)
DeployId := "dset-***"
ModifyDeploySetName := "ModifyName"
ModifyDeployDesc := "Modify Desc"
queryArgs := &api.ModifyDeploySetArgs{
// 部署集名称
Name: ModifyDeploySetName,
// 部署集描述
Desc: ModifyDeployDesc,
}
result, err := bccClient.ModifyDeploySet(DeployId, queryArgs)
fmt.Println(err)
fmt.Println(result)
}
删除指定的部署集
使用以下代码删除用户自己的指定的部署集。
package main
import (
"fmt"
"github.com/baidubce/bce-sdk-go/services/bcc"
)
func main() {
// 设置您的ak、sk和要访问的endpoint
ak := "ak"
sk := "sk"
endpoint := "bcc.bj.baidubce.com"
// 创建bcc client
bccClient, _ := bcc.NewClient(ak, sk, endpoint)
DeployId := "dset-***"
result := bccClient.DeleteDeploySet(DeployId)
fmt.Println(result)
}
绑定指定的部署集
使用以下代码绑定用户自己指定的部署集。
queryArgs := &api.UpdateInstanceDeployArgs{
// 设置你要绑定的InstanceId
InstanceId: "InstanceId",
// 设置你要绑定的DeploySetIds
DeploySetIds: []string{"DeploySetId"},
}
rep, err := BCC_CLIENT.UpdateInstanceDeploySet(queryArgs)
fmt.Println(rep)
ExpectEqual(t.Errorf, err, nil)
解绑指定的部署集
使用以下代码解绑用户自己指定的部署集。
queryArgs := &api.DelInstanceDeployArgs{
// 设置你要解绑的DeploySetId
DeploySetId: "DeploySetId",
// 设置你要解绑的InstanceIds
InstanceIds: []string{"InstanceId"},
}
rep, err := BCC_CLIENT.DelInstanceDeploySet(queryArgs)
fmt.Println(rep)
ExpectEqual(t.Errorf, err, nil)