Merge pull request '合并覆盖' (#17) from github_branch into master
This commit is contained in:
commit
79990eda0a
|
@ -19,7 +19,7 @@ func CreateContainerGroup(request *CreateContainerGroupRequest) (response *Creat
|
||||||
|
|
||||||
provider := pbtenant.CloudProvider(request.ProviderId)
|
provider := pbtenant.CloudProvider(request.ProviderId)
|
||||||
var configFile string
|
var configFile string
|
||||||
flag.StringVar(&configFile, "conf", "configs/config.yaml", "config.yaml")
|
flag.StringVar(&configFile, "confAli", "configs/config.yaml", "config.yaml")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
defer glog.Flush()
|
defer glog.Flush()
|
||||||
|
|
||||||
|
@ -43,15 +43,21 @@ func CreateContainerGroup(request *CreateContainerGroupRequest) (response *Creat
|
||||||
switch request.ProviderId {
|
switch request.ProviderId {
|
||||||
case 0:
|
case 0:
|
||||||
regionId, _ = tenanter.GetAliRegionId(request.RegionId)
|
regionId, _ = tenanter.GetAliRegionId(request.RegionId)
|
||||||
|
cpuPod = strconv.FormatFloat(cpuPodFloat, 'f', 0, 64)
|
||||||
|
memoryPod = strconv.FormatFloat(memoryPodFloat, 'f', 0, 64)
|
||||||
case 1:
|
case 1:
|
||||||
regionId, _ = tenanter.GetTencentRegionId(request.RegionId)
|
regionId, _ = tenanter.GetTencentRegionId(request.RegionId)
|
||||||
|
cpuPod = strconv.FormatFloat(cpuPodFloat, 'f', 0, 64)
|
||||||
|
memoryPod = strconv.FormatFloat(memoryPodFloat, 'f', 0, 64)
|
||||||
case 2:
|
case 2:
|
||||||
//华为的CPU和内存数量要进行转换
|
//华为的CPU和内存数量要进行转换
|
||||||
regionId, _ = tenanter.GetHuaweiRegionId(request.RegionId)
|
regionId, _ = tenanter.GetHuaweiRegionId(request.RegionId)
|
||||||
cpuPod = strconv.FormatFloat(cpuPodFloat*1000, 'f', 0, 64)
|
cpuPod = strconv.FormatFloat(cpuPodFloat*1000, 'f', 0, 64) + "m"
|
||||||
memoryPod = strconv.FormatFloat(memoryPodFloat, 'f', 0, 64)
|
memoryPod = strconv.FormatFloat(memoryPodFloat, 'f', 0, 64) + "Gi"
|
||||||
case 3:
|
case 3:
|
||||||
regionId, _ = tenanter.GetK8SRegionId(request.RegionId)
|
regionId, _ = tenanter.GetK8SRegionId(request.RegionId)
|
||||||
|
cpuPod = strconv.FormatFloat(cpuPodFloat*1000, 'f', 0, 64) + "m"
|
||||||
|
memoryPod = strconv.FormatFloat(memoryPodFloat, 'f', 0, 64) + "Gi"
|
||||||
}
|
}
|
||||||
|
|
||||||
requestPCM := &pbpod.CreatePodReq{
|
requestPCM := &pbpod.CreatePodReq{
|
||||||
|
@ -62,8 +68,8 @@ func CreateContainerGroup(request *CreateContainerGroupRequest) (response *Creat
|
||||||
RegionId: regionId,
|
RegionId: regionId,
|
||||||
ContainerImage: containerImage,
|
ContainerImage: containerImage,
|
||||||
ContainerName: containerName,
|
ContainerName: containerName,
|
||||||
CpuPod: cpuPod + "m",
|
CpuPod: cpuPod,
|
||||||
MemoryPod: memoryPod + "Gi",
|
MemoryPod: memoryPod,
|
||||||
SecurityGroupId: "sg-6qlun7hd",
|
SecurityGroupId: "sg-6qlun7hd",
|
||||||
SubnetId: "subnet-mnwfg2fk",
|
SubnetId: "subnet-mnwfg2fk",
|
||||||
VpcId: "vpc-rkwt40g5",
|
VpcId: "vpc-rkwt40g5",
|
||||||
|
|
|
@ -33,7 +33,7 @@ func DeleteContainerGroup(request *DeleteContainerGroupRequest) (response *Delet
|
||||||
|
|
||||||
provider := pbtenant.CloudProvider(request.ProviderId)
|
provider := pbtenant.CloudProvider(request.ProviderId)
|
||||||
var configFile string
|
var configFile string
|
||||||
flag.StringVar(&configFile, "conf", "configs/config.yaml", "config.yaml")
|
flag.StringVar(&configFile, "confAli", "configs/config.yaml", "config.yaml")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
defer glog.Flush()
|
defer glog.Flush()
|
||||||
|
|
||||||
|
@ -47,21 +47,18 @@ func DeleteContainerGroup(request *DeleteContainerGroupRequest) (response *Delet
|
||||||
glog.Infof("load tenant from file finished")
|
glog.Infof("load tenant from file finished")
|
||||||
var regionId int32
|
var regionId int32
|
||||||
var pcmId string
|
var pcmId string
|
||||||
podId := request.ContainerGroupId
|
pcmId = request.PcmId
|
||||||
podName := request.ContainerGroupName
|
//podId := request.ContainerGroupId
|
||||||
|
//podName := request.ContainerGroupName
|
||||||
switch request.ProviderId {
|
switch request.ProviderId {
|
||||||
case 0:
|
case 0:
|
||||||
regionId, _ = tenanter.GetAliRegionId(request.RegionId)
|
regionId, _ = tenanter.GetAliRegionId(request.RegionId)
|
||||||
pcmId = podId
|
|
||||||
case 1:
|
case 1:
|
||||||
regionId, _ = tenanter.GetTencentRegionId(request.RegionId)
|
regionId, _ = tenanter.GetTencentRegionId(request.RegionId)
|
||||||
pcmId = podId
|
|
||||||
case 2:
|
case 2:
|
||||||
regionId, _ = tenanter.GetHuaweiRegionId(request.RegionId)
|
regionId, _ = tenanter.GetHuaweiRegionId(request.RegionId)
|
||||||
pcmId = podName
|
|
||||||
case 3:
|
case 3:
|
||||||
regionId, _ = tenanter.GetK8SRegionId(request.RegionId)
|
regionId, _ = tenanter.GetK8SRegionId(request.RegionId)
|
||||||
pcmId = podName
|
|
||||||
}
|
}
|
||||||
|
|
||||||
requestPCM := &pbpod.DeletePodReq{
|
requestPCM := &pbpod.DeletePodReq{
|
||||||
|
@ -69,14 +66,15 @@ func DeleteContainerGroup(request *DeleteContainerGroupRequest) (response *Delet
|
||||||
Provider: provider,
|
Provider: provider,
|
||||||
AccountName: request.AccountName,
|
AccountName: request.AccountName,
|
||||||
PcmId: pcmId,
|
PcmId: pcmId,
|
||||||
PodId: podId,
|
|
||||||
PodName: podName,
|
|
||||||
Namespace: request.Namespace,
|
Namespace: request.Namespace,
|
||||||
RegionId: regionId,
|
RegionId: regionId,
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := server.DeletePod(nil, requestPCM)
|
resp, err := server.DeletePod(nil, requestPCM)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
response = &DeleteContainerGroupResponse{
|
response = &DeleteContainerGroupResponse{
|
||||||
BaseResponse: nil,
|
BaseResponse: nil,
|
||||||
RequestId: resp.RequestId,
|
RequestId: resp.RequestId,
|
||||||
|
@ -94,6 +92,7 @@ type DeleteContainerGroupRequest struct {
|
||||||
ProviderId int32 `position:"Query" name:"ProviderId"`
|
ProviderId int32 `position:"Query" name:"ProviderId"`
|
||||||
AccountName string `position:"Query" name:"AccountName"`
|
AccountName string `position:"Query" name:"AccountName"`
|
||||||
Namespace string `position:"Query" name:"Namespace"`
|
Namespace string `position:"Query" name:"Namespace"`
|
||||||
|
PcmId string `position:"Query" name:"PcmId"`
|
||||||
ContainerGroupName string `position:"Query" name:"ContainerGroupName"`
|
ContainerGroupName string `position:"Query" name:"ContainerGroupName"`
|
||||||
/*********PCM param************/
|
/*********PCM param************/
|
||||||
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
|
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
|
||||||
|
|
|
@ -33,7 +33,7 @@ func UpdateContainerGroup(request *UpdateContainerGroupRequest) (response *Updat
|
||||||
|
|
||||||
provider := pbtenant.CloudProvider(request.ProviderId)
|
provider := pbtenant.CloudProvider(request.ProviderId)
|
||||||
var configFile string
|
var configFile string
|
||||||
flag.StringVar(&configFile, "conf", "configs/config.yaml", "config.yaml")
|
flag.StringVar(&configFile, "confAli", "configs/config.yaml", "config.yaml")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
defer glog.Flush()
|
defer glog.Flush()
|
||||||
|
|
||||||
|
@ -62,6 +62,7 @@ func UpdateContainerGroup(request *UpdateContainerGroupRequest) (response *Updat
|
||||||
RequestSource: "ali",
|
RequestSource: "ali",
|
||||||
Provider: provider,
|
Provider: provider,
|
||||||
AccountName: request.AccountName,
|
AccountName: request.AccountName,
|
||||||
|
PcmId: request.PcmId,
|
||||||
PodId: request.ContainerGroupId,
|
PodId: request.ContainerGroupId,
|
||||||
PodName: request.ContainerGroupName,
|
PodName: request.ContainerGroupName,
|
||||||
Namespace: request.Namespace,
|
Namespace: request.Namespace,
|
||||||
|
@ -71,7 +72,7 @@ func UpdateContainerGroup(request *UpdateContainerGroupRequest) (response *Updat
|
||||||
CpuPod: string(containers[0].Cpu),
|
CpuPod: string(containers[0].Cpu),
|
||||||
MemoryPod: string(containers[0].Memory),
|
MemoryPod: string(containers[0].Memory),
|
||||||
RestartPolicy: request.RestartPolicy,
|
RestartPolicy: request.RestartPolicy,
|
||||||
Labels: "",
|
Labels: "sss",
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := server.UpdatePod(nil, requestPCM)
|
resp, err := server.UpdatePod(nil, requestPCM)
|
||||||
|
@ -92,6 +93,8 @@ type UpdateContainerGroupRequest struct {
|
||||||
ProviderId int32 `position:"Query" name:"ProviderId"`
|
ProviderId int32 `position:"Query" name:"ProviderId"`
|
||||||
AccountName string `position:"Query" name:"AccountName"`
|
AccountName string `position:"Query" name:"AccountName"`
|
||||||
Namespace string `position:"Query" name:"Namespace"`
|
Namespace string `position:"Query" name:"Namespace"`
|
||||||
|
PcmId string `position:"Query" name:"PcmId"`
|
||||||
|
PodName string `position:"Query" name:"PodName"`
|
||||||
ContainerGroupName string `position:"Query" name:"ContainerGroupName"`
|
ContainerGroupName string `position:"Query" name:"ContainerGroupName"`
|
||||||
/*********PCM param************/
|
/*********PCM param************/
|
||||||
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
|
OwnerId requests.Integer `position:"Query" name:"OwnerId"`
|
||||||
|
|
|
@ -126,7 +126,7 @@ func (eci *AliEci) DeletePod(ctx context.Context, req *pbpod.DeletePodReq) (*pbp
|
||||||
isFinished := true
|
isFinished := true
|
||||||
if err != nil {
|
if err != nil {
|
||||||
isFinished = false
|
isFinished = false
|
||||||
return nil, errors.Wrap(err, "Aliyun DeletePod error")
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.Infof("--------------------Aliyun ECI Instance deleted--------------------")
|
glog.Infof("--------------------Aliyun ECI Instance deleted--------------------")
|
||||||
|
@ -157,7 +157,7 @@ func (eci *AliEci) UpdatePod(ctx context.Context, req *pbpod.UpdatePodReq) (*pbp
|
||||||
isFinished := true
|
isFinished := true
|
||||||
if err != nil {
|
if err != nil {
|
||||||
isFinished = false
|
isFinished = false
|
||||||
return nil, errors.Wrap(err, "Aliyun UpdatePod error")
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.Infof("--------------------Aliyun ECI Instance updated--------------------")
|
glog.Infof("--------------------Aliyun ECI Instance updated--------------------")
|
||||||
|
@ -176,7 +176,7 @@ func (eci *AliEci) ListPodDetail(ctx context.Context, req *pbpod.ListPodDetailRe
|
||||||
resp, err := eci.cli.DescribeContainerGroups(request)
|
resp, err := eci.cli.DescribeContainerGroups(request)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "Aliyun ListDetail error")
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var ecies = make([]*pbpod.PodInstance, len(resp.ContainerGroups))
|
var ecies = make([]*pbpod.PodInstance, len(resp.ContainerGroups))
|
||||||
|
|
|
@ -128,7 +128,7 @@ func (cci *HuaweiCci) CreatePod(ctx context.Context, req *pbpod.CreatePodReq) (*
|
||||||
|
|
||||||
resp, err := cci.cli.CoreV1().Pods(req.Namespace).Create(context.TODO(), &pod, metav1.CreateOptions{})
|
resp, err := cci.cli.CoreV1().Pods(req.Namespace).Create(context.TODO(), &pod, metav1.CreateOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "Huaweiyun CreatePod error")
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
isFinished := false
|
isFinished := false
|
||||||
|
@ -152,8 +152,7 @@ func (cci *HuaweiCci) DeletePod(ctx context.Context, req *pbpod.DeletePodReq) (*
|
||||||
|
|
||||||
isFinished := true
|
isFinished := true
|
||||||
if err != nil {
|
if err != nil {
|
||||||
isFinished = false
|
return nil, err
|
||||||
return nil, errors.Wrap(err, "Huaweiyun DeletePod error")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.Infof("--------------------Huawei CCI Instance deleted--------------------")
|
glog.Infof("--------------------Huawei CCI Instance deleted--------------------")
|
||||||
|
@ -171,12 +170,12 @@ func (cci *HuaweiCci) UpdatePod(ctx context.Context, req *pbpod.UpdatePodReq) (*
|
||||||
|
|
||||||
qresp, err := cci.cli.CoreV1().Pods(req.GetNamespace()).Get(context.TODO(), req.PcmId, metav1.GetOptions{})
|
qresp, err := cci.cli.CoreV1().Pods(req.GetNamespace()).Get(context.TODO(), req.PcmId, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "Huaweiyun UpdatePod error")
|
return nil, err
|
||||||
}
|
}
|
||||||
pod := corev1.Pod{
|
pod := corev1.Pod{
|
||||||
TypeMeta: qresp.TypeMeta,
|
TypeMeta: qresp.TypeMeta,
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: req.PodName,
|
Name: req.PcmId,
|
||||||
Namespace: req.Namespace,
|
Namespace: req.Namespace,
|
||||||
Labels: map[string]string{"name": req.Labels},
|
Labels: map[string]string{"name": req.Labels},
|
||||||
},
|
},
|
||||||
|
@ -210,7 +209,7 @@ func (cci *HuaweiCci) ListPodDetail(ctx context.Context, req *pbpod.ListPodDetai
|
||||||
resp, err := cci.cli.CoreV1().Pods(req.GetNamespace()).List(context.TODO(), metav1.ListOptions{})
|
resp, err := cci.cli.CoreV1().Pods(req.GetNamespace()).List(context.TODO(), metav1.ListOptions{})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "Huaweiyun ListDetail pod error")
|
return nil, err
|
||||||
}
|
}
|
||||||
glog.Info("Huaweiyun ListDetail pod success", resp.Items)
|
glog.Info("Huaweiyun ListDetail pod success", resp.Items)
|
||||||
var pods = make([]*pbpod.PodInstance, len(resp.Items))
|
var pods = make([]*pbpod.PodInstance, len(resp.Items))
|
||||||
|
|
|
@ -114,7 +114,7 @@ func (k *K8SPoder) CreatePod(ctx context.Context, req *pbpod.CreatePodReq) (*pbp
|
||||||
|
|
||||||
resp, err := k.cli.CoreV1().Pods(req.Namespace).Create(context.TODO(), &pod, metav1.CreateOptions{})
|
resp, err := k.cli.CoreV1().Pods(req.Namespace).Create(context.TODO(), &pod, metav1.CreateOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "K8S CreatePod error")
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.Infof("--------------------K8S Pod Instance created--------------------")
|
glog.Infof("--------------------K8S Pod Instance created--------------------")
|
||||||
|
@ -143,8 +143,7 @@ func (k K8SPoder) DeletePod(ctx context.Context, req *pbpod.DeletePodReq) (*pbpo
|
||||||
|
|
||||||
isFinished := true
|
isFinished := true
|
||||||
if err != nil {
|
if err != nil {
|
||||||
isFinished = false
|
return nil, err
|
||||||
return nil, errors.Wrap(err, "K8S DeletePod error")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pbpod.DeletePodResp{
|
return &pbpod.DeletePodResp{
|
||||||
|
@ -174,7 +173,7 @@ func (k K8SPoder) UpdatePod(ctx context.Context, req *pbpod.UpdatePodReq) (*pbpo
|
||||||
pod.Spec.Containers[0].Image = req.ContainerImage
|
pod.Spec.Containers[0].Image = req.ContainerImage
|
||||||
resp, err := k.cli.CoreV1().Pods(req.Namespace).Update(context.TODO(), &pod, metav1.UpdateOptions{})
|
resp, err := k.cli.CoreV1().Pods(req.Namespace).Update(context.TODO(), &pod, metav1.UpdateOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "K8S UpdatePod error")
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.Infof("--------------------K8S Pod Instance updated--------------------")
|
glog.Infof("--------------------K8S Pod Instance updated--------------------")
|
||||||
|
@ -196,7 +195,7 @@ func (k K8SPoder) UpdatePod(ctx context.Context, req *pbpod.UpdatePodReq) (*pbpo
|
||||||
func (k K8SPoder) ListPodDetail(ctx context.Context, req *pbpod.ListPodDetailReq) (*pbpod.ListPodDetailResp, error) {
|
func (k K8SPoder) ListPodDetail(ctx context.Context, req *pbpod.ListPodDetailReq) (*pbpod.ListPodDetailResp, error) {
|
||||||
resp, err := k.cli.CoreV1().Pods(req.GetNamespace()).List(context.TODO(), metav1.ListOptions{})
|
resp, err := k.cli.CoreV1().Pods(req.GetNamespace()).List(context.TODO(), metav1.ListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "K8S ListDetail pod error")
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var pods = make([]*pbpod.PodInstance, len(resp.Items))
|
var pods = make([]*pbpod.PodInstance, len(resp.Items))
|
||||||
|
|
|
@ -155,16 +155,12 @@ func (eks *TencentEks) UpdatePod(ctx context.Context, req *pbpod.UpdatePodReq) (
|
||||||
//创建更新pod请求
|
//创建更新pod请求
|
||||||
request := tencenteks.NewUpdateEKSContainerInstanceRequest()
|
request := tencenteks.NewUpdateEKSContainerInstanceRequest()
|
||||||
request.EksCiId = &req.PcmId
|
request.EksCiId = &req.PcmId
|
||||||
request.RestartPolicy = &req.RestartPolicy
|
|
||||||
request.Name = &req.PodName
|
request.Name = &req.PodName
|
||||||
cpu, err := strconv.ParseFloat(req.CpuPod, 64)
|
request.RestartPolicy = &req.RestartPolicy
|
||||||
memory, err := strconv.ParseFloat(req.MemoryPod, 64)
|
|
||||||
request.Containers = make([]*tencenteks.Container, 1)
|
request.Containers = make([]*tencenteks.Container, 1)
|
||||||
request.Containers[0] = new(tencenteks.Container)
|
request.Containers[0] = new(tencenteks.Container)
|
||||||
request.Containers[0].Name = &req.ContainerName
|
request.Containers[0].Name = &req.ContainerName
|
||||||
request.Containers[0].Image = &req.ContainerImage
|
request.Containers[0].Image = &req.ContainerImage
|
||||||
request.Containers[0].Cpu = &cpu
|
|
||||||
request.Containers[0].Memory = &memory
|
|
||||||
resp, err := eks.cli.UpdateEKSContainerInstance(request)
|
resp, err := eks.cli.UpdateEKSContainerInstance(request)
|
||||||
isFinished := true
|
isFinished := true
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -3,11 +3,12 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
openapi "github.com/alibabacloud-go/darabonba-openapi/client"
|
openapi "github.com/alibabacloud-go/darabonba-openapi/client"
|
||||||
eci20180808 "github.com/alibabacloud-go/eci-20180808/v2/client"
|
"github.com/aliyun/alibaba-cloud-sdk-go/services/eci"
|
||||||
|
|
||||||
"github.com/alibabacloud-go/tea/tea"
|
"github.com/alibabacloud-go/tea/tea"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CreateClient(accessKeyId *string, accessKeySecret *string) (_result *eci20180808.Client, _err error) {
|
func CreateClient(accessKeyId *string, accessKeySecret *string) (_result *eci.Client, _err error) {
|
||||||
config := &openapi.Config{
|
config := &openapi.Config{
|
||||||
// 您的AccessKey ID
|
// 您的AccessKey ID
|
||||||
AccessKeyId: accessKeyId,
|
AccessKeyId: accessKeyId,
|
||||||
|
@ -16,32 +17,78 @@ func CreateClient(accessKeyId *string, accessKeySecret *string) (_result *eci201
|
||||||
}
|
}
|
||||||
// 访问的域名
|
// 访问的域名
|
||||||
config.Endpoint = tea.String("eci.aliyuncs.com")
|
config.Endpoint = tea.String("eci.aliyuncs.com")
|
||||||
_result = &eci20180808.Client{}
|
_result = &eci.Client{}
|
||||||
_result, _err = eci20180808.NewClient(config)
|
_result, _err = eci.NewClientWithAccessKey("cn-hangzhou", *accessKeyId, *accessKeySecret)
|
||||||
return _result, _err
|
return _result, _err
|
||||||
}
|
}
|
||||||
|
|
||||||
func aliOriginMain() (_err error) {
|
func aliCreate(client eci.Client) (_err error) {
|
||||||
client, _err := CreateClient(tea.String(""), tea.String(""))
|
|
||||||
if _err != nil {
|
request := eci.CreateCreateContainerGroupRequest()
|
||||||
return _err
|
request.RegionId = "cn-hangzhou"
|
||||||
}
|
request.ContainerGroupName = "pcm0517"
|
||||||
|
requestContainer := make([]eci.CreateContainerGroupContainer, 1)
|
||||||
|
requestContainer[0].Image = "nginx:latest"
|
||||||
|
requestContainer[0].Name = "pcm"
|
||||||
|
requestContainer[0].Cpu = "1"
|
||||||
|
requestContainer[0].Memory = "2"
|
||||||
|
request.Container = &requestContainer
|
||||||
|
|
||||||
|
resp, _err := client.CreateContainerGroup(request)
|
||||||
|
println(resp.ContainerGroupId)
|
||||||
|
|
||||||
|
return _err
|
||||||
|
}
|
||||||
|
|
||||||
|
func aliDescribe(client eci.Client) (_err error) {
|
||||||
|
|
||||||
|
request := eci.CreateDescribeContainerGroupsRequest()
|
||||||
|
request.RegionId = "cn-hangzhou"
|
||||||
|
|
||||||
|
resp, _err := client.DescribeContainerGroups(request)
|
||||||
|
println(resp.ContainerGroups[0].ContainerGroupId)
|
||||||
|
|
||||||
describeContainerGroupsRequest := &eci20180808.DescribeContainerGroupsRequest{
|
|
||||||
RegionId: tea.String("cn-hangzhou"),
|
|
||||||
}
|
|
||||||
// 复制代码运行请自行打印 API 的返回值
|
|
||||||
resp, _err := client.DescribeContainerGroups(describeContainerGroupsRequest)
|
|
||||||
println(*resp.Body.ContainerGroups[0].ContainerGroupId)
|
|
||||||
if _err != nil {
|
if _err != nil {
|
||||||
return _err
|
return _err
|
||||||
}
|
}
|
||||||
return _err
|
return _err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func aliUpdate(client eci.Client) (_err error) {
|
||||||
|
|
||||||
|
request := eci.CreateUpdateContainerGroupRequest()
|
||||||
|
request.RegionId = "cn-hangzhou"
|
||||||
|
request.ContainerGroupId = "eci-bp10k06yd8efj65d4iqg"
|
||||||
|
request.RestartPolicy = "Never"
|
||||||
|
|
||||||
|
resp, _err := client.UpdateContainerGroup(request)
|
||||||
|
println(resp.RequestId)
|
||||||
|
if _err != nil {
|
||||||
|
return _err
|
||||||
|
}
|
||||||
|
return _err
|
||||||
|
}
|
||||||
|
|
||||||
|
func aliDelete(client eci.Client) (_err error) {
|
||||||
|
|
||||||
|
request := eci.CreateDeleteContainerGroupRequest()
|
||||||
|
request.RegionId = "cn-hangzhou"
|
||||||
|
request.ContainerGroupId = "eci-bp10k06yd8efj65d4iqg"
|
||||||
|
|
||||||
|
resp, _err := client.DeleteContainerGroup(request)
|
||||||
|
println(resp.RequestId)
|
||||||
|
if _err != nil {
|
||||||
|
return _err
|
||||||
|
}
|
||||||
|
return _err
|
||||||
|
}
|
||||||
func main() {
|
func main() {
|
||||||
err := aliOriginMain()
|
client, _ := CreateClient(tea.String(""), tea.String(""))
|
||||||
|
|
||||||
|
err := aliDelete(*client)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,8 @@ const (
|
||||||
cciEndpoint = "https://cci.cn-east-3.myhuaweicloud.com"
|
cciEndpoint = "https://cci.cn-east-3.myhuaweicloud.com"
|
||||||
iamEndpoint = "https://iam.cn-east-3.myhuaweicloud.com"
|
iamEndpoint = "https://iam.cn-east-3.myhuaweicloud.com"
|
||||||
projectName = "cn-east-3"
|
projectName = "cn-east-3"
|
||||||
ak = "ATQTIWUT9K66VRMMXKVY"
|
ak = ""
|
||||||
sk = "Wa0aixDVuhZOfDZGWvgIJQBHnyiDlGdgDn1Ai5Yy"
|
sk = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewClientOrigin 通过AK/SK认证创建ClientSet
|
// NewClientOrigin 通过AK/SK认证创建ClientSet
|
||||||
|
@ -105,8 +105,8 @@ func UpdatePodOrigin(client *kubernetes.Clientset) error {
|
||||||
Image: "library/nginx:stable-alpine-perl",
|
Image: "library/nginx:stable-alpine-perl",
|
||||||
Resources: corev1.ResourceRequirements{
|
Resources: corev1.ResourceRequirements{
|
||||||
Limits: map[corev1.ResourceName]resource.Quantity{
|
Limits: map[corev1.ResourceName]resource.Quantity{
|
||||||
corev1.ResourceCPU: resource.MustParse("500m"),
|
corev1.ResourceCPU: resource.MustParse("1000m"),
|
||||||
corev1.ResourceMemory: resource.MustParse("1Gi"),
|
corev1.ResourceMemory: resource.MustParse("2Gi"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -121,7 +121,7 @@ func UpdatePodOrigin(client *kubernetes.Clientset) error {
|
||||||
|
|
||||||
// DeletePodOrigin 删除Pod
|
// DeletePodOrigin 删除Pod
|
||||||
func DeletePodOrigin(client *kubernetes.Clientset) error {
|
func DeletePodOrigin(client *kubernetes.Clientset) error {
|
||||||
return client.CoreV1().Pods("pcm").Delete(context.TODO(), "podName", metav1.DeleteOptions{})
|
return client.CoreV1().Pods("pcm").Delete(context.TODO(), "hw-sdk-test", metav1.DeleteOptions{})
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListPodOrigin 查询Pod
|
// ListPodOrigin 查询Pod
|
||||||
|
@ -135,20 +135,9 @@ func main() {
|
||||||
|
|
||||||
cs, _ := NewClientOrigin()
|
cs, _ := NewClientOrigin()
|
||||||
|
|
||||||
fmt.Println("start to create Pod")
|
//CreatePodOrigin(cs)
|
||||||
CreatePodOrigin(cs)
|
//ListPodOrigin(cs)
|
||||||
fmt.Println("Pod created")
|
//UpdatePodOrigin(cs)
|
||||||
|
|
||||||
fmt.Println("start to get Pod details")
|
|
||||||
ListPodOrigin(cs)
|
|
||||||
fmt.Println("Pod details got")
|
|
||||||
|
|
||||||
fmt.Println("start to update Pod")
|
|
||||||
UpdatePodOrigin(cs)
|
|
||||||
fmt.Println("Pod updated")
|
|
||||||
|
|
||||||
fmt.Println("start to delete Pod")
|
|
||||||
DeletePodOrigin(cs)
|
DeletePodOrigin(cs)
|
||||||
fmt.Println("Pod deleted")
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,51 +2,99 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
pcm_pod_ali "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pod/server/ali"
|
pcm_pod_ali "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pod/server/ali"
|
||||||
"github.com/alibabacloud-go/tea/tea"
|
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func _main(args []*string) (_err error) {
|
/*****
|
||||||
|
regionId ali:cn-hangzhou tc:ap-guangzhou hw: cn-east-3
|
||||||
|
image: tencent nginx:latest
|
||||||
|
ali registry-vpc.cn-hangzhou.aliyuncs.com/eci_open/nginx
|
||||||
|
huawei library/nginx:stable-alpine-perl
|
||||||
|
*****/
|
||||||
|
func aliCreatePCM() (_err error) {
|
||||||
|
request := pcm_pod_ali.CreateCreateContainerGroupRequest()
|
||||||
|
|
||||||
//查询
|
/****************PCM params******************/
|
||||||
//describeContainerGroupsRequest := pcm_pod_ali.DescribeContainerGroupsRequest{
|
request.ProviderId = 3
|
||||||
// RegionId: "cn-hangzhou",
|
request.RegionId = "cn-east-3"
|
||||||
// ProviderId: 1,
|
request.Namespace = "pcm"
|
||||||
//}
|
/****************PCM params******************/
|
||||||
//
|
request.ContainerGroupName = "pcm0518"
|
||||||
//// 复制代码运行请自行打印 API 的返回值
|
requestContainer := make([]pcm_pod_ali.CreateContainerGroupContainer, 1)
|
||||||
//resp, _err := pcm_pod_ali.DescribeContainerGroups(&describeContainerGroupsRequest)
|
requestContainer[0].Image = "nginx/nginx:latest"
|
||||||
//println(resp.ContainerGroups[0].ContainerGroupId)
|
requestContainer[0].Name = "pcm"
|
||||||
|
requestContainer[0].Cpu = "1"
|
||||||
//创建
|
requestContainer[0].Memory = "2"
|
||||||
container := pcm_pod_ali.CreateContainerGroupContainer{
|
request.Container = &requestContainer
|
||||||
Image: "nginx:latest",
|
|
||||||
Name: "pcm-sdk-ali",
|
|
||||||
Cpu: "1",
|
|
||||||
Memory: "2",
|
|
||||||
}
|
|
||||||
containers := make([]pcm_pod_ali.CreateContainerGroupContainer, 0)
|
|
||||||
containers = append(containers, container)
|
|
||||||
|
|
||||||
createContainerGroupsRequest := pcm_pod_ali.CreateContainerGroupRequest{
|
|
||||||
RpcRequest: nil,
|
|
||||||
//ali:cn-hangzhou tc:ap-guangzhou hw: cn-east-3
|
|
||||||
RegionId: "cn-east-3",
|
|
||||||
ProviderId: 2,
|
|
||||||
Namespace: "pcm",
|
|
||||||
ContainerGroupName: "sdk-alitohuawei",
|
|
||||||
Container: &containers,
|
|
||||||
}
|
|
||||||
|
|
||||||
// 复制代码运行请自行打印 API 的返回值
|
|
||||||
resp, _err := pcm_pod_ali.CreateContainerGroup(&createContainerGroupsRequest)
|
|
||||||
|
|
||||||
|
resp, _err := pcm_pod_ali.CreateContainerGroup(request)
|
||||||
println(resp.ContainerGroupId)
|
println(resp.ContainerGroupId)
|
||||||
|
|
||||||
|
return _err
|
||||||
|
}
|
||||||
|
|
||||||
|
func aliDescribePCM() (_err error) {
|
||||||
|
request := pcm_pod_ali.CreateDescribeContainerGroupsRequest()
|
||||||
|
|
||||||
|
/****************PCM params******************/
|
||||||
|
request.ProviderId = 3
|
||||||
|
//ali:cn-hangzhou tc:ap-guangzhou hw: cn-east-3
|
||||||
|
request.RegionId = "cn-east-3"
|
||||||
|
request.Namespace = "pcm"
|
||||||
|
/****************PCM params******************/
|
||||||
|
|
||||||
|
resp, _err := pcm_pod_ali.DescribeContainerGroups(request)
|
||||||
|
println(resp.ContainerGroups[0].ContainerGroupName)
|
||||||
|
|
||||||
|
return _err
|
||||||
|
}
|
||||||
|
|
||||||
|
func aliUpdatePCM() (_err error) {
|
||||||
|
request := pcm_pod_ali.CreateUpdateContainerGroupRequest()
|
||||||
|
|
||||||
|
/****************PCM params******************/
|
||||||
|
request.ProviderId = 3
|
||||||
|
request.RegionId = "cn-east-3"
|
||||||
|
request.Namespace = "pcm"
|
||||||
|
request.PcmId = "pcm0517"
|
||||||
|
/****************PCM params******************/
|
||||||
|
request.PodName = "pcm0517"
|
||||||
|
request.RestartPolicy = "Never"
|
||||||
|
requestContainer := make([]pcm_pod_ali.UpdateContainerGroupContainer, 1)
|
||||||
|
requestContainer[0].Cpu = "2"
|
||||||
|
requestContainer[0].Memory = "4"
|
||||||
|
requestContainer[0].Image = "nginx:latest"
|
||||||
|
requestContainer[0].Name = "pcm"
|
||||||
|
request.Container = &requestContainer
|
||||||
|
|
||||||
|
resp, _err := pcm_pod_ali.UpdateContainerGroup(request)
|
||||||
|
println(resp.RequestId)
|
||||||
|
|
||||||
|
return _err
|
||||||
|
}
|
||||||
|
|
||||||
|
func aliDeletePCM() (_err error) {
|
||||||
|
|
||||||
|
request := pcm_pod_ali.CreateDeleteContainerGroupRequest()
|
||||||
|
/****************PCM params******************/
|
||||||
|
request.ProviderId = 3
|
||||||
|
//ali:cn-hangzhou tc:ap-guangzhou hw: cn-east-3
|
||||||
|
request.RegionId = "cn-east-3"
|
||||||
|
request.Namespace = "pcm"
|
||||||
|
request.PcmId = "hw-sdk-hwk8s"
|
||||||
|
/****************PCM params******************/
|
||||||
|
|
||||||
|
resp, _err := pcm_pod_ali.DeleteContainerGroup(request)
|
||||||
|
if _err != nil {
|
||||||
|
return _err
|
||||||
|
}
|
||||||
|
println(resp.RequestId)
|
||||||
|
|
||||||
return _err
|
return _err
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
err := _main(tea.StringSlice(os.Args[1:]))
|
|
||||||
|
err := aliDeletePCM()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,21 +12,30 @@ import (
|
||||||
"k8s.io/client-go/tools/clientcmd/api"
|
"k8s.io/client-go/tools/clientcmd/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
apiVersionPCM = "client.authentication.k8s.io/v1beta1"
|
||||||
|
cciEndpointPCM = "https://cci.cn-east-3.myhuaweicloud.com"
|
||||||
|
iamEndpointPCM = "https://iam.cn-east-3.myhuaweicloud.com"
|
||||||
|
projectNamePCM = "cn-east-3"
|
||||||
|
akPCM = ""
|
||||||
|
skPCM = ""
|
||||||
|
)
|
||||||
|
|
||||||
// NewClient 通过AK/SK认证创建ClientSet
|
// NewClient 通过AK/SK认证创建ClientSet
|
||||||
func NewClient() (*kubernetes.Clientset, error) {
|
func NewClient() (*kubernetes.Clientset, error) {
|
||||||
config, err := clientcmd.BuildConfigFromFlags(cciEndpoint, "")
|
config, err := clientcmd.BuildConfigFromFlags(cciEndpointPCM, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var optionArgs []string
|
var optionArgs []string
|
||||||
optionArgs = append(optionArgs, fmt.Sprintf("--iam-endpoint=%s", iamEndpoint))
|
optionArgs = append(optionArgs, fmt.Sprintf("--iam-endpoint=%s", iamEndpointPCM))
|
||||||
optionArgs = append(optionArgs, fmt.Sprintf("--project-name=%s", projectName))
|
optionArgs = append(optionArgs, fmt.Sprintf("--project-name=%s", projectNamePCM))
|
||||||
optionArgs = append(optionArgs, fmt.Sprintf("--token-only=false"))
|
optionArgs = append(optionArgs, fmt.Sprintf("--token-only=false"))
|
||||||
optionArgs = append(optionArgs, fmt.Sprintf("--ak=%s", ak))
|
optionArgs = append(optionArgs, fmt.Sprintf("--ak=%s", akPCM))
|
||||||
optionArgs = append(optionArgs, fmt.Sprintf("--sk=%s", sk))
|
optionArgs = append(optionArgs, fmt.Sprintf("--sk=%s", skPCM))
|
||||||
config.ExecProvider = &api.ExecConfig{
|
config.ExecProvider = &api.ExecConfig{
|
||||||
Command: "cci-iam-authenticator",
|
Command: "cci-iam-authenticator",
|
||||||
APIVersion: apiVersion,
|
APIVersion: apiVersionPCM,
|
||||||
Args: append([]string{"token"}, optionArgs...),
|
Args: append([]string{"token"}, optionArgs...),
|
||||||
Env: make([]api.ExecEnvVar, 0),
|
Env: make([]api.ExecEnvVar, 0),
|
||||||
}
|
}
|
||||||
|
@ -42,22 +51,22 @@ func CreatePod(client *kubernetes.Clientset) (*corev1.Pod, error) {
|
||||||
Kind: "Pod",
|
Kind: "Pod",
|
||||||
},
|
},
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "hw-sdk-hwk8s01",
|
Name: "hw-sdk-hwk8s02",
|
||||||
Namespace: "pcm",
|
Namespace: "pcm",
|
||||||
Labels: map[string]string{"name": "test_api"},
|
Labels: map[string]string{"name": "test_api"},
|
||||||
},
|
},
|
||||||
Spec: corev1.PodSpec{
|
Spec: corev1.PodSpec{
|
||||||
/****************PCM params******************/
|
/****************PCM params******************/
|
||||||
//0: ali, 1: tencent, 2: huawei,3: k8s
|
//0: ali, 1: tencent, 2: huawei,3: k8s
|
||||||
ProviderId: 0,
|
ProviderId: 3,
|
||||||
//ali:cn-hangzhou tc:ap-guangzhou hw: cn-east-3
|
//ali:cn-hangzhou tc:ap-guangzhou hw: cn-east-3
|
||||||
RegionId: "cn-hangzhou",
|
RegionId: "cn-east-3",
|
||||||
/****************PCM params******************/
|
/****************PCM params******************/
|
||||||
RestartPolicy: corev1.RestartPolicyAlways,
|
RestartPolicy: corev1.RestartPolicyAlways,
|
||||||
Containers: []corev1.Container{
|
Containers: []corev1.Container{
|
||||||
{
|
{
|
||||||
Name: "sdk-hwk8s01-container",
|
Name: "sdk-hwk8s01-container",
|
||||||
Image: "registry-vpc.cn-hangzhou.aliyuncs.com/eci_open/alpine:3.5",
|
Image: "library/nginx:stable-alpine-perl",
|
||||||
Resources: corev1.ResourceRequirements{
|
Resources: corev1.ResourceRequirements{
|
||||||
Limits: map[corev1.ResourceName]resource.Quantity{
|
Limits: map[corev1.ResourceName]resource.Quantity{
|
||||||
corev1.ResourceCPU: resource.MustParse("1000m"),
|
corev1.ResourceCPU: resource.MustParse("1000m"),
|
||||||
|
@ -89,14 +98,15 @@ func ListPod(client *kubernetes.Clientset) (*corev1.PodList, error) {
|
||||||
Spec: corev1.PodSpec{
|
Spec: corev1.PodSpec{
|
||||||
/****************PCM params******************/
|
/****************PCM params******************/
|
||||||
//0: ali, 1: tencent, 2: huawei,3: k8s
|
//0: ali, 1: tencent, 2: huawei,3: k8s
|
||||||
ProviderId: 0,
|
ProviderId: 3,
|
||||||
//ali:cn-hangzhou tc:ap-guangzhou hw: cn-east-3
|
//ali:cn-hangzhou tc:ap-guangzhou hw: cn-east-3
|
||||||
//RegionId: "cn-hangzhou",
|
//RegionId: "cn-east-3",
|
||||||
/****************PCM params******************/
|
/****************PCM params******************/
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
podList, _ := client.CoreV1().Pods("pcm").List(context.TODO(), &pod, metav1.ListOptions{})
|
podList, _ := client.CoreV1().Pods("pcm").List(context.TODO(), &pod, metav1.ListOptions{})
|
||||||
|
println(podList.Items[0].Spec.Containers[0].Name)
|
||||||
return podList, nil
|
return podList, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,26 +118,26 @@ func UpdatePod(client *kubernetes.Clientset) error {
|
||||||
Kind: "Pod",
|
Kind: "Pod",
|
||||||
},
|
},
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "hw-sdk-test002",
|
Name: "hw-sdk-hwk8s01",
|
||||||
Namespace: "pcm",
|
Namespace: "pcm",
|
||||||
UID: "eci-bp123wba1qv9xymntd24",
|
UID: "hw-sdk-hwk8s01",
|
||||||
Labels: map[string]string{"name": "test_api222"},
|
Labels: map[string]string{"name": "test_api222"},
|
||||||
},
|
},
|
||||||
Spec: corev1.PodSpec{
|
Spec: corev1.PodSpec{
|
||||||
/****************PCM params******************/
|
/****************PCM params******************/
|
||||||
//0: ali, 1: tencent, 2: huawei,3: k8s
|
//0: ali, 1: tencent, 2: huawei,3: k8s
|
||||||
ProviderId: 0,
|
ProviderId: 2,
|
||||||
//ali:cn-hangzhou tc:ap-guangzhou hw: cn-east-3
|
//ali:cn-hangzhou tc:ap-guangzhou hw: cn-east-3
|
||||||
RegionId: "cn-hangzhou",
|
RegionId: "cn-east-3",
|
||||||
/****************PCM params******************/
|
/****************PCM params******************/
|
||||||
RestartPolicy: corev1.RestartPolicyAlways,
|
RestartPolicy: corev1.RestartPolicyNever,
|
||||||
Containers: []corev1.Container{
|
Containers: []corev1.Container{
|
||||||
{
|
{
|
||||||
Name: "pcm-sdk-huawei-contai",
|
Name: "pcm-sdk-huawei-conta22i",
|
||||||
Image: "nginx:latest",
|
Image: "nginx:latest",
|
||||||
Resources: corev1.ResourceRequirements{
|
Resources: corev1.ResourceRequirements{
|
||||||
Limits: map[corev1.ResourceName]resource.Quantity{
|
Limits: map[corev1.ResourceName]resource.Quantity{
|
||||||
corev1.ResourceCPU: resource.MustParse("2000m"),
|
corev1.ResourceCPU: resource.MustParse("500m"),
|
||||||
corev1.ResourceMemory: resource.MustParse("1Gi"),
|
corev1.ResourceMemory: resource.MustParse("1Gi"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -147,37 +157,17 @@ func UpdatePod(client *kubernetes.Clientset) error {
|
||||||
// DeletePod 删除Pod
|
// DeletePod 删除Pod
|
||||||
func DeletePod(client *kubernetes.Clientset) error {
|
func DeletePod(client *kubernetes.Clientset) error {
|
||||||
//多出5个参数 namespace providerId regionName accountName pcmId
|
//多出5个参数 namespace providerId regionName accountName pcmId
|
||||||
return client.CoreV1().Pods("pcm").Delete(context.TODO(), "pcm", 0, "cn-hangzhou",
|
return client.CoreV1().Pods("pcm").Delete(context.TODO(), "pcm", 3, "cn-east-3",
|
||||||
"", "eci-bp123wba1qv9xymntd24", metav1.DeleteOptions{})
|
"", "hw-sdk-hwk8s02", metav1.DeleteOptions{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
cs, _ := NewClient()
|
cs, _ := NewClient()
|
||||||
|
|
||||||
fmt.Println("start to create Pod")
|
//CreatePod(cs)
|
||||||
_, err := CreatePod(cs)
|
//ListPod(cs)
|
||||||
if err != nil {
|
//UpdatePod(cs)
|
||||||
return
|
DeletePod(cs)
|
||||||
}
|
|
||||||
fmt.Println("Pod created")
|
|
||||||
fmt.Println("start to get Pod details")
|
|
||||||
_, err = ListPod(cs)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Println("Pod details got")
|
|
||||||
fmt.Println("start to update Pod")
|
|
||||||
err = UpdatePod(cs)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Println("Pod updated")
|
|
||||||
fmt.Println("start to delete Pod")
|
|
||||||
err = DeletePod(cs)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Println("Pod deleted")
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
1
go.mod
1
go.mod
|
@ -5,7 +5,6 @@ go 1.17
|
||||||
require (
|
require (
|
||||||
github.com/alibabacloud-go/darabonba-openapi v0.1.4
|
github.com/alibabacloud-go/darabonba-openapi v0.1.4
|
||||||
github.com/alibabacloud-go/darabonba-string v1.0.0
|
github.com/alibabacloud-go/darabonba-string v1.0.0
|
||||||
github.com/alibabacloud-go/eci-20180808/v2 v2.0.2
|
|
||||||
github.com/alibabacloud-go/ecs-20140526/v2 v2.1.0
|
github.com/alibabacloud-go/ecs-20140526/v2 v2.1.0
|
||||||
github.com/alibabacloud-go/tea v1.1.15
|
github.com/alibabacloud-go/tea v1.1.15
|
||||||
github.com/alibabacloud-go/tea-utils v1.3.9
|
github.com/alibabacloud-go/tea-utils v1.3.9
|
||||||
|
|
Loading…
Reference in New Issue