Merge branch 'master' into protobuf
# Conflicts: # adaptor/container_api_adaptor/common/main.go # adaptor/container_api_adaptor/huawei/pkg/auth/aksk/aksk.go # adaptor/pod_adaptor/server/pod/list.go # adaptor/pod_adaptor/service/poder/poder.go # common/server/server.go # common/server/server_pod.go # idl/pbpod/pod.proto # lan_trans/idl/pbpod/pod.pb.go # lan_trans/idl/pbpod/pod.pb.gw.go # lan_trans/idl/pbpod/pod_grpc.pb.go # lan_trans/openapiv2/idl/demo/demo.swagger.json # lan_trans/openapiv2/idl/pbecs/ecs.swagger.json # lan_trans/openapiv2/idl/pbpod/pod.swagger.json # lan_trans/openapiv2/idl/pbtenant/tenant.swagger.json # main.go
This commit is contained in:
commit
55d71ebab1
|
@ -1,26 +0,0 @@
|
|||
[pod_create_conf]
|
||||
region_id=cn-hangzhou
|
||||
#容器实例名称(pod名) 对应阿里 ContainerGroupName(阿里必需)
|
||||
container_group_name=pcm-test-ali-pod
|
||||
#镜像地址 对应阿里 Container.Image(阿里必需)
|
||||
container_image=registry-vpc.cn-hangzhou.aliyuncs.com/eci_open/nginx
|
||||
#容器名称 对应阿里 Container.Name(阿里必需)
|
||||
container_name=pcm-test-ali-container
|
||||
|
||||
[pod_delete_conf]
|
||||
# 地域id
|
||||
region_id=cn-hangzhou
|
||||
#容器实例ID
|
||||
container_group_id=eci-bp1c3eqfq98nz2kbiooo
|
||||
|
||||
[pod_list_conf]
|
||||
# 地域id
|
||||
region_id=cn-hangzhou
|
||||
|
||||
[pod_update_conf]
|
||||
# 地域id
|
||||
region_id=cn-hangzhou
|
||||
#容器实例ID
|
||||
container_group_id=eci-bp1c3eqfq98nz2kbiooo
|
||||
#可选 这里用重启策略做更新测试
|
||||
restart_policy=Never
|
|
@ -1,121 +0,0 @@
|
|||
package eci
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/aliyun/alibaba-cloud-sdk-go/services/eci"
|
||||
"gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/common/auth/aksk"
|
||||
"gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/common/config"
|
||||
)
|
||||
|
||||
// CreateContainerGroup 创建
|
||||
func CreateContainerGroup(cloudStack string, akskPath string, configPath string) string {
|
||||
|
||||
var client *eci.Client
|
||||
configCommon, _ := config.PCMconfig(configPath)
|
||||
configAksk, _ := aksk.AkskConfig(cloudStack, akskPath)
|
||||
|
||||
//创建客户端
|
||||
client, _ = eci.NewClientWithAccessKey(configCommon.RegionId, configAksk.AccessKey, configAksk.SecretKey)
|
||||
// 生成创建请求
|
||||
createContainerRequest := eci.CreateCreateContainerGroupRequest()
|
||||
// 必需参数
|
||||
//区域ID
|
||||
createContainerRequest.RegionId = configCommon.RegionId
|
||||
//POD名称
|
||||
createContainerRequest.ContainerGroupName = configCommon.ContainerGroupName
|
||||
//容器名称和镜像名称
|
||||
createContainerRequestContainer := make([]eci.CreateContainerGroupContainer, 1)
|
||||
createContainerRequestContainer[0].Image = configCommon.ContainerImage
|
||||
createContainerRequestContainer[0].Name = configCommon.ContainerName
|
||||
createContainerRequest.Container = &createContainerRequestContainer
|
||||
|
||||
client.GetConfig().MaxRetryTime = 0
|
||||
createContainerGroupResponse, err := client.CreateContainerGroup(createContainerRequest)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
containerGroupId := createContainerGroupResponse.ContainerGroupId
|
||||
fmt.Println("Alibaba ContainerGroup created:", containerGroupId)
|
||||
return containerGroupId
|
||||
}
|
||||
|
||||
// DescribeContainerGroup 查询Pod
|
||||
func DescribeContainerGroup(cloudStack string, akskPath string, configPath string) eci.DescribeContainerGroupsContainerGroup0 {
|
||||
var client *eci.Client
|
||||
|
||||
configCommon, _ := config.PCMconfig(configPath)
|
||||
configAksk, _ := aksk.AkskConfig(cloudStack, akskPath)
|
||||
client, _ = eci.NewClientWithAccessKey(configCommon.RegionId, configAksk.AccessKey, configAksk.SecretKey)
|
||||
|
||||
// 生成查询请求
|
||||
describeContainerGroupsRequest := eci.CreateDescribeContainerGroupsRequest()
|
||||
describeContainerGroupsRequest.RegionId = configCommon.RegionIdList
|
||||
describeContainerGroupsResponse, err := client.DescribeContainerGroups(describeContainerGroupsRequest)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
describeContainerGroupNumber := len(describeContainerGroupsResponse.ContainerGroups)
|
||||
|
||||
//当前区域没有Pod情形的处理
|
||||
if describeContainerGroupsResponse.TotalCount != 1 && describeContainerGroupNumber != 1 {
|
||||
fmt.Println("Invalid ContainerGroups count", describeContainerGroupsResponse.TotalCount, describeContainerGroupNumber)
|
||||
panic("Invalid ContainerGroups count")
|
||||
}
|
||||
|
||||
fmt.Println("Alibaba ContainerGroup Name:", describeContainerGroupsResponse.ContainerGroups[0].ContainerGroupName, "\n",
|
||||
"ContainerGroup Id:", describeContainerGroupsResponse.ContainerGroups[0].ContainerGroupId)
|
||||
|
||||
return describeContainerGroupsResponse.ContainerGroups[0]
|
||||
}
|
||||
|
||||
// UpdateContainerGroup 更新Pod
|
||||
func UpdateContainerGroup(cloudStack string, akskPath string, configPath string) string {
|
||||
var client *eci.Client
|
||||
|
||||
configCommon, _ := config.PCMconfig(configPath)
|
||||
configAksk, _ := aksk.AkskConfig(cloudStack, akskPath)
|
||||
|
||||
client, _ = eci.NewClientWithAccessKey(configCommon.RegionId, configAksk.AccessKey, configAksk.SecretKey)
|
||||
|
||||
//生成更新请求
|
||||
updateContainerGroupRequest := eci.CreateUpdateContainerGroupRequest()
|
||||
updateContainerGroupRequest.RegionId = configCommon.RegionIdUpdate
|
||||
updateContainerGroupRequest.ContainerGroupId = configCommon.ContainerGroupIdUpdate
|
||||
|
||||
//容器实体内容,这里测试可以修改配置文件中的重启策略
|
||||
updateContainerRequestContainer := make([]eci.UpdateContainerGroupContainer, 1)
|
||||
updateContainerRequestContainer[0].Image = configCommon.ContainerImage
|
||||
updateContainerRequestContainer[0].Name = configCommon.ContainerName
|
||||
updateContainerGroupRequest.Container = &updateContainerRequestContainer
|
||||
updateContainerGroupRequest.RestartPolicy = configCommon.RestartPolicyUpdate
|
||||
|
||||
updateContainerGroupResponse, err := client.UpdateContainerGroup(updateContainerGroupRequest)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
requestId := updateContainerGroupResponse.RequestId
|
||||
fmt.Println("Alibaba ContainerGroup: ", configCommon.ContainerGroupIdUpdate, " Updated with request ID:", requestId)
|
||||
return requestId
|
||||
}
|
||||
|
||||
// DeleteContainerGroup 删除Pod
|
||||
func DeleteContainerGroup(cloudStack string, akskPath string, configPath string) string {
|
||||
var client *eci.Client
|
||||
configCommon, _ := config.PCMconfig(configPath)
|
||||
configAksk, _ := aksk.AkskConfig(cloudStack, akskPath)
|
||||
client, _ = eci.NewClientWithAccessKey(configCommon.RegionId, configAksk.AccessKey, configAksk.SecretKey)
|
||||
|
||||
//生成删除请求
|
||||
deleteContainerGroupRequest := eci.CreateDeleteContainerGroupRequest()
|
||||
deleteContainerGroupRequest.RegionId = configCommon.RegionIdDelete
|
||||
deleteContainerGroupRequest.ContainerGroupId = configCommon.ContainerGroupIdDelete
|
||||
|
||||
deleteContainerGroupResponse, err := client.DeleteContainerGroup(deleteContainerGroupRequest)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
requestId := deleteContainerGroupResponse.RequestId
|
||||
fmt.Println("Alibaba ContainerGroup: ", configCommon.ContainerGroupIdUpdate, " Deleted with request ID:", requestId)
|
||||
|
||||
return requestId
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/alibaba/eci"
|
||||
cciAksk "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/auth/aksk"
|
||||
cci "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/resources/pod"
|
||||
"gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/tencent/eks"
|
||||
)
|
||||
|
||||
//CreatePod 创建Pod通用方法
|
||||
func CreatePod(cloudStack string, akskPath string, configPath string) {
|
||||
switch cloudStack {
|
||||
|
||||
case "alibaba":
|
||||
eci.CreateContainerGroup(cloudStack, akskPath, configPath)
|
||||
|
||||
case "huawei":
|
||||
cs, err := cciAksk.NewClient(cloudStack, akskPath, configPath)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_, err = cci.CreatePod(cs, configPath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
case "tencent":
|
||||
eks.CreateEksInstance(cloudStack, akskPath, configPath)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// DeletePod 删除Pod 通用方法
|
||||
func DeletePod(cloudStack string, akskPath string, configPath string) {
|
||||
|
||||
switch cloudStack {
|
||||
|
||||
case "alibaba":
|
||||
eci.DeleteContainerGroup(cloudStack, akskPath, configPath)
|
||||
|
||||
case "huawei":
|
||||
cs, err := cciAksk.NewClient(cloudStack, akskPath, configPath)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = cci.DeletePod(cs, configPath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
case "tencent":
|
||||
eks.DeleteEksInstance(cloudStack, akskPath, configPath)
|
||||
}
|
||||
}
|
||||
|
||||
//UpdatePod 更新Pod通用方法
|
||||
func UpdatePod(cloudStack string, akskPath string, configPath string) {
|
||||
|
||||
switch cloudStack {
|
||||
|
||||
case "alibaba":
|
||||
eci.UpdateContainerGroup(cloudStack, akskPath, configPath)
|
||||
|
||||
case "huawei":
|
||||
cs, err := cciAksk.NewClient(cloudStack, akskPath, configPath)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_, err = cci.UpdatePod(cs, configPath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
case "tencent":
|
||||
eks.UpdateEksInstance(cloudStack, akskPath, configPath)
|
||||
}
|
||||
}
|
||||
|
||||
//ListPod 查询Pod通用方法
|
||||
func ListPod(cloudStack string, akskPath string, configPath string) {
|
||||
|
||||
switch cloudStack {
|
||||
|
||||
case "alibaba":
|
||||
eci.DescribeContainerGroup(cloudStack, akskPath, configPath)
|
||||
|
||||
case "huawei":
|
||||
cs, err := cciAksk.NewClient(cloudStack, akskPath, configPath)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_, err = cci.ListPod(cs, configPath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
case "tencent":
|
||||
eks.ListEksInstance(cloudStack, akskPath, configPath)
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package aksk
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Unknwon/goconfig"
|
||||
"os"
|
||||
)
|
||||
|
||||
type AkskContainerConfig struct {
|
||||
AccessKey string
|
||||
SecretKey string
|
||||
}
|
||||
|
||||
func AkskConfig(cloudStack string, akskPath string) (AkskContainerConfig, error) {
|
||||
var cfg *goconfig.ConfigFile
|
||||
config, err := goconfig.LoadConfigFile(akskPath)
|
||||
if err != nil {
|
||||
fmt.Println("get config file error:", err.Error())
|
||||
os.Exit(-1)
|
||||
}
|
||||
cfg = config
|
||||
var accessKey string
|
||||
var secretKey string
|
||||
switch cloudStack {
|
||||
|
||||
case "alibaba":
|
||||
accessKey, _ = cfg.GetValue(cloudStack, "access_key")
|
||||
secretKey, _ = cfg.GetValue(cloudStack, "secret_key")
|
||||
|
||||
case "huawei":
|
||||
accessKey, _ = cfg.GetValue(cloudStack, "access_key")
|
||||
secretKey, _ = cfg.GetValue(cloudStack, "secret_key")
|
||||
case "tencent":
|
||||
accessKey, _ = cfg.GetValue(cloudStack, "access_key")
|
||||
secretKey, _ = cfg.GetValue(cloudStack, "secret_key")
|
||||
}
|
||||
|
||||
var akskConfig = AkskContainerConfig{
|
||||
AccessKey: accessKey,
|
||||
SecretKey: secretKey,
|
||||
}
|
||||
return akskConfig, nil
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
#阿里
|
||||
[alibaba]
|
||||
access_key =
|
||||
secret_key =
|
||||
|
||||
#华为
|
||||
[huawei]
|
||||
access_key =
|
||||
secret_key =
|
||||
|
||||
#腾讯
|
||||
[tencent]
|
||||
access_key =
|
||||
secret_key =
|
|
@ -1,133 +0,0 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Unknwon/goconfig"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type PCMContainerConfig struct {
|
||||
RegionId string
|
||||
ContainerGroupName string
|
||||
ContainerImage string
|
||||
ContainerName string
|
||||
CpuPod string
|
||||
MemoryPod string
|
||||
CpuContainer string
|
||||
MemoryContainer string
|
||||
CpuPodFloat float64
|
||||
MemoryPodFloat float64
|
||||
CpuContainerFloat float64
|
||||
MemoryContainerFloat float64
|
||||
NameSpace string
|
||||
SecurityGroupId string
|
||||
SubnetId string
|
||||
VpcId string
|
||||
RegionIdDelete string
|
||||
ContainerGroupIdDelete string
|
||||
RegionIdList string
|
||||
NamespaceUpdate string
|
||||
RegionIdUpdate string
|
||||
ContainerImageUpdate string
|
||||
ContainerNameUpdate string
|
||||
CpuPodUpdate string
|
||||
MemoryPodUpdate string
|
||||
ContainerGroupNameUpdate string
|
||||
ContainerGroupIdUpdate string
|
||||
RestartPolicyUpdate string
|
||||
NamespaceDelete string
|
||||
ContainerGroupNameDelete string
|
||||
}
|
||||
|
||||
func PCMconfig(configPath string) (PCMContainerConfig, error) {
|
||||
|
||||
//加载配置文件
|
||||
var cfg *goconfig.ConfigFile
|
||||
config, err := goconfig.LoadConfigFile(configPath)
|
||||
if err != nil {
|
||||
fmt.Println("get config file error:", err.Error())
|
||||
os.Exit(-1)
|
||||
}
|
||||
cfg = config
|
||||
|
||||
//[创建]通用创建必需信息
|
||||
regionId, _ := cfg.GetValue("pod_create_conf", "region_id")
|
||||
containerGroupName, _ := cfg.GetValue("pod_create_conf", "container_group_name")
|
||||
containerImage, _ := cfg.GetValue("pod_create_conf", "container_image")
|
||||
containerName, _ := cfg.GetValue("pod_create_conf", "container_name")
|
||||
|
||||
//[创建]阿里创建必需(unique)
|
||||
|
||||
//[创建]腾讯创建必需(unique)
|
||||
cpuPod, _ := cfg.GetValue("pod_create_conf", "cpu_pod")
|
||||
memoryPod, _ := cfg.GetValue("pod_create_conf", "memory_pod")
|
||||
cpuPodFloat, _ := strconv.ParseFloat(cpuPod, 64)
|
||||
memoryPodFloat, _ := strconv.ParseFloat(memoryPod, 64)
|
||||
securityGroupId, _ := cfg.GetValue("pod_create_conf", "security_group_id")
|
||||
subnetId, _ := cfg.GetValue("pod_create_conf", "subnet_id")
|
||||
vpcId, _ := cfg.GetValue("pod_create_conf", "vpc_id")
|
||||
|
||||
//[创建]华为创建必需(unique)
|
||||
nameSpace, _ := cfg.GetValue("pod_create_conf", "namespace")
|
||||
|
||||
//[创建]非必需参数
|
||||
cpuContainer, _ := cfg.GetValue("pod_create_conf", "cpu_container")
|
||||
memoryContainer, _ := cfg.GetValue("pod_create_conf", "memory_container")
|
||||
cpuContainerFloat, _ := strconv.ParseFloat(cpuContainer, 64)
|
||||
memoryContainerFloat, _ := strconv.ParseFloat(memoryContainer, 64)
|
||||
|
||||
//[删除]通用删除配置信息
|
||||
regionIdDelete, _ := cfg.GetValue("pod_delete_conf", "region_id")
|
||||
containerGroupIdDelete, _ := cfg.GetValue("pod_delete_conf", "container_group_id")
|
||||
nameSpaceDelete, _ := cfg.GetValue("pod_delete_conf", "namespace")
|
||||
containerGroupNameDelete, _ := cfg.GetValue("pod_delete_conf", "container_group_name")
|
||||
|
||||
//[查询]通用查询配置信息
|
||||
regionIdList, _ := cfg.GetValue("pod_list_conf", "region_id")
|
||||
|
||||
//[更新]通用更新配置信息
|
||||
regionIdUpdate, _ := cfg.GetValue("pod_update_conf", "region_id")
|
||||
namespaceUpdate, _ := cfg.GetValue("pod_update_conf", "namespace")
|
||||
containerGroupIdUpdate, _ := cfg.GetValue("pod_update_conf", "container_group_id")
|
||||
restartPolicyUpdate, _ := cfg.GetValue("pod_update_conf", "restart_policy")
|
||||
ContainerNameUpdate, _ := cfg.GetValue("pod_update_conf", "container_name")
|
||||
CpuPodUpdate, _ := cfg.GetValue("pod_update_conf", "cpu_pod")
|
||||
MemoryPodUpdate, _ := cfg.GetValue("pod_update_conf", "memory_pod")
|
||||
ContainerGroupNameUpdate, _ := cfg.GetValue("pod_update_conf", "container_group_name")
|
||||
|
||||
var configCommon = PCMContainerConfig{
|
||||
RegionId: regionId,
|
||||
ContainerGroupName: containerGroupName,
|
||||
ContainerImage: containerImage,
|
||||
ContainerName: containerName,
|
||||
CpuPod: cpuPod,
|
||||
MemoryPod: memoryPod,
|
||||
CpuContainer: cpuContainer,
|
||||
MemoryContainer: memoryContainer,
|
||||
CpuPodFloat: cpuPodFloat,
|
||||
MemoryPodFloat: memoryPodFloat,
|
||||
CpuContainerFloat: cpuContainerFloat,
|
||||
MemoryContainerFloat: memoryContainerFloat,
|
||||
NameSpace: nameSpace,
|
||||
SecurityGroupId: securityGroupId,
|
||||
SubnetId: subnetId,
|
||||
VpcId: vpcId,
|
||||
RegionIdDelete: regionIdDelete,
|
||||
ContainerGroupIdDelete: containerGroupIdDelete,
|
||||
RegionIdList: regionIdList,
|
||||
RegionIdUpdate: regionIdUpdate,
|
||||
NamespaceUpdate: namespaceUpdate,
|
||||
ContainerGroupIdUpdate: containerGroupIdUpdate,
|
||||
RestartPolicyUpdate: restartPolicyUpdate,
|
||||
ContainerImageUpdate: containerName,
|
||||
ContainerNameUpdate: ContainerNameUpdate,
|
||||
CpuPodUpdate: CpuPodUpdate,
|
||||
MemoryPodUpdate: MemoryPodUpdate,
|
||||
ContainerGroupNameUpdate: ContainerGroupNameUpdate,
|
||||
NamespaceDelete: nameSpaceDelete,
|
||||
ContainerGroupNameDelete: containerGroupNameDelete,
|
||||
}
|
||||
|
||||
return configCommon, nil
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
[container_conf]
|
||||
[pod_create_conf]
|
||||
#测试账号ak
|
||||
access_key =
|
||||
secret_key =
|
||||
#region
|
||||
region_id=
|
||||
#容器实例名称(pod名)
|
||||
container_group_name=
|
||||
#镜像地址
|
||||
container_image=
|
||||
#容器名称
|
||||
container_name=
|
||||
#namespace 华为CCI基于K8S namespace进行管理,需要单独提供namespace (华为必需)
|
||||
namespace=
|
||||
#Pod拥有核数 对应腾讯 Cpu(腾讯必需)
|
||||
cpu_pod=1
|
||||
#Pod拥有内存大小 对应腾讯 Memory(腾讯必需)
|
||||
memory_pod=2
|
||||
#安全组ID 对应腾讯 SecurityGroupIds(腾讯必需)
|
||||
security_group_id=
|
||||
#子网ID 对应腾讯 SubnetId(腾讯必需)
|
||||
subnet_id=
|
||||
#VPC ID 对应腾讯 VpcId(腾讯必需)
|
||||
vpc_id=
|
||||
##考虑多个函数分成不同的配置组
|
||||
##用户可以在请求中指定任务在各厂商调度比例
|
||||
##地域、厂商、用户AKSK等信息通过独立的配置文件进行导入
|
||||
|
||||
[pod_create_conf]
|
||||
#可选项,框架可以不必过于细节
|
||||
ali_count=10000
|
||||
huawei_count=10000
|
||||
tencent_count=20000
|
||||
|
||||
hangzhou_count=20000
|
||||
shanghai_count=20000
|
||||
|
||||
|
||||
[pod_delete_conf]
|
||||
[pod_update_conf]
|
||||
[pod_list_conf]
|
||||
|
||||
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
package main
|
||||
|
||||
import "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/common/api"
|
||||
|
||||
func main() {
|
||||
|
||||
aliConfigPath := "adaptor/container_api_adaptor/alibaba/eci/config_eci.conf"
|
||||
huaweiConfigPath := "adaptor/container_api_adaptor/huawei/cci/config_cci.conf"
|
||||
tencentConfigPath := "adaptor/container_api_adaptor/tencent/eks/config_eks.conf"
|
||||
akskPath := "adaptor/container_api_adaptor/common/auth/aksk/aksk.conf"
|
||||
println(aliConfigPath)
|
||||
println(huaweiConfigPath)
|
||||
println(tencentConfigPath)
|
||||
println(akskPath)
|
||||
|
||||
//api.CreatePod("alibaba", akskPath, aliConfigPath)
|
||||
//api.ListPod("alibaba", akskPath, aliConfigPath)
|
||||
//api.UpdatePod("alibaba", akskPath, aliConfigPath)
|
||||
//api.DeletePod("alibaba", akskPath, aliConfigPath)
|
||||
|
||||
//api.CreatePod("huawei", akskPath, huaweiConfigPath)
|
||||
api.ListPod("huawei", akskPath, huaweiConfigPath)
|
||||
//api.UpdatePod("huawei", akskPath, huaweiConfigPath)
|
||||
//api.DeletePod("huawei", akskPath, huaweiConfigPath)
|
||||
|
||||
//api.CreatePod("tencent", akskPath, tencentConfigPath)
|
||||
//api.ListPod("tencent", akskPath, tencentConfigPath)
|
||||
//api.UpdatePod("tencent", akskPath, tencentConfigPath)
|
||||
//api.DeletePod("tencent", akskPath, tencentConfigPath)
|
||||
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
[pod_create_conf]
|
||||
#region 对应华为 Region (华为创建Namespace必需)
|
||||
region_id=cn-north-4
|
||||
#namespace 华为CCI基于K8S namespace进行管理,需要单独提供namespace 对应Pod.ObjectMeta.Namespace (华为必需)
|
||||
namespace=test-k8s-client-namespace1
|
||||
#容器实例名称(pod名) 对应华为 Pod.ObjectMeta.Name (华为必需)
|
||||
container_group_name=pcm-test-huawei-pod
|
||||
#镜像地址 对应华为 Pod.PodSpec.Containers.Container.Image (华为必需)
|
||||
container_image=library/nginx:stable-alpine-perl
|
||||
#容器名称 对应华为 Pod.PodSpec.Containers.Container.Name (华为必需)
|
||||
container_name=pcm-test-huawei-container
|
||||
#Pod拥有核数 对应华为 Pod.PodSpec.Containers.Container.Resources.Limits.ResourceCPU (华为必需)
|
||||
cpu_pod=500m
|
||||
#Pod拥有内存大小 对应华为 Pod.PodSpec.Containers.Container.Resources.Limits.ResourceMemory (华为必需)
|
||||
memory_pod=1024Mi
|
||||
|
||||
[pod_delete_conf]
|
||||
# 地域id
|
||||
namespace=test-k8s-client-namespace1
|
||||
#容器实例名称(pod名) 对应华为 Pod.ObjectMeta.Name (华为必需)
|
||||
container_group_name=pcm-test-huawei-pod
|
||||
|
||||
[pod_list_conf]
|
||||
# 地域id
|
||||
region_id=cn-hangzhou
|
||||
|
||||
[pod_update_conf]
|
||||
#容器实例名称(pod名) 对应华为 Pod.ObjectMeta.Name (华为必需)
|
||||
container_group_name=pcm-test-huawei-pod
|
||||
#镜像地址 对应华为 Pod.PodSpec.Containers.Container.Image (华为必需)
|
||||
container_image=library/nginx:stable-alpine-perl
|
||||
#容器名称 对应华为 Pod.PodSpec.Containers.Container.Name (华为必需)
|
||||
container_name=pcm-test-huawei-container-new
|
||||
#Pod拥有核数 对应华为 Pod.PodSpec.Containers.Container.Resources.Limits.ResourceCPU (华为必需)
|
||||
cpu_pod=500m
|
||||
#Pod拥有内存大小 对应华为 Pod.PodSpec.Containers.Container.Resources.Limits.ResourceMemory (华为必需)
|
||||
memory_pod=2048Mi
|
||||
namespace=test-k8s-client-namespace1
|
||||
restart_policy=Always
|
|
@ -1,4 +0,0 @@
|
|||
// +k8s:deepcopy-gen=package
|
||||
// +groupName=networking.cci.io
|
||||
// +groupGoName=NetworkingCCI
|
||||
package v1beta1
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
// GroupName is the group name use in this package
|
||||
const GroupName = "networking.cci.io"
|
||||
|
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"}
|
||||
|
||||
// Resource takes an unqualified resource and returns a Group qualified GroupResource
|
||||
func Resource(resource string) schema.GroupResource {
|
||||
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
||||
}
|
||||
|
||||
var (
|
||||
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
|
||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||
localSchemeBuilder = &SchemeBuilder
|
||||
AddToScheme = localSchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
// Adds the list of known types to the given scheme.
|
||||
func addKnownTypes(scheme *runtime.Scheme) error {
|
||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||
&Network{},
|
||||
&NetworkList{},
|
||||
)
|
||||
// Add the watch version that applies
|
||||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
return nil
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2017 OpenStack Foundation.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// NetworkList is a list of network resource in container.
|
||||
type NetworkList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
// Standard list metadata.
|
||||
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
|
||||
// +optional
|
||||
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
||||
Items []Network `json:"items" protobuf:"bytes,2,rep,name=items"`
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// Network is a network resource in container.
|
||||
type Network struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
// +optional
|
||||
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
||||
// Spec defines the attributes on a network
|
||||
// +optional
|
||||
Spec NetworkSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
|
||||
// Status describes the network status
|
||||
// +optional
|
||||
Status NetworkStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
|
||||
}
|
||||
|
||||
// NetworkSpec describes the attributes on a network resource.
|
||||
type NetworkSpec struct {
|
||||
// network type
|
||||
NetworkType string `json:"networkType,omitempty" protobuf:"bytes,5,opt,name=networkType"`
|
||||
// ID of the VPC to attach
|
||||
AttachedVPC string `json:"attachedVPC,omitempty" protobuf:"bytes,4,opt,name=attachedVPC"`
|
||||
// network ID
|
||||
NetworkID string `json:"networkID,omitempty" protobuf:"bytes,7,opt,name=networkID"`
|
||||
// Subnet ID
|
||||
SubnetID string `json:"subnetID,omitempty" protobuf:"bytes,8,opt,name=subnetID"`
|
||||
// available zone
|
||||
AvailableZone string `json:"availableZone,omitempty" protobuf:"bytes,9,opt,name=availableZone"`
|
||||
// The CIDR of the network
|
||||
CIDR string `json:"cidr,omitempty" protobuf:"bytes,3,opt,name=cidr"`
|
||||
}
|
||||
|
||||
// NetworkStatus describes the status of a network
|
||||
type NetworkStatus struct {
|
||||
// State describes the network state
|
||||
// +optional
|
||||
State string `json:"state" protobuf:"bytes,1,opt,name=state"`
|
||||
// Message describes why network is in current state
|
||||
// +optional
|
||||
Message string `json:"message,omitempty" protobuf:"bytes,2,opt,name=message"`
|
||||
}
|
||||
|
||||
const (
|
||||
// NetworkInitializing means the network is initializing
|
||||
NetworkInitializing = "Initializing"
|
||||
// NetworkPending means the network is processing
|
||||
NetworkPending = "Pending"
|
||||
// NetworkActive means the network is available
|
||||
NetworkActive = "Active"
|
||||
// NetworkFailed means the network is not available
|
||||
NetworkFailed = "Failed"
|
||||
// NetworkTerminating means the network is undergoing graceful termination
|
||||
NetworkTerminating = "Terminating"
|
||||
)
|
|
@ -1,119 +0,0 @@
|
|||
//go:build !ignore_autogenerated
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by deepcopy-gen. DO NOT EDIT.
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Network) DeepCopyInto(out *Network) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
out.Spec = in.Spec
|
||||
out.Status = in.Status
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Network.
|
||||
func (in *Network) DeepCopy() *Network {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Network)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *Network) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *NetworkList) DeepCopyInto(out *NetworkList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]Network, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkList.
|
||||
func (in *NetworkList) DeepCopy() *NetworkList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(NetworkList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *NetworkList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *NetworkSpec) DeepCopyInto(out *NetworkSpec) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkSpec.
|
||||
func (in *NetworkSpec) DeepCopy() *NetworkSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(NetworkSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *NetworkStatus) DeepCopyInto(out *NetworkStatus) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkStatus.
|
||||
func (in *NetworkStatus) DeepCopy() *NetworkStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(NetworkStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
package aksk
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/common/auth/aksk"
|
||||
"gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/common/config"
|
||||
clientset "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
"k8s.io/client-go/tools/clientcmd/api"
|
||||
)
|
||||
|
||||
const (
|
||||
apiVersion = "client.authentication.k8s.io/v1beta1"
|
||||
// 云容器实例 CCI,参考https://developer.huaweicloud.com/endpoint
|
||||
//cciEndpoint = "https://cci.cn-north-4.myhuaweicloud.com"
|
||||
// 统一身份认证服务 IAM,参考https://developer.huaweicloud.com/endpoint
|
||||
iamEndpoint = "https://iam.myhuaweicloud.com"
|
||||
// 地区和终端节点,参考https://developer.huaweicloud.com/endpoint
|
||||
//projectName = "cn-north-4"
|
||||
// 获取AK/SK参考: https://support.huaweicloud.com/devg-cci/cci_kubectl_01.html#cci_kubectl_01__section17023744719
|
||||
|
||||
//ak = "ATQTIWUT9K66VRMMXKVY"
|
||||
//sk = "Wa0aixDVuhZOfDZGWvgIJQBHnyiDlGdgDn1Ai5Yy"
|
||||
|
||||
DomainId = "0a4e7f245680f3040fdfc011720e50a0" //账号ID,可以在我的凭证获取
|
||||
ProjectId = "0a62ffb0d48026c12fbfc011b8d23f0b" //项目ID,可以在我的凭证获取
|
||||
SecurityGroupID = "5157f1d1-fe7d-47a1-beaf-aee027b99755" //安全组ID,可以在安全组控制台获取
|
||||
AvailableZone = "cn-north-4a" //az名称,例如cn-north-1a、cn-north-4a或cn-east-3a
|
||||
VpcID = "0333b519-7903-49e8-908e-ed56216fe921" //虚拟私有云的ID,可在VPC控制台获取
|
||||
Cidr = "10.0.0.0/10" //子网网段,例如192.168.128.0/18
|
||||
NetworkID = "2a14ac3f-07f7-4479-9930-3ea06a888f54" //<子网的网络ID,可在VPC控制台 > 子网中获取>
|
||||
SubnetID = "0dea26d7-2544-424c-b7aa-620b206fce35" //<子网ID,可在VPC控制台 > 子网获取>
|
||||
)
|
||||
|
||||
// NewClient 通过AK/SK认证创建Clientset
|
||||
func NewClient(cloudStack string, akskPath string, configPath string) (*kubernetes.Clientset, error) {
|
||||
|
||||
configAksk, _ := aksk.AkskConfig(cloudStack, akskPath)
|
||||
configCommon, _ := config.PCMconfig(configPath)
|
||||
|
||||
ak := configAksk.AccessKey
|
||||
sk := configAksk.SecretKey
|
||||
regionId := configCommon.RegionId
|
||||
cciEndpoint := "https://cci." + regionId + ".myhuaweicloud.com"
|
||||
|
||||
cciConfig, err := clientcmd.BuildConfigFromFlags(cciEndpoint, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var optionArgs []string
|
||||
optionArgs = append(optionArgs, fmt.Sprintf("--iam-endpoint=%s", iamEndpoint))
|
||||
optionArgs = append(optionArgs, fmt.Sprintf("--project-name=%s", regionId))
|
||||
optionArgs = append(optionArgs, fmt.Sprintf("--ak=%s", ak))
|
||||
optionArgs = append(optionArgs, fmt.Sprintf("--sk=%s", sk))
|
||||
cciConfig.ExecProvider = &api.ExecConfig{
|
||||
Command: "cci-iam-authenticator",
|
||||
APIVersion: apiVersion,
|
||||
Args: append([]string{"token"}, optionArgs...),
|
||||
Env: make([]api.ExecEnvVar, 0),
|
||||
}
|
||||
return kubernetes.NewForConfig(cciConfig)
|
||||
}
|
||||
|
||||
func NewNetworkClient(cloudStack string, akskPath string, configPath string) (*clientset.Clientset, error) {
|
||||
|
||||
configAksk, _ := aksk.AkskConfig(cloudStack, akskPath)
|
||||
configCommon, _ := config.PCMconfig(configPath)
|
||||
|
||||
ak := configAksk.AccessKey
|
||||
sk := configAksk.SecretKey
|
||||
regionId := configCommon.RegionId
|
||||
cciEndpoint := "https://cci." + regionId + ".myhuaweicloud.com"
|
||||
|
||||
configFromFlags, err := clientcmd.BuildConfigFromFlags(cciEndpoint, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var optionArgs []string
|
||||
optionArgs = append(optionArgs, fmt.Sprintf("--iam-endpoint=%s", iamEndpoint))
|
||||
optionArgs = append(optionArgs, fmt.Sprintf("--project-name=%s", regionId))
|
||||
optionArgs = append(optionArgs, fmt.Sprintf("--ak=%s", ak))
|
||||
optionArgs = append(optionArgs, fmt.Sprintf("--sk=%s", sk))
|
||||
configFromFlags.ExecProvider = &api.ExecConfig{
|
||||
Command: "cci-iam-authenticator",
|
||||
APIVersion: apiVersion,
|
||||
Args: append([]string{"token"}, optionArgs...),
|
||||
Env: make([]api.ExecEnvVar, 0),
|
||||
}
|
||||
return clientset.NewForConfig(configFromFlags)
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package kubeconfig
|
||||
|
||||
import (
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
)
|
||||
|
||||
// NewClient 通过kubeconfig配置文件创建Clientset
|
||||
// kubeconfig配置文件需包含认证相关信息,具体请参考《cci-iam-authenticator使用参考》生成kubeconfig配置文件:https://support.huaweicloud.com/devg-cci/cci_kubectl_03.html
|
||||
func NewClient() (*kubernetes.Clientset, error) {
|
||||
config, err := clientcmd.BuildConfigFromFlags("", "/path/to/kubeconfig")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return kubernetes.NewForConfig(config)
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package password
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
"k8s.io/client-go/tools/clientcmd/api"
|
||||
)
|
||||
|
||||
const (
|
||||
apiVersion = "client.authentication.k8s.io/v1beta1"
|
||||
// 云容器实例 CCI,参考https://developer.huaweicloud.com/endpoint
|
||||
cciEndpoint = "<例如华北-北京四: https://cci.cn-north-4.myhuaweicloud.com>"
|
||||
// 统一身份认证服务 IAM,参考https://developer.huaweicloud.com/endpoint
|
||||
iamEndpoint = "<例如华北-北京四: https://iam.cn-north-4.myhuaweicloud.com>"
|
||||
// 地区和终端节点,参考https://developer.huaweicloud.com/endpoint
|
||||
projectName = "<例如华北-北京四: cn-north-4>"
|
||||
userName = "<Your Account User Name>"
|
||||
domainName = "<Your Account Domain Name>"
|
||||
password = "<Your Account Password>"
|
||||
)
|
||||
|
||||
// NewClient 通过username/password创建Clientset
|
||||
func NewClient() (*kubernetes.Clientset, error) {
|
||||
config, err := clientcmd.BuildConfigFromFlags(cciEndpoint, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var optionArgs []string
|
||||
optionArgs = append(optionArgs, fmt.Sprintf("--iam-endpoint=%s", iamEndpoint))
|
||||
optionArgs = append(optionArgs, fmt.Sprintf("--project-name=%s", projectName))
|
||||
optionArgs = append(optionArgs, fmt.Sprintf("--token-only=false"))
|
||||
optionArgs = append(optionArgs, fmt.Sprintf("--domain-name=%s", domainName))
|
||||
optionArgs = append(optionArgs, fmt.Sprintf("--user-name=%s", userName))
|
||||
optionArgs = append(optionArgs, fmt.Sprintf("--password=%s", password))
|
||||
|
||||
config.ExecProvider = &api.ExecConfig{
|
||||
Command: "cci-iam-authenticator",
|
||||
APIVersion: apiVersion,
|
||||
Args: append([]string{"token"}, optionArgs...),
|
||||
Env: make([]api.ExecEnvVar, 0),
|
||||
}
|
||||
return kubernetes.NewForConfig(config)
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
networkingcciv1beta1 "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1"
|
||||
discovery "k8s.io/client-go/discovery"
|
||||
rest "k8s.io/client-go/rest"
|
||||
flowcontrol "k8s.io/client-go/util/flowcontrol"
|
||||
)
|
||||
|
||||
type Interface interface {
|
||||
Discovery() discovery.DiscoveryInterface
|
||||
NetworkingCCIV1beta1() networkingcciv1beta1.NetworkingCCIV1beta1Interface
|
||||
}
|
||||
|
||||
// Clientset contains the clients for groups. Each group has exactly one
|
||||
// version included in a Clientset.
|
||||
type Clientset struct {
|
||||
*discovery.DiscoveryClient
|
||||
networkingCCIV1beta1 *networkingcciv1beta1.NetworkingCCIV1beta1Client
|
||||
}
|
||||
|
||||
// NetworkingCCIV1beta1 retrieves the NetworkingCCIV1beta1Client
|
||||
func (c *Clientset) NetworkingCCIV1beta1() networkingcciv1beta1.NetworkingCCIV1beta1Interface {
|
||||
return c.networkingCCIV1beta1
|
||||
}
|
||||
|
||||
// Discovery retrieves the DiscoveryClient
|
||||
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
return c.DiscoveryClient
|
||||
}
|
||||
|
||||
// NewForConfig creates a new Clientset for the given config.
|
||||
func NewForConfig(c *rest.Config) (*Clientset, error) {
|
||||
configShallowCopy := *c
|
||||
if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
|
||||
configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
|
||||
}
|
||||
var cs Clientset
|
||||
var err error
|
||||
cs.networkingCCIV1beta1, err = networkingcciv1beta1.NewForConfig(&configShallowCopy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &cs, nil
|
||||
}
|
||||
|
||||
// NewForConfigOrDie creates a new Clientset for the given config and
|
||||
// panics if there is an error in the config.
|
||||
func NewForConfigOrDie(c *rest.Config) *Clientset {
|
||||
var cs Clientset
|
||||
cs.networkingCCIV1beta1 = networkingcciv1beta1.NewForConfigOrDie(c)
|
||||
|
||||
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
|
||||
return &cs
|
||||
}
|
||||
|
||||
// New creates a new Clientset for the given RESTClient.
|
||||
func New(c rest.Interface) *Clientset {
|
||||
var cs Clientset
|
||||
cs.networkingCCIV1beta1 = networkingcciv1beta1.New(c)
|
||||
|
||||
cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
|
||||
return &cs
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
// This package has the automatically generated clientset.
|
||||
package v1beta1
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
clientset "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1"
|
||||
networkingcciv1beta1 "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1"
|
||||
fakenetworkingcciv1beta1 "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/fake"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/client-go/discovery"
|
||||
fakediscovery "k8s.io/client-go/discovery/fake"
|
||||
"k8s.io/client-go/testing"
|
||||
)
|
||||
|
||||
// NewSimpleClientset returns a clientset that will respond with the provided objects.
|
||||
// It's backed by a very simple object tracker that processes creates, updates and deletions as-is,
|
||||
// without applying any validations and/or defaults. It shouldn't be considered a replacement
|
||||
// for a real clientset and is mostly useful in simple unit tests.
|
||||
func NewSimpleClientset(objects ...runtime.Object) *Clientset {
|
||||
o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder())
|
||||
for _, obj := range objects {
|
||||
if err := o.Add(obj); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
cs := &Clientset{tracker: o}
|
||||
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
|
||||
cs.AddReactor("*", "*", testing.ObjectReaction(o))
|
||||
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
|
||||
gvr := action.GetResource()
|
||||
ns := action.GetNamespace()
|
||||
watch, err := o.Watch(gvr, ns)
|
||||
if err != nil {
|
||||
return false, nil, err
|
||||
}
|
||||
return true, watch, nil
|
||||
})
|
||||
|
||||
return cs
|
||||
}
|
||||
|
||||
// Clientset implements clientset.Interface. Meant to be embedded into a
|
||||
// struct to get a default implementation. This makes faking out just the method
|
||||
// you want to test easier.
|
||||
type Clientset struct {
|
||||
testing.Fake
|
||||
discovery *fakediscovery.FakeDiscovery
|
||||
tracker testing.ObjectTracker
|
||||
}
|
||||
|
||||
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
|
||||
return c.discovery
|
||||
}
|
||||
|
||||
func (c *Clientset) Tracker() testing.ObjectTracker {
|
||||
return c.tracker
|
||||
}
|
||||
|
||||
var _ clientset.Interface = &Clientset{}
|
||||
|
||||
// NetworkingCCIV1beta1 retrieves the NetworkingCCIV1beta1Client
|
||||
func (c *Clientset) NetworkingCCIV1beta1() networkingcciv1beta1.NetworkingCCIV1beta1Interface {
|
||||
return &fakenetworkingcciv1beta1.FakeNetworkingCCIV1beta1{Fake: &c.Fake}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
// This package has the automatically generated fake clientset.
|
||||
package fake
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
networkingcciv1beta1 "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
)
|
||||
|
||||
var scheme = runtime.NewScheme()
|
||||
var codecs = serializer.NewCodecFactory(scheme)
|
||||
var parameterCodec = runtime.NewParameterCodec(scheme)
|
||||
var localSchemeBuilder = runtime.SchemeBuilder{
|
||||
networkingcciv1beta1.AddToScheme,
|
||||
}
|
||||
|
||||
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
|
||||
// of clientsets, like in:
|
||||
//
|
||||
// import (
|
||||
// "k8s.io/client-go/kubernetes"
|
||||
// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
|
||||
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
|
||||
// )
|
||||
//
|
||||
// kclientset, _ := kubernetes.NewForConfig(c)
|
||||
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
|
||||
//
|
||||
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
|
||||
// correctly.
|
||||
var AddToScheme = localSchemeBuilder.AddToScheme
|
||||
|
||||
func init() {
|
||||
v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"})
|
||||
utilruntime.Must(AddToScheme(scheme))
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
// This package contains the scheme of the automatically generated clientset.
|
||||
package scheme
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package scheme
|
||||
|
||||
import (
|
||||
networkingcciv1beta1 "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
)
|
||||
|
||||
var Scheme = runtime.NewScheme()
|
||||
var Codecs = serializer.NewCodecFactory(Scheme)
|
||||
var ParameterCodec = runtime.NewParameterCodec(Scheme)
|
||||
var localSchemeBuilder = runtime.SchemeBuilder{
|
||||
networkingcciv1beta1.AddToScheme,
|
||||
}
|
||||
|
||||
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
|
||||
// of clientsets, like in:
|
||||
//
|
||||
// import (
|
||||
// "k8s.io/client-go/kubernetes"
|
||||
// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
|
||||
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
|
||||
// )
|
||||
//
|
||||
// kclientset, _ := kubernetes.NewForConfig(c)
|
||||
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
|
||||
//
|
||||
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
|
||||
// correctly.
|
||||
var AddToScheme = localSchemeBuilder.AddToScheme
|
||||
|
||||
func init() {
|
||||
v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"})
|
||||
utilruntime.Must(AddToScheme(Scheme))
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
// This package has the automatically generated typed clients.
|
||||
package v1beta1
|
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
// Package fake has the automatically generated clients.
|
||||
package fake
|
|
@ -1,140 +0,0 @@
|
|||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
v1beta1 "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
labels "k8s.io/apimachinery/pkg/labels"
|
||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
testing "k8s.io/client-go/testing"
|
||||
)
|
||||
|
||||
// FakeNetworks implements NetworkInterface
|
||||
type FakeNetworks struct {
|
||||
Fake *FakeNetworkingCCIV1beta1
|
||||
ns string
|
||||
}
|
||||
|
||||
var networksResource = schema.GroupVersionResource{Group: "networking.cci.io", Version: "v1beta1", Resource: "networks"}
|
||||
|
||||
var networksKind = schema.GroupVersionKind{Group: "networking.cci.io", Version: "v1beta1", Kind: "Network"}
|
||||
|
||||
// Get takes name of the network, and returns the corresponding network object, and an error if there is any.
|
||||
func (c *FakeNetworks) Get(name string, options v1.GetOptions) (result *v1beta1.Network, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewGetAction(networksResource, c.ns, name), &v1beta1.Network{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1beta1.Network), err
|
||||
}
|
||||
|
||||
// List takes label and field selectors, and returns the list of Networks that match those selectors.
|
||||
func (c *FakeNetworks) List(opts v1.ListOptions) (result *v1beta1.NetworkList, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewListAction(networksResource, networksKind, c.ns, opts), &v1beta1.NetworkList{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
label, _, _ := testing.ExtractFromListOptions(opts)
|
||||
if label == nil {
|
||||
label = labels.Everything()
|
||||
}
|
||||
list := &v1beta1.NetworkList{ListMeta: obj.(*v1beta1.NetworkList).ListMeta}
|
||||
for _, item := range obj.(*v1beta1.NetworkList).Items {
|
||||
if label.Matches(labels.Set(item.Labels)) {
|
||||
list.Items = append(list.Items, item)
|
||||
}
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested networks.
|
||||
func (c *FakeNetworks) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
||||
return c.Fake.
|
||||
InvokesWatch(testing.NewWatchAction(networksResource, c.ns, opts))
|
||||
|
||||
}
|
||||
|
||||
// Create takes the representation of a network and creates it. Returns the server's representation of the network, and an error, if there is any.
|
||||
func (c *FakeNetworks) Create(network *v1beta1.Network) (result *v1beta1.Network, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewCreateAction(networksResource, c.ns, network), &v1beta1.Network{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1beta1.Network), err
|
||||
}
|
||||
|
||||
// Update takes the representation of a network and updates it. Returns the server's representation of the network, and an error, if there is any.
|
||||
func (c *FakeNetworks) Update(network *v1beta1.Network) (result *v1beta1.Network, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateAction(networksResource, c.ns, network), &v1beta1.Network{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1beta1.Network), err
|
||||
}
|
||||
|
||||
// UpdateStatus was generated because the type contains a Status member.
|
||||
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
|
||||
func (c *FakeNetworks) UpdateStatus(network *v1beta1.Network) (*v1beta1.Network, error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateSubresourceAction(networksResource, "status", c.ns, network), &v1beta1.Network{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1beta1.Network), err
|
||||
}
|
||||
|
||||
// Delete takes name of the network and deletes it. Returns an error if one occurs.
|
||||
func (c *FakeNetworks) Delete(name string, options *v1.DeleteOptions) error {
|
||||
_, err := c.Fake.
|
||||
Invokes(testing.NewDeleteAction(networksResource, c.ns, name), &v1beta1.Network{})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// DeleteCollection deletes a collection of objects.
|
||||
func (c *FakeNetworks) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
||||
action := testing.NewDeleteCollectionAction(networksResource, c.ns, listOptions)
|
||||
|
||||
_, err := c.Fake.Invokes(action, &v1beta1.NetworkList{})
|
||||
return err
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched network.
|
||||
func (c *FakeNetworks) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Network, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(networksResource, c.ns, name, pt, data, subresources...), &v1beta1.Network{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1beta1.Network), err
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
v1beta1 "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1"
|
||||
rest "k8s.io/client-go/rest"
|
||||
testing "k8s.io/client-go/testing"
|
||||
)
|
||||
|
||||
type FakeNetworkingCCIV1beta1 struct {
|
||||
*testing.Fake
|
||||
}
|
||||
|
||||
func (c *FakeNetworkingCCIV1beta1) Networks(namespace string) v1beta1.NetworkInterface {
|
||||
return &FakeNetworks{c, namespace}
|
||||
}
|
||||
|
||||
// RESTClient returns a RESTClient that is used to communicate
|
||||
// with API server by this client implementation.
|
||||
func (c *FakeNetworkingCCIV1beta1) RESTClient() rest.Interface {
|
||||
var ret *rest.RESTClient
|
||||
return ret
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package v1beta1
|
||||
|
||||
type NetworkExpansion interface{}
|
|
@ -1,191 +0,0 @@
|
|||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
v1beta1 "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1"
|
||||
scheme "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/scheme"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
rest "k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
// NetworksGetter has a method to return a NetworkInterface.
|
||||
// A group's client should implement this interface.
|
||||
type NetworksGetter interface {
|
||||
Networks(namespace string) NetworkInterface
|
||||
}
|
||||
|
||||
// NetworkInterface has methods to work with Network resources.
|
||||
type NetworkInterface interface {
|
||||
Create(*v1beta1.Network) (*v1beta1.Network, error)
|
||||
Update(*v1beta1.Network) (*v1beta1.Network, error)
|
||||
UpdateStatus(*v1beta1.Network) (*v1beta1.Network, error)
|
||||
Delete(name string, options *v1.DeleteOptions) error
|
||||
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
|
||||
Get(name string, options v1.GetOptions) (*v1beta1.Network, error)
|
||||
List(opts v1.ListOptions) (*v1beta1.NetworkList, error)
|
||||
Watch(opts v1.ListOptions) (watch.Interface, error)
|
||||
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Network, err error)
|
||||
NetworkExpansion
|
||||
}
|
||||
|
||||
// networks implements NetworkInterface
|
||||
type networks struct {
|
||||
client rest.Interface
|
||||
ns string
|
||||
}
|
||||
|
||||
// newNetworks returns a Networks
|
||||
func newNetworks(c *NetworkingCCIV1beta1Client, namespace string) *networks {
|
||||
return &networks{
|
||||
client: c.RESTClient(),
|
||||
ns: namespace,
|
||||
}
|
||||
}
|
||||
|
||||
// Get takes name of the network, and returns the corresponding network object, and an error if there is any.
|
||||
func (c *networks) Get(name string, options v1.GetOptions) (result *v1beta1.Network, err error) {
|
||||
result = &v1beta1.Network{}
|
||||
err = c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("networks").
|
||||
Name(name).
|
||||
VersionedParams(&options, scheme.ParameterCodec).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// List takes label and field selectors, and returns the list of Networks that match those selectors.
|
||||
func (c *networks) List(opts v1.ListOptions) (result *v1beta1.NetworkList, err error) {
|
||||
var timeout time.Duration
|
||||
if opts.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
||||
}
|
||||
result = &v1beta1.NetworkList{}
|
||||
err = c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("networks").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested networks.
|
||||
func (c *networks) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
||||
var timeout time.Duration
|
||||
if opts.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
||||
}
|
||||
opts.Watch = true
|
||||
return c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("networks").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Watch()
|
||||
}
|
||||
|
||||
// Create takes the representation of a network and creates it. Returns the server's representation of the network, and an error, if there is any.
|
||||
func (c *networks) Create(network *v1beta1.Network) (result *v1beta1.Network, err error) {
|
||||
result = &v1beta1.Network{}
|
||||
err = c.client.Post().
|
||||
Namespace(c.ns).
|
||||
Resource("networks").
|
||||
Body(network).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Update takes the representation of a network and updates it. Returns the server's representation of the network, and an error, if there is any.
|
||||
func (c *networks) Update(network *v1beta1.Network) (result *v1beta1.Network, err error) {
|
||||
result = &v1beta1.Network{}
|
||||
err = c.client.Put().
|
||||
Namespace(c.ns).
|
||||
Resource("networks").
|
||||
Name(network.Name).
|
||||
Body(network).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateStatus was generated because the type contains a Status member.
|
||||
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
|
||||
|
||||
func (c *networks) UpdateStatus(network *v1beta1.Network) (result *v1beta1.Network, err error) {
|
||||
result = &v1beta1.Network{}
|
||||
err = c.client.Put().
|
||||
Namespace(c.ns).
|
||||
Resource("networks").
|
||||
Name(network.Name).
|
||||
SubResource("status").
|
||||
Body(network).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete takes name of the network and deletes it. Returns an error if one occurs.
|
||||
func (c *networks) Delete(name string, options *v1.DeleteOptions) error {
|
||||
return c.client.Delete().
|
||||
Namespace(c.ns).
|
||||
Resource("networks").
|
||||
Name(name).
|
||||
Body(options).
|
||||
Do().
|
||||
Error()
|
||||
}
|
||||
|
||||
// DeleteCollection deletes a collection of objects.
|
||||
func (c *networks) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
||||
var timeout time.Duration
|
||||
if listOptions.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
|
||||
}
|
||||
return c.client.Delete().
|
||||
Namespace(c.ns).
|
||||
Resource("networks").
|
||||
VersionedParams(&listOptions, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Body(options).
|
||||
Do().
|
||||
Error()
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched network.
|
||||
func (c *networks) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Network, err error) {
|
||||
result = &v1beta1.Network{}
|
||||
err = c.client.Patch(pt).
|
||||
Namespace(c.ns).
|
||||
Resource("networks").
|
||||
SubResource(subresources...).
|
||||
Name(name).
|
||||
Body(data).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
v1beta1 "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1"
|
||||
"gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/scheme"
|
||||
rest "k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
type NetworkingCCIV1beta1Interface interface {
|
||||
RESTClient() rest.Interface
|
||||
NetworksGetter
|
||||
}
|
||||
|
||||
// NetworkingCCIV1beta1Client is used to interact with features provided by the networking.cci.io group.
|
||||
type NetworkingCCIV1beta1Client struct {
|
||||
restClient rest.Interface
|
||||
}
|
||||
|
||||
func (c *NetworkingCCIV1beta1Client) Networks(namespace string) NetworkInterface {
|
||||
return newNetworks(c, namespace)
|
||||
}
|
||||
|
||||
// NewForConfig creates a new NetworkingCCIV1beta1Client for the given config.
|
||||
func NewForConfig(c *rest.Config) (*NetworkingCCIV1beta1Client, error) {
|
||||
config := *c
|
||||
if err := setConfigDefaults(&config); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
client, err := rest.RESTClientFor(&config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &NetworkingCCIV1beta1Client{client}, nil
|
||||
}
|
||||
|
||||
// NewForConfigOrDie creates a new NetworkingCCIV1beta1Client for the given config and
|
||||
// panics if there is an error in the config.
|
||||
func NewForConfigOrDie(c *rest.Config) *NetworkingCCIV1beta1Client {
|
||||
client, err := NewForConfig(c)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
// New creates a new NetworkingCCIV1beta1Client for the given RESTClient.
|
||||
func New(c rest.Interface) *NetworkingCCIV1beta1Client {
|
||||
return &NetworkingCCIV1beta1Client{c}
|
||||
}
|
||||
|
||||
func setConfigDefaults(config *rest.Config) error {
|
||||
gv := v1beta1.SchemeGroupVersion
|
||||
config.GroupVersion = &gv
|
||||
config.APIPath = "/apis"
|
||||
config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
|
||||
|
||||
if config.UserAgent == "" {
|
||||
config.UserAgent = rest.DefaultKubernetesUserAgent()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RESTClient returns a RESTClient that is used to communicate
|
||||
// with API server by this client implementation.
|
||||
func (c *NetworkingCCIV1beta1Client) RESTClient() rest.Interface {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
return c.restClient
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
package deployment
|
||||
|
||||
import (
|
||||
v1 "k8s.io/api/apps/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
)
|
||||
|
||||
const (
|
||||
app = "test-k8s-client-deployment"
|
||||
namespace = "test-k8s-client-namespace1"
|
||||
)
|
||||
|
||||
// CreateDeployment 创建Deployment
|
||||
// API参考:https://support.huaweicloud.com/api-cci/createAppsV1NamespacedDeployment.html
|
||||
func CreateDeployment(client *kubernetes.Clientset) (*v1.Deployment, error) {
|
||||
var replicas int32 = 2
|
||||
var priority int32 = 0
|
||||
|
||||
container := corev1.Container{
|
||||
Name: "container-0",
|
||||
Image: "library/nginx:stable-alpine-perl",
|
||||
Resources: corev1.ResourceRequirements{
|
||||
Requests: map[corev1.ResourceName]resource.Quantity{
|
||||
corev1.ResourceCPU: resource.MustParse("500m"),
|
||||
corev1.ResourceMemory: resource.MustParse("1024Mi"),
|
||||
},
|
||||
Limits: map[corev1.ResourceName]resource.Quantity{
|
||||
corev1.ResourceCPU: resource.MustParse("500m"),
|
||||
corev1.ResourceMemory: resource.MustParse("1024Mi"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
podTemplate := corev1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{Labels: map[string]string{"app": app}},
|
||||
Spec: corev1.PodSpec{
|
||||
Priority: &priority,
|
||||
ImagePullSecrets: []corev1.LocalObjectReference{{Name: "imagepull-secret"}},
|
||||
Containers: []corev1.Container{container},
|
||||
},
|
||||
}
|
||||
|
||||
deployment := v1.Deployment{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: "apps/v1",
|
||||
Kind: "Deployment",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: app,
|
||||
},
|
||||
Spec: v1.DeploymentSpec{
|
||||
Replicas: &replicas,
|
||||
Selector: &metav1.LabelSelector{
|
||||
MatchLabels: map[string]string{
|
||||
"app": app,
|
||||
},
|
||||
},
|
||||
Template: podTemplate,
|
||||
},
|
||||
}
|
||||
return client.AppsV1().Deployments(namespace).Create(&deployment)
|
||||
}
|
||||
|
||||
// DeleteDeployment 删除Deployment
|
||||
// API参考:https://support.huaweicloud.com/api-cci/deleteAppsV1NamespacedDeployment.html
|
||||
func DeleteDeployment(client *kubernetes.Clientset) error {
|
||||
return client.AppsV1().Deployments(namespace).Delete(app, &metav1.DeleteOptions{})
|
||||
}
|
||||
|
||||
// GetDeployment 查询Deployment
|
||||
// API参考:https://support.huaweicloud.com/api-cci/readAppsV1NamespacedDeployment.html
|
||||
func GetDeployment(client *kubernetes.Clientset) (*v1.Deployment, error) {
|
||||
return client.AppsV1().Deployments(namespace).Get(app, metav1.GetOptions{})
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
package namespace
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
)
|
||||
|
||||
const (
|
||||
namespace = "test-k8s-client-namespace1"
|
||||
)
|
||||
|
||||
// CreateNamespace 创建命名空间
|
||||
// API参考:https://support.huaweicloud.com/api-cci/createCoreV1Namespace.html
|
||||
func CreateNamespace(cs *kubernetes.Clientset) (*corev1.Namespace, error) {
|
||||
namespace := &corev1.Namespace{
|
||||
TypeMeta: metav1.TypeMeta{},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: namespace,
|
||||
Annotations: map[string]string{
|
||||
"namespace.kubernetes.io/flavor": "general-computing",
|
||||
"network.cci.io/warm-pool-size": "10",
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"rbac.authorization.cci.io/enable-k8s-rbac": "false",
|
||||
},
|
||||
},
|
||||
}
|
||||
return cs.CoreV1().Namespaces().Create(namespace)
|
||||
}
|
||||
|
||||
// DeleteNamespace 删除Namespace
|
||||
// API参考:https://support.huaweicloud.com/api-cci/deleteCoreV1Namespace.html
|
||||
func DeleteNamespace(cs *kubernetes.Clientset) error {
|
||||
return cs.CoreV1().Namespaces().Delete(namespace, &metav1.DeleteOptions{})
|
||||
}
|
||||
|
||||
// WaitNamespaceActive 查询Namespace状态,等待其状态变为"Active"
|
||||
// API参考:https://support.huaweicloud.com/api-cci/readCoreV1Namespace.html
|
||||
func WaitNamespaceActive(cs *kubernetes.Clientset) error {
|
||||
return wait.Poll(time.Second*5, time.Second*30, func() (done bool, err error) {
|
||||
ns, err := cs.CoreV1().Namespaces().Get(namespace, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if ns.Status.Phase == corev1.NamespaceActive {
|
||||
return true, nil
|
||||
}
|
||||
return false, nil
|
||||
})
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
package network
|
||||
|
||||
import (
|
||||
"gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1"
|
||||
"gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/auth/aksk"
|
||||
"time"
|
||||
|
||||
clientset "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
)
|
||||
|
||||
const (
|
||||
name = "test-k8s-client-namespace-cn-north-1-default-network"
|
||||
namespace = "test-k8s-client-namespace1"
|
||||
)
|
||||
|
||||
// CreateNetwork 创建Network,并等待其状态变更为Active
|
||||
// 参考《Namespace和Network》 https://support.huaweicloud.com/devg-cci/cci_05_0023.html
|
||||
// API参考:https://support.huaweicloud.com/api-cci/createNetworkingCciIoV1beta1NamespacedNetwork.html
|
||||
func CreateNetwork(cs *clientset.Clientset) (*v1beta1.Network, error) {
|
||||
|
||||
network := &v1beta1.Network{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Annotations: map[string]string{
|
||||
"network.alpha.kubernetes.io/default-security-group": aksk.SecurityGroupID,
|
||||
"network.alpha.kubernetes.io/domain-id": aksk.DomainId,
|
||||
"network.alpha.kubernetes.io/project-id": aksk.ProjectId,
|
||||
},
|
||||
Name: name,
|
||||
},
|
||||
Spec: v1beta1.NetworkSpec{
|
||||
AvailableZone: aksk.AvailableZone,
|
||||
CIDR: aksk.Cidr,
|
||||
AttachedVPC: aksk.VpcID,
|
||||
NetworkID: aksk.NetworkID,
|
||||
NetworkType: "underlay_neutron",
|
||||
SubnetID: aksk.SubnetID,
|
||||
},
|
||||
}
|
||||
network, err := cs.NetworkingCCIV1beta1().Networks(namespace).Create(network)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 查询Network状态,等待其状态变为"Active"
|
||||
err = wait.Poll(time.Second*5, time.Second*30, func() (done bool, err error) {
|
||||
network, err = cs.NetworkingCCIV1beta1().Networks(namespace).Get(name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if network.Status.State == v1beta1.NetworkActive {
|
||||
return true, nil
|
||||
}
|
||||
return false, nil
|
||||
})
|
||||
return network, err
|
||||
}
|
|
@ -1,134 +0,0 @@
|
|||
package pod
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/common/config"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
)
|
||||
|
||||
// CreatePod 创建Pod
|
||||
func CreatePod(client *kubernetes.Clientset, configPath string) (*corev1.Pod, error) {
|
||||
|
||||
var configCommon config.PCMContainerConfig
|
||||
configCommon, _ = config.PCMconfig(configPath)
|
||||
|
||||
nameSpace := configCommon.NameSpace
|
||||
podName := configCommon.ContainerGroupName
|
||||
containerImage := configCommon.ContainerImage
|
||||
containerName := configCommon.ContainerName
|
||||
cpuPod := configCommon.CpuPod
|
||||
memoryPod := configCommon.MemoryPod
|
||||
pod := corev1.Pod{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: "core/V1",
|
||||
Kind: "Pod",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: podName,
|
||||
Namespace: nameSpace,
|
||||
Labels: map[string]string{"name": "testapi"},
|
||||
},
|
||||
Spec: corev1.PodSpec{
|
||||
RestartPolicy: corev1.RestartPolicyAlways,
|
||||
Containers: []corev1.Container{
|
||||
{
|
||||
Name: containerName,
|
||||
Image: containerImage,
|
||||
Resources: corev1.ResourceRequirements{
|
||||
Limits: map[corev1.ResourceName]resource.Quantity{
|
||||
corev1.ResourceCPU: resource.MustParse(cpuPod),
|
||||
corev1.ResourceMemory: resource.MustParse(memoryPod),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Status: corev1.PodStatus{},
|
||||
}
|
||||
|
||||
fmt.Println("Huawei ContainerGroup created")
|
||||
return client.CoreV1().Pods(nameSpace).Create(&pod)
|
||||
}
|
||||
|
||||
// ListPod 查询Namespace下Pod列表
|
||||
func ListPod(client *kubernetes.Clientset, configPath string) (*corev1.PodList, error) {
|
||||
|
||||
var configCommon config.PCMContainerConfig
|
||||
configCommon, _ = config.PCMconfig(configPath)
|
||||
|
||||
nameSpace := configCommon.NameSpace
|
||||
|
||||
podList, _ := client.CoreV1().Pods(nameSpace).List(metav1.ListOptions{})
|
||||
fmt.Println("Huawei ContainerGroup list", podList)
|
||||
|
||||
return podList, nil
|
||||
}
|
||||
|
||||
// UpdatePod 更新指定Pod
|
||||
/*
|
||||
// 跨namespace目前有点问题
|
||||
*/
|
||||
func UpdatePod(client *kubernetes.Clientset, configPath string) (*corev1.Pod, error) {
|
||||
|
||||
var configCommon config.PCMContainerConfig
|
||||
configCommon, _ = config.PCMconfig(configPath)
|
||||
|
||||
nameSpace := configCommon.NamespaceUpdate
|
||||
podName := configCommon.ContainerGroupNameUpdate
|
||||
containerImage := configCommon.ContainerImageUpdate
|
||||
containerName := configCommon.ContainerNameUpdate
|
||||
|
||||
pod := corev1.Pod{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: "core/V1",
|
||||
Kind: "Pod",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: podName,
|
||||
Namespace: nameSpace,
|
||||
Labels: map[string]string{"name": "pod-test2"},
|
||||
},
|
||||
Spec: corev1.PodSpec{
|
||||
RestartPolicy: corev1.RestartPolicyAlways,
|
||||
Containers: []corev1.Container{
|
||||
{
|
||||
Name: containerName,
|
||||
Image: containerImage,
|
||||
Resources: corev1.ResourceRequirements{
|
||||
Limits: map[corev1.ResourceName]resource.Quantity{
|
||||
corev1.ResourceLimitsCPU: resource.MustParse("500m"),
|
||||
corev1.ResourceLimitsMemory: resource.MustParse("1Gi"),
|
||||
},
|
||||
Requests: map[corev1.ResourceName]resource.Quantity{
|
||||
corev1.ResourceRequestsCPU: resource.MustParse("500m"),
|
||||
corev1.ResourceRequestsMemory: resource.MustParse("1Gi"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Status: corev1.PodStatus{},
|
||||
}
|
||||
|
||||
podNew, _ := client.CoreV1().Pods(nameSpace).Update(&pod)
|
||||
fmt.Println("Huawei ContainerGroup updated", podNew)
|
||||
|
||||
return podNew, nil
|
||||
}
|
||||
|
||||
// DeletePod 删除指定Pod
|
||||
func DeletePod(client *kubernetes.Clientset, configPath string) error {
|
||||
|
||||
var configCommon config.PCMContainerConfig
|
||||
configCommon, _ = config.PCMconfig(configPath)
|
||||
|
||||
nameSpace := configCommon.NameSpace
|
||||
podName := configCommon.ContainerGroupName
|
||||
|
||||
fmt.Println("Huawei ContainerGroup:", podName, " Deleted")
|
||||
|
||||
return client.CoreV1().Pods(nameSpace).Delete(podName, &metav1.DeleteOptions{})
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
[pod_create_conf]
|
||||
#区域ID
|
||||
region_id=ap-beijing
|
||||
#容器实例名称(pod名) 对应腾讯EksCiName(腾讯必需)
|
||||
container_group_name=pcm-test-tencent-pod
|
||||
#镜像地址 对应腾讯 Container.Image(腾讯必需)
|
||||
container_image=library/nginx:stable-alpine-perl
|
||||
#容器名称 对应腾讯 Container.Name(腾讯必需)
|
||||
container_name=pcm-test-tencent-container
|
||||
#Pod拥有核数 对应腾讯 Cpu(腾讯必需)
|
||||
cpu_pod=1
|
||||
#Pod拥有内存大小 对应腾讯 Memory(腾讯必需)
|
||||
memory_pod=2
|
||||
#安全组ID 对应腾讯 SecurityGroupIds(腾讯必需)
|
||||
security_group_id=sg-owzbdinl
|
||||
#子网ID 对应腾讯 SubnetId(腾讯必需)
|
||||
subnet_id=subnet-n4h73049
|
||||
#VPC ID 对应腾讯 VpcId(腾讯必需)
|
||||
vpc_id=vpc-e8hdbla8
|
||||
|
||||
[pod_list_conf]
|
||||
#区域ID
|
||||
region_id=ap-beijing
|
||||
|
||||
[pod_update_conf]
|
||||
#区域ID
|
||||
region_id=ap-beijing
|
||||
#容器实例ID 对应腾讯EksCiName(腾讯必需)
|
||||
container_group_id=eksci-pawu7qad
|
||||
#容器实例名称(pod名) 对应腾讯EksCiName(腾讯必需)
|
||||
container_group_name=eksci-pawu7qad
|
||||
|
||||
[pod_delete_conf]
|
||||
container_group_id=eksci-pawu7qad
|
|
@ -1,138 +0,0 @@
|
|||
package eks
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
|
||||
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
|
||||
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
|
||||
tke "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525"
|
||||
"gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/common/auth/aksk"
|
||||
pcmCommon "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/common/config"
|
||||
)
|
||||
|
||||
func CreateEksInstance(cloudStack string, akskPath string, configPath string) {
|
||||
|
||||
configCommon, _ := pcmCommon.PCMconfig(configPath)
|
||||
configAksk, _ := aksk.AkskConfig(cloudStack, akskPath)
|
||||
|
||||
credential := common.NewCredential(
|
||||
configAksk.AccessKey,
|
||||
configAksk.SecretKey,
|
||||
)
|
||||
cpf := profile.NewClientProfile()
|
||||
cpf.HttpProfile.Endpoint = "tke.tencentcloudapi.com"
|
||||
client, _ := tke.NewClient(credential, configCommon.RegionId, cpf)
|
||||
|
||||
request := tke.NewCreateEKSContainerInstancesRequest()
|
||||
|
||||
eksCiName := &configCommon.ContainerGroupName
|
||||
containerName := &configCommon.ContainerName
|
||||
containerImage := &configCommon.ContainerImage
|
||||
eksCpu := &configCommon.CpuPodFloat
|
||||
eksMemory := &configCommon.MemoryPodFloat
|
||||
securityGroupId := &configCommon.SecurityGroupId
|
||||
securityGroupIds := make([]*string, 1)
|
||||
securityGroupIds[0] = securityGroupId
|
||||
subNetId := &configCommon.SubnetId
|
||||
vpcId := &configCommon.VpcId
|
||||
|
||||
request.EksCiName = eksCiName
|
||||
container := make([]*tke.Container, 1)
|
||||
container[0] = new(tke.Container)
|
||||
container[0].Name = containerName
|
||||
container[0].Image = containerImage
|
||||
//container[0].Cpu = containerCpuPt
|
||||
//container[0].Memory = containerMemoryPt
|
||||
|
||||
request.Containers = container
|
||||
request.Cpu = eksCpu
|
||||
request.Memory = eksMemory
|
||||
request.SecurityGroupIds = securityGroupIds
|
||||
request.SubnetId = subNetId
|
||||
request.VpcId = vpcId
|
||||
|
||||
response, err := client.CreateEKSContainerInstances(request)
|
||||
if _, ok := err.(*errors.TencentCloudSDKError); ok {
|
||||
fmt.Printf("An API error has returned: %s", err)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("%s", response.ToJsonString())
|
||||
}
|
||||
|
||||
func ListEksInstance(cloudStack string, akskPath string, configPath string) {
|
||||
|
||||
configCommon, _ := pcmCommon.PCMconfig(configPath)
|
||||
configAksk, _ := aksk.AkskConfig(cloudStack, akskPath)
|
||||
|
||||
credential := common.NewCredential(configAksk.AccessKey, configAksk.SecretKey)
|
||||
cpf := profile.NewClientProfile()
|
||||
cpf.HttpProfile.Endpoint = "tke.tencentcloudapi.com"
|
||||
client, _ := tke.NewClient(credential, configCommon.RegionId, cpf)
|
||||
|
||||
request := tke.NewDescribeEKSContainerInstancesRequest()
|
||||
|
||||
response, err := client.DescribeEKSContainerInstances(request)
|
||||
if _, ok := err.(*errors.TencentCloudSDKError); ok {
|
||||
fmt.Printf("An API error has returned: %s", err)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("%s", response.ToJsonString())
|
||||
}
|
||||
|
||||
func UpdateEksInstance(cloudStack string, akskPath string, configPath string) {
|
||||
|
||||
configCommon, _ := pcmCommon.PCMconfig(configPath)
|
||||
configAksk, _ := aksk.AkskConfig(cloudStack, akskPath)
|
||||
|
||||
credential := common.NewCredential(configAksk.AccessKey, configAksk.SecretKey)
|
||||
cpf := profile.NewClientProfile()
|
||||
cpf.HttpProfile.Endpoint = "tke.tencentcloudapi.com"
|
||||
client, _ := tke.NewClient(credential, configCommon.RegionId, cpf)
|
||||
|
||||
request := tke.NewUpdateEKSContainerInstanceRequest()
|
||||
request.EksCiId = &configCommon.ContainerGroupIdUpdate
|
||||
request.Name = &configCommon.ContainerGroupNameUpdate
|
||||
|
||||
response, err := client.UpdateEKSContainerInstance(request)
|
||||
if _, ok := err.(*errors.TencentCloudSDKError); ok {
|
||||
fmt.Printf("An API error has returned: %s", err)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("%s", response.ToJsonString())
|
||||
}
|
||||
|
||||
func DeleteEksInstance(cloudStack string, akskPath string, configPath string) {
|
||||
|
||||
configCommon, _ := pcmCommon.PCMconfig(configPath)
|
||||
configAksk, _ := aksk.AkskConfig(cloudStack, akskPath)
|
||||
|
||||
credential := common.NewCredential(configAksk.AccessKey, configAksk.SecretKey)
|
||||
cpf := profile.NewClientProfile()
|
||||
cpf.HttpProfile.Endpoint = "tke.tencentcloudapi.com"
|
||||
client, _ := tke.NewClient(credential, configCommon.RegionId, cpf)
|
||||
|
||||
request := tke.NewDeleteEKSContainerInstancesRequest()
|
||||
eksCiIds := make([]*string, 1)
|
||||
eksCiIds[0] = &configCommon.ContainerGroupIdDelete
|
||||
|
||||
request.EksCiIds = eksCiIds
|
||||
|
||||
response, err := client.DeleteEKSContainerInstances(request)
|
||||
if _, ok := err.(*errors.TencentCloudSDKError); ok {
|
||||
fmt.Printf("An API error has returned: %s", err)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("%s", response.ToJsonString())
|
||||
}
|
|
@ -2,19 +2,17 @@ package pod
|
|||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"gitlink.org.cn/JCCE/PCM/adaptor/pod_adaptor/service/poder"
|
||||
"gitlink.org.cn/JCCE/PCM/common/tenanter"
|
||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod"
|
||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant"
|
||||
"sync"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
//ListDetail returns the detail of pod instances
|
||||
func ListDetail(ctx context.Context, req *pbpod.ListDetailReq) (*pbpod.ListDetailResp, error) {
|
||||
func CreatePod(ctx context.Context, req *pbpod.CreatePodReq) (*pbpod.CreatePodResp, error) {
|
||||
var (
|
||||
pod poder.Poder
|
||||
)
|
||||
|
@ -38,15 +36,41 @@ func ListDetail(ctx context.Context, req *pbpod.ListDetailReq) (*pbpod.ListDetai
|
|||
}
|
||||
}
|
||||
|
||||
return pod.ListDetail(ctx, req)
|
||||
return pod.CreatePod(ctx, req)
|
||||
}
|
||||
|
||||
//List returns the list of pod instances
|
||||
func List(ctx context.Context, req *pbpod.ListReq) (*pbpod.ListResp, error) {
|
||||
func ListPodDetail(ctx context.Context, req *pbpod.ListPodDetailReq) (*pbpod.ListPodDetailResp, error) {
|
||||
var (
|
||||
pod poder.Poder
|
||||
)
|
||||
|
||||
tenanters, err := tenanter.GetTenanters(req.Provider)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "getTenanters error")
|
||||
}
|
||||
|
||||
region, err := tenanter.NewRegion(req.Provider, req.RegionId)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessagef(err, "provider %v regionId %v", req.Provider, req.RegionId)
|
||||
}
|
||||
|
||||
for _, tenanter := range tenanters {
|
||||
if req.AccountName == "" || tenanter.AccountName() == req.AccountName {
|
||||
if pod, err = poder.NewPodClient(req.Provider, region, tenanter); err != nil {
|
||||
return nil, errors.WithMessage(err, "NewPodClient error")
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return pod.ListPodDetail(ctx, req)
|
||||
}
|
||||
|
||||
func ListPod(ctx context.Context, req *pbpod.ListPodReq) (*pbpod.ListPodResp, error) {
|
||||
var (
|
||||
wg sync.WaitGroup
|
||||
mutex sync.Mutex
|
||||
podes []*pbpod.PodInstance
|
||||
pods []*pbpod.PodInstance
|
||||
)
|
||||
|
||||
tenanters, err := tenanter.GetTenanters(req.Provider)
|
||||
|
@ -67,22 +91,22 @@ func List(ctx context.Context, req *pbpod.ListReq) (*pbpod.ListResp, error) {
|
|||
return
|
||||
}
|
||||
|
||||
request := &pbpod.ListDetailReq{
|
||||
request := &pbpod.ListPodDetailReq{
|
||||
Provider: req.Provider,
|
||||
AccountName: tenant.AccountName(),
|
||||
RegionId: region.GetId(),
|
||||
PageNumber: 1,
|
||||
PageSize: 20,
|
||||
PageSize: 100,
|
||||
NextToken: "",
|
||||
}
|
||||
for {
|
||||
resp, err := pod.ListDetail(ctx, request)
|
||||
resp, err := pod.ListPodDetail(ctx, request)
|
||||
if err != nil {
|
||||
glog.Errorf("ListDetail error %v", err)
|
||||
return
|
||||
}
|
||||
mutex.Lock()
|
||||
podes = append(podes, resp.Pods...)
|
||||
pods = append(pods, resp.Pods...)
|
||||
mutex.Unlock()
|
||||
if resp.Finished {
|
||||
break
|
||||
|
@ -90,19 +114,19 @@ func List(ctx context.Context, req *pbpod.ListReq) (*pbpod.ListResp, error) {
|
|||
request.PageNumber, request.PageSize, request.NextToken = resp.PageNumber, resp.PageSize, resp.NextToken
|
||||
}
|
||||
}(t, region)
|
||||
|
||||
}
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
return &pbpod.ListResp{Pods: podes}, nil
|
||||
return &pbpod.ListPodResp{Pods: pods}, nil
|
||||
}
|
||||
|
||||
// ListAll returns all pod instances
|
||||
func ListAll(ctx context.Context) (*pbpod.ListResp, error) {
|
||||
func ListPodAll(ctx context.Context) (*pbpod.ListPodResp, error) {
|
||||
var (
|
||||
wg sync.WaitGroup
|
||||
mutex sync.Mutex
|
||||
podes []*pbpod.PodInstance
|
||||
pods []*pbpod.PodInstance
|
||||
)
|
||||
|
||||
wg.Add(len(pbtenant.CloudProvider_name))
|
||||
|
@ -110,19 +134,19 @@ func ListAll(ctx context.Context) (*pbpod.ListResp, error) {
|
|||
go func(provider int32) {
|
||||
defer wg.Done()
|
||||
|
||||
resp, err := List(ctx, &pbpod.ListReq{Provider: pbtenant.CloudProvider(provider)})
|
||||
resp, err := ListPod(ctx, &pbpod.ListPodReq{Provider: pbtenant.CloudProvider(provider)})
|
||||
if err != nil {
|
||||
glog.Errorf("List error %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
mutex.Lock()
|
||||
podes = append(podes, resp.Pods...)
|
||||
pods = append(pods, resp.Pods...)
|
||||
mutex.Unlock()
|
||||
}(k)
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
|
||||
return &pbpod.ListResp{Pods: podes}, nil
|
||||
return &pbpod.ListPodResp{Pods: pods}, nil
|
||||
}
|
||||
|
|
|
@ -0,0 +1,198 @@
|
|||
package poder
|
||||
|
||||
import (
|
||||
"context"
|
||||
"gitlink.org.cn/JCCE/PCM/common/tenanter"
|
||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod"
|
||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant"
|
||||
"sync"
|
||||
|
||||
alieci "github.com/aliyun/alibaba-cloud-sdk-go/services/eci"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var aliClientMutex sync.Mutex
|
||||
|
||||
type AliEci struct {
|
||||
cli *alieci.Client
|
||||
region tenanter.Region
|
||||
tenanter tenanter.Tenanter
|
||||
}
|
||||
|
||||
func newAliEciClient(region tenanter.Region, tenant tenanter.Tenanter) (Poder, error) {
|
||||
var (
|
||||
client *alieci.Client
|
||||
err error
|
||||
)
|
||||
|
||||
switch t := tenant.(type) {
|
||||
case *tenanter.AccessKeyTenant:
|
||||
// 阿里云的sdk有一个 map 的并发问题,go test 加上-race 能检测出来,所以这里加一个锁
|
||||
aliClientMutex.Lock()
|
||||
client, err = alieci.NewClientWithAccessKey(region.GetName(), t.GetId(), t.GetSecret())
|
||||
aliClientMutex.Unlock()
|
||||
default:
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "init ali ecs client error")
|
||||
}
|
||||
|
||||
return &AliEci{
|
||||
cli: client,
|
||||
region: region,
|
||||
tenanter: tenant,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (eci *AliEci) CreatePod(ctx context.Context, req *pbpod.CreatePodReq) (*pbpod.CreatePodResp, error) {
|
||||
request := alieci.CreateCreateContainerGroupRequest()
|
||||
|
||||
request.RegionId = eci.region.GetName()
|
||||
request.ContainerGroupName = req.PodName
|
||||
requestContainer := make([]alieci.CreateContainerGroupContainer, 1)
|
||||
requestContainer[0].Image = req.ContainerImage
|
||||
requestContainer[0].Name = req.ContainerName
|
||||
request.Container = &requestContainer
|
||||
|
||||
resp, err := eci.cli.CreateContainerGroup(request)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Aliyun CreatePod error")
|
||||
}
|
||||
|
||||
isFinished := false
|
||||
if len(resp.ContainerGroupId) > 0 {
|
||||
isFinished = true
|
||||
}
|
||||
|
||||
return &pbpod.CreatePodResp{
|
||||
Pods: nil,
|
||||
Finished: isFinished,
|
||||
RequestId: resp.RequestId,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (eci *AliEci) ListPodDetail(ctx context.Context, req *pbpod.ListPodDetailReq) (*pbpod.ListPodDetailResp, error) {
|
||||
request := alieci.CreateDescribeContainerGroupsRequest()
|
||||
request.NextToken = req.NextToken
|
||||
resp, err := eci.cli.DescribeContainerGroups(request)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Aliyun ListDetail error")
|
||||
}
|
||||
|
||||
var ecies = make([]*pbpod.PodInstance, len(resp.ContainerGroups))
|
||||
for k, v := range resp.ContainerGroups {
|
||||
ecies[k] = &pbpod.PodInstance{
|
||||
Provider: pbtenant.CloudProvider_ali,
|
||||
AccountName: eci.tenanter.AccountName(),
|
||||
PodId: v.ContainerGroupId,
|
||||
PodName: v.ContainerGroupName,
|
||||
RegionId: 0,
|
||||
ContainerImage: v.Containers[k].Image,
|
||||
ContainerName: v.Containers[k].Name,
|
||||
CpuPod: v.Cpu,
|
||||
MemoryPod: v.Memory,
|
||||
SecurityGroupId: v.SecurityGroupId,
|
||||
SubnetId: v.InternetIp,
|
||||
VpcId: v.VpcId,
|
||||
Namespace: "",
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
isFinished := false
|
||||
if len(ecies) < int(req.PageSize) {
|
||||
isFinished = true
|
||||
}
|
||||
|
||||
return &pbpod.ListPodDetailResp{
|
||||
Pods: ecies,
|
||||
Finished: isFinished,
|
||||
PageNumber: req.PageNumber + 1,
|
||||
PageSize: req.PageSize,
|
||||
NextToken: resp.NextToken,
|
||||
RequestId: resp.RequestId,
|
||||
}, nil
|
||||
}
|
||||
|
||||
//
|
||||
//// DescribeContainerGroup 查询Pod
|
||||
//func DescribeContainerGroup(cloudStack string, akskPath string, configPath string) eci.DescribeContainerGroupsContainerGroup0 {
|
||||
// var client *eci.Client
|
||||
//
|
||||
// configCommon, _ := config.PCMconfig(configPath)
|
||||
// configAksk, _ := aksk.AkskConfig(cloudStack, akskPath)
|
||||
// client, _ = eci.NewClientWithAccessKey(configCommon.RegionId, configAksk.AccessKey, configAksk.SecretKey)
|
||||
//
|
||||
// // 生成查询请求
|
||||
// describeContainerGroupsRequest := eci.CreateDescribeContainerGroupsRequest()
|
||||
// describeContainerGroupsRequest.RegionId = configCommon.RegionIdList
|
||||
// describeContainerGroupsResponse, err := client.DescribeContainerGroups(describeContainerGroupsRequest)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
// describeContainerGroupNumber := len(describeContainerGroupsResponse.ContainerGroups)
|
||||
//
|
||||
// //当前区域没有Pod情形的处理
|
||||
// if describeContainerGroupsResponse.TotalCount != 1 && describeContainerGroupNumber != 1 {
|
||||
// fmt.Println("Invalid ContainerGroups count", describeContainerGroupsResponse.TotalCount, describeContainerGroupNumber)
|
||||
// panic("Invalid ContainerGroups count")
|
||||
// }
|
||||
//
|
||||
// fmt.Println("Alibaba ContainerGroup Name:", describeContainerGroupsResponse.ContainerGroups[0].ContainerGroupName, "\n",
|
||||
// "ContainerGroup Id:", describeContainerGroupsResponse.ContainerGroups[0].ContainerGroupId)
|
||||
//
|
||||
// return describeContainerGroupsResponse.ContainerGroups[0]
|
||||
//}
|
||||
//
|
||||
//// UpdateContainerGroup 更新Pod
|
||||
//func UpdateContainerGroup(cloudStack string, akskPath string, configPath string) string {
|
||||
// var client *eci.Client
|
||||
//
|
||||
// configCommon, _ := config.PCMconfig(configPath)
|
||||
// configAksk, _ := aksk.AkskConfig(cloudStack, akskPath)
|
||||
//
|
||||
// client, _ = eci.NewClientWithAccessKey(configCommon.RegionId, configAksk.AccessKey, configAksk.SecretKey)
|
||||
//
|
||||
// //生成更新请求
|
||||
// updateContainerGroupRequest := eci.CreateUpdateContainerGroupRequest()
|
||||
// updateContainerGroupRequest.RegionId = configCommon.RegionIdUpdate
|
||||
// updateContainerGroupRequest.ContainerGroupId = configCommon.ContainerGroupIdUpdate
|
||||
//
|
||||
// //容器实体内容,这里测试可以修改配置文件中的重启策略
|
||||
// updateContainerRequestContainer := make([]eci.UpdateContainerGroupContainer, 1)
|
||||
// updateContainerRequestContainer[0].Image = configCommon.ContainerImage
|
||||
// updateContainerRequestContainer[0].Name = configCommon.ContainerName
|
||||
// updateContainerGroupRequest.Container = &updateContainerRequestContainer
|
||||
// updateContainerGroupRequest.RestartPolicy = configCommon.RestartPolicyUpdate
|
||||
//
|
||||
// updateContainerGroupResponse, err := client.UpdateContainerGroup(updateContainerGroupRequest)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
// requestId := updateContainerGroupResponse.RequestId
|
||||
// fmt.Println("Alibaba ContainerGroup: ", configCommon.ContainerGroupIdUpdate, " Updated with request ID:", requestId)
|
||||
// return requestId
|
||||
//}
|
||||
//
|
||||
//// DeleteContainerGroup 删除Pod
|
||||
//func DeleteContainerGroup(cloudStack string, akskPath string, configPath string) string {
|
||||
// var client *eci.Client
|
||||
// configCommon, _ := config.PCMconfig(configPath)
|
||||
// configAksk, _ := aksk.AkskConfig(cloudStack, akskPath)
|
||||
// client, _ = eci.NewClientWithAccessKey(configCommon.RegionId, configAksk.AccessKey, configAksk.SecretKey)
|
||||
//
|
||||
// //生成删除请求
|
||||
// deleteContainerGroupRequest := eci.CreateDeleteContainerGroupRequest()
|
||||
// deleteContainerGroupRequest.RegionId = configCommon.RegionIdDelete
|
||||
// deleteContainerGroupRequest.ContainerGroupId = configCommon.ContainerGroupIdDelete
|
||||
//
|
||||
// deleteContainerGroupResponse, err := client.DeleteContainerGroup(deleteContainerGroupRequest)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
// requestId := deleteContainerGroupResponse.RequestId
|
||||
// fmt.Println("Alibaba ContainerGroup: ", configCommon.ContainerGroupIdUpdate, " Deleted with request ID:", requestId)
|
||||
//
|
||||
// return requestId
|
||||
//}
|
|
@ -0,0 +1,135 @@
|
|||
package poder
|
||||
|
||||
//
|
||||
//import (
|
||||
// "fmt"
|
||||
// "gitlink.org.cn/JCCE/PCM/adaptor/pod_adaptor/common/config"
|
||||
// corev1 "k8s.io/api/core/v1"
|
||||
// "k8s.io/apimachinery/pkg/api/resource"
|
||||
// metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
// "k8s.io/client-go/kubernetes"
|
||||
//)
|
||||
//
|
||||
//// CreatePod 创建Pod
|
||||
//func CreatePod(client *kubernetes.Clientset, configPath string) (*corev1.Pod, error) {
|
||||
//
|
||||
// var configCommon config.PCMContainerConfig
|
||||
// configCommon, _ = config.PCMconfig(configPath)
|
||||
//
|
||||
// nameSpace := configCommon.NameSpace
|
||||
// podName := configCommon.ContainerGroupName
|
||||
// containerImage := configCommon.ContainerImage
|
||||
// containerName := configCommon.ContainerName
|
||||
// cpuPod := configCommon.CpuPod
|
||||
// memoryPod := configCommon.MemoryPod
|
||||
// pod := corev1.Pod{
|
||||
// TypeMeta: metav1.TypeMeta{
|
||||
// APIVersion: "core/V1",
|
||||
// Kind: "Pod",
|
||||
// },
|
||||
// ObjectMeta: metav1.ObjectMeta{
|
||||
// Name: podName,
|
||||
// Namespace: nameSpace,
|
||||
// Labels: map[string]string{"name": "testapi"},
|
||||
// },
|
||||
// Spec: corev1.PodSpec{
|
||||
// RestartPolicy: corev1.RestartPolicyAlways,
|
||||
// Containers: []corev1.Container{
|
||||
// {
|
||||
// Name: containerName,
|
||||
// Image: containerImage,
|
||||
// Resources: corev1.ResourceRequirements{
|
||||
// Limits: map[corev1.ResourceName]resource.Quantity{
|
||||
// corev1.ResourceCPU: resource.MustParse(cpuPod),
|
||||
// corev1.ResourceMemory: resource.MustParse(memoryPod),
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// Status: corev1.PodStatus{},
|
||||
// }
|
||||
//
|
||||
// fmt.Println("Huawei ContainerGroup created")
|
||||
// return client.CoreV1().Pods(nameSpace).Create(&pod)
|
||||
//}
|
||||
//
|
||||
//// ListPod 查询Namespace下Pod列表
|
||||
//func ListPod(client *kubernetes.Clientset, configPath string) (*corev1.PodList, error) {
|
||||
//
|
||||
// var configCommon config.PCMContainerConfig
|
||||
// configCommon, _ = config.PCMconfig(configPath)
|
||||
//
|
||||
// nameSpace := configCommon.NameSpace
|
||||
//
|
||||
// podList, _ := client.CoreV1().Pods(nameSpace).List(metav1.ListOptions{})
|
||||
// fmt.Println("Huawei ContainerGroup list", podList)
|
||||
//
|
||||
// return podList, nil
|
||||
//}
|
||||
//
|
||||
//// UpdatePod 更新指定Pod
|
||||
///*
|
||||
//// 跨namespace目前有点问题
|
||||
//*/
|
||||
//func UpdatePod(client *kubernetes.Clientset, configPath string) (*corev1.Pod, error) {
|
||||
//
|
||||
// var configCommon config.PCMContainerConfig
|
||||
// configCommon, _ = config.PCMconfig(configPath)
|
||||
//
|
||||
// nameSpace := configCommon.NamespaceUpdate
|
||||
// podName := configCommon.ContainerGroupNameUpdate
|
||||
// containerImage := configCommon.ContainerImageUpdate
|
||||
// containerName := configCommon.ContainerNameUpdate
|
||||
//
|
||||
// pod := corev1.Pod{
|
||||
// TypeMeta: metav1.TypeMeta{
|
||||
// APIVersion: "core/V1",
|
||||
// Kind: "Pod",
|
||||
// },
|
||||
// ObjectMeta: metav1.ObjectMeta{
|
||||
// Name: podName,
|
||||
// Namespace: nameSpace,
|
||||
// Labels: map[string]string{"name": "pod-test2"},
|
||||
// },
|
||||
// Spec: corev1.PodSpec{
|
||||
// RestartPolicy: corev1.RestartPolicyAlways,
|
||||
// Containers: []corev1.Container{
|
||||
// {
|
||||
// Name: containerName,
|
||||
// Image: containerImage,
|
||||
// Resources: corev1.ResourceRequirements{
|
||||
// Limits: map[corev1.ResourceName]resource.Quantity{
|
||||
// corev1.ResourceLimitsCPU: resource.MustParse("500m"),
|
||||
// corev1.ResourceLimitsMemory: resource.MustParse("1Gi"),
|
||||
// },
|
||||
// Requests: map[corev1.ResourceName]resource.Quantity{
|
||||
// corev1.ResourceRequestsCPU: resource.MustParse("500m"),
|
||||
// corev1.ResourceRequestsMemory: resource.MustParse("1Gi"),
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// Status: corev1.PodStatus{},
|
||||
// }
|
||||
//
|
||||
// podNew, _ := client.CoreV1().Pods(nameSpace).Update(&pod)
|
||||
// fmt.Println("Huawei ContainerGroup updated", podNew)
|
||||
//
|
||||
// return podNew, nil
|
||||
//}
|
||||
//
|
||||
//// DeletePod 删除指定Pod
|
||||
//func DeletePod(client *kubernetes.Clientset, configPath string) error {
|
||||
//
|
||||
// var configCommon config.PCMContainerConfig
|
||||
// configCommon, _ = config.PCMconfig(configPath)
|
||||
//
|
||||
// nameSpace := configCommon.NameSpace
|
||||
// podName := configCommon.ContainerGroupName
|
||||
//
|
||||
// fmt.Println("Huawei ContainerGroup:", podName, " Deleted")
|
||||
//
|
||||
// return client.CoreV1().Pods(nameSpace).Delete(podName, &metav1.DeleteOptions{})
|
||||
//}
|
|
@ -2,10 +2,8 @@ package poder
|
|||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod"
|
||||
|
||||
"gitlink.org.cn/JCCE/PCM/common/tenanter"
|
||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod"
|
||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
@ -18,7 +16,8 @@ var (
|
|||
)
|
||||
|
||||
type Poder interface {
|
||||
ListDetail(ctx context.Context, req *pbpod.ListDetailReq) (resp *pbpod.ListDetailResp, err error)
|
||||
ListPodDetail(ctx context.Context, req *pbpod.ListPodDetailReq) (resp *pbpod.ListPodDetailResp, err error)
|
||||
CreatePod(ctx context.Context, req *pbpod.CreatePodReq) (resp *pbpod.CreatePodResp, err error)
|
||||
}
|
||||
|
||||
func NewPodClient(provider pbtenant.CloudProvider, region tenanter.Region, tenant tenanter.Tenanter) (poder Poder, err error) {
|
||||
|
@ -32,11 +31,11 @@ func NewPodClient(provider pbtenant.CloudProvider, region tenanter.Region, tenan
|
|||
|
||||
switch provider {
|
||||
case pbtenant.CloudProvider_ali:
|
||||
return newAliPodClient(region, tenant)
|
||||
//case pbtenant.CloudProvider_tencent:
|
||||
// return newTencentPodClient(region, tenant)
|
||||
return newAliEciClient(region, tenant)
|
||||
case pbtenant.CloudProvider_tencent:
|
||||
return nil, nil
|
||||
case pbtenant.CloudProvider_huawei:
|
||||
return newHuaweiPodClient(region, tenant)
|
||||
return nil, nil
|
||||
//TODO aws
|
||||
//case pbtenant.CloudProvider_aws:
|
||||
// return newAwsPodClient(region, tenant)
|
||||
|
|
|
@ -0,0 +1,139 @@
|
|||
package poder
|
||||
|
||||
//
|
||||
//import (
|
||||
// "fmt"
|
||||
// "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
|
||||
// "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
|
||||
// "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
|
||||
// tke "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525"
|
||||
// "gitlink.org.cn/JCCE/PCM/adaptor/pod_adaptor/common/auth/aksk"
|
||||
// pcmCommon "gitlink.org.cn/JCCE/PCM/adaptor/pod_adaptor/common/config"
|
||||
//)
|
||||
//
|
||||
//func CreateEksInstance(cloudStack string, akskPath string, configPath string) {
|
||||
//
|
||||
// configCommon, _ := pcmCommon.PCMconfig(configPath)
|
||||
// configAksk, _ := aksk.AkskConfig(cloudStack, akskPath)
|
||||
//
|
||||
// credential := common.NewCredential(
|
||||
// configAksk.AccessKey,
|
||||
// configAksk.SecretKey,
|
||||
// )
|
||||
// cpf := profile.NewClientProfile()
|
||||
// cpf.HttpProfile.Endpoint = "tke.tencentcloudapi.com"
|
||||
// client, _ := tke.NewClient(credential, configCommon.RegionId, cpf)
|
||||
//
|
||||
// request := tke.NewCreateEKSContainerInstancesRequest()
|
||||
//
|
||||
// eksCiName := &configCommon.ContainerGroupName
|
||||
// containerName := &configCommon.ContainerName
|
||||
// containerImage := &configCommon.ContainerImage
|
||||
// eksCpu := &configCommon.CpuPodFloat
|
||||
// eksMemory := &configCommon.MemoryPodFloat
|
||||
// securityGroupId := &configCommon.SecurityGroupId
|
||||
// securityGroupIds := make([]*string, 1)
|
||||
// securityGroupIds[0] = securityGroupId
|
||||
// subNetId := &configCommon.SubnetId
|
||||
// vpcId := &configCommon.VpcId
|
||||
//
|
||||
// request.EksCiName = eksCiName
|
||||
// container := make([]*tke.Container, 1)
|
||||
// container[0] = new(tke.Container)
|
||||
// container[0].Name = containerName
|
||||
// container[0].Image = containerImage
|
||||
// //container[0].Cpu = containerCpuPt
|
||||
// //container[0].Memory = containerMemoryPt
|
||||
//
|
||||
// request.Containers = container
|
||||
// request.Cpu = eksCpu
|
||||
// request.Memory = eksMemory
|
||||
// request.SecurityGroupIds = securityGroupIds
|
||||
// request.SubnetId = subNetId
|
||||
// request.VpcId = vpcId
|
||||
//
|
||||
// response, err := client.CreateEKSContainerInstances(request)
|
||||
// if _, ok := err.(*errors.TencentCloudSDKError); ok {
|
||||
// fmt.Printf("An API error has returned: %s", err)
|
||||
// return
|
||||
// }
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
// fmt.Printf("%s", response.ToJsonString())
|
||||
//}
|
||||
//
|
||||
//func ListEksInstance(cloudStack string, akskPath string, configPath string) {
|
||||
//
|
||||
// configCommon, _ := pcmCommon.PCMconfig(configPath)
|
||||
// configAksk, _ := aksk.AkskConfig(cloudStack, akskPath)
|
||||
//
|
||||
// credential := common.NewCredential(configAksk.AccessKey, configAksk.SecretKey)
|
||||
// cpf := profile.NewClientProfile()
|
||||
// cpf.HttpProfile.Endpoint = "tke.tencentcloudapi.com"
|
||||
// client, _ := tke.NewClient(credential, configCommon.RegionId, cpf)
|
||||
//
|
||||
// request := tke.NewDescribeEKSContainerInstancesRequest()
|
||||
//
|
||||
// response, err := client.DescribeEKSContainerInstances(request)
|
||||
// if _, ok := err.(*errors.TencentCloudSDKError); ok {
|
||||
// fmt.Printf("An API error has returned: %s", err)
|
||||
// return
|
||||
// }
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
// fmt.Printf("%s", response.ToJsonString())
|
||||
//}
|
||||
//
|
||||
//func UpdateEksInstance(cloudStack string, akskPath string, configPath string) {
|
||||
//
|
||||
// configCommon, _ := pcmCommon.PCMconfig(configPath)
|
||||
// configAksk, _ := aksk.AkskConfig(cloudStack, akskPath)
|
||||
//
|
||||
// credential := common.NewCredential(configAksk.AccessKey, configAksk.SecretKey)
|
||||
// cpf := profile.NewClientProfile()
|
||||
// cpf.HttpProfile.Endpoint = "tke.tencentcloudapi.com"
|
||||
// client, _ := tke.NewClient(credential, configCommon.RegionId, cpf)
|
||||
//
|
||||
// request := tke.NewUpdateEKSContainerInstanceRequest()
|
||||
// request.EksCiId = &configCommon.ContainerGroupIdUpdate
|
||||
// request.Name = &configCommon.ContainerGroupNameUpdate
|
||||
//
|
||||
// response, err := client.UpdateEKSContainerInstance(request)
|
||||
// if _, ok := err.(*errors.TencentCloudSDKError); ok {
|
||||
// fmt.Printf("An API error has returned: %s", err)
|
||||
// return
|
||||
// }
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
// fmt.Printf("%s", response.ToJsonString())
|
||||
//}
|
||||
//
|
||||
//func DeleteEksInstance(cloudStack string, akskPath string, configPath string) {
|
||||
//
|
||||
// configCommon, _ := pcmCommon.PCMconfig(configPath)
|
||||
// configAksk, _ := aksk.AkskConfig(cloudStack, akskPath)
|
||||
//
|
||||
// credential := common.NewCredential(configAksk.AccessKey, configAksk.SecretKey)
|
||||
// cpf := profile.NewClientProfile()
|
||||
// cpf.HttpProfile.Endpoint = "tke.tencentcloudapi.com"
|
||||
// client, _ := tke.NewClient(credential, configCommon.RegionId, cpf)
|
||||
//
|
||||
// request := tke.NewDeleteEKSContainerInstancesRequest()
|
||||
// eksCiIds := make([]*string, 1)
|
||||
// eksCiIds[0] = &configCommon.ContainerGroupIdDelete
|
||||
//
|
||||
// request.EksCiIds = eksCiIds
|
||||
//
|
||||
// response, err := client.DeleteEKSContainerInstances(request)
|
||||
// if _, ok := err.(*errors.TencentCloudSDKError); ok {
|
||||
// fmt.Printf("An API error has returned: %s", err)
|
||||
// return
|
||||
// }
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
// fmt.Printf("%s", response.ToJsonString())
|
||||
//}
|
|
@ -2,18 +2,16 @@ package server
|
|||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod"
|
||||
|
||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/demo"
|
||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs"
|
||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
// 使用unsafe可以强制让编译器检查是否实现了相关方法
|
||||
demo.UnsafeDemoServiceServer
|
||||
pbecs.UnsafeEcsServiceServer
|
||||
pbpod.UnimplementedPodServiceServer
|
||||
pbpod.UnsafePodServiceServer
|
||||
}
|
||||
|
||||
func (s *Server) Echo(ctx context.Context, req *demo.StringMessage) (*demo.StringMessage, error) {
|
||||
|
|
|
@ -2,7 +2,6 @@ package server
|
|||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlink.org.cn/JCCE/PCM/adaptor/pod_adaptor/server/pod"
|
||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod"
|
||||
|
||||
|
@ -11,9 +10,17 @@ import (
|
|||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// ListPodDetail return pod detail
|
||||
func (s *Server) ListPodDetail(ctx context.Context, req *pbpod.ListDetailReq) (*pbpod.ListDetailResp, error) {
|
||||
resp, err := pod.ListDetail(ctx, req)
|
||||
func (s *Server) CreatePod(ctx context.Context, req *pbpod.CreatePodReq) (*pbpod.CreatePodResp, error) {
|
||||
resp, err := pod.CreatePod(ctx, req)
|
||||
if err != nil {
|
||||
glog.Errorf("CreatePod error %+v", err)
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *Server) ListPodDetail(ctx context.Context, req *pbpod.ListPodDetailReq) (*pbpod.ListPodDetailResp, error) {
|
||||
resp, err := pod.ListPodDetail(ctx, req)
|
||||
if err != nil {
|
||||
glog.Errorf("ListPodDetail error %+v", err)
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
|
@ -21,12 +28,20 @@ func (s *Server) ListPodDetail(ctx context.Context, req *pbpod.ListDetailReq) (*
|
|||
return resp, nil
|
||||
}
|
||||
|
||||
//ListPod return pod list
|
||||
func (s *Server) ListPod(ctx context.Context, req *pbpod.ListReq) (*pbpod.ListResp, error) {
|
||||
resp, err := pod.List(ctx, req)
|
||||
func (s *Server) ListPod(ctx context.Context, req *pbpod.ListPodReq) (*pbpod.ListPodResp, error) {
|
||||
resp, err := pod.ListPod(ctx, req)
|
||||
if err != nil {
|
||||
glog.Errorf("ListPod error %+v", err)
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *Server) ListPodAll(ctx context.Context, req *pbpod.ListPodAllReq) (*pbpod.ListPodResp, error) {
|
||||
resp, err := pod.ListPodAll(ctx)
|
||||
if err != nil {
|
||||
glog.Errorf("ListPodAll error %+v", err)
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
|
|
@ -2,13 +2,13 @@ configs:
|
|||
# provider 0:阿里云 1:腾讯云 2:华为云
|
||||
- provider: 0
|
||||
name: "ali-PCM"
|
||||
accessid: ""
|
||||
accesssecret: ""
|
||||
accessid: "LTAI5tSCnrhQAdbFhGyWkSL2"
|
||||
accesssecret: "KN4tqu8lalQdo47SoUQBb88qOWjzYC"
|
||||
- provider: 1
|
||||
name: "tencent-PCM"
|
||||
accessid: ""
|
||||
accesssecret: ""
|
||||
accessid: "AKIDRefQxnhmuqTU1KRWFl58wQeCE0XoAeEZ"
|
||||
accesssecret: "LUMVRmGj2kFrEahhZzA5pKvHNSMASntj"
|
||||
- provider: 2
|
||||
name: "huawei-PCM"
|
||||
accessid: ""
|
||||
accesssecret: ""
|
||||
accessid: "ATQTIWUT9K66VRMMXKVY"
|
||||
accesssecret: "Wa0aixDVuhZOfDZGWvgIJQBHnyiDlGdgDn1Ai5Yy"
|
||||
|
|
|
@ -12,71 +12,90 @@ message PodInstance {
|
|||
// 账号名称
|
||||
string account_name = 2;
|
||||
// 实例id
|
||||
string instance_id = 3;
|
||||
string pod_id = 3;
|
||||
// 实例名称
|
||||
string instance_name = 4;
|
||||
string pod_name = 4;
|
||||
// 地域,数据中心
|
||||
string region_name = 5;
|
||||
// 公网ip
|
||||
string public_ips = 6;
|
||||
// 实例类型
|
||||
string instance_type = 7;
|
||||
// vcpu数
|
||||
int32 cpu = 8;
|
||||
// 内存MB
|
||||
int32 memory = 9;
|
||||
// 实例描述
|
||||
string description = 10;
|
||||
// 状态
|
||||
string status = 11;
|
||||
// 创建时间,ISO8601
|
||||
string creation_time = 12;
|
||||
// 过期时间
|
||||
string expire_time = 13;
|
||||
// 内网ip
|
||||
repeated string inner_ips = 14;
|
||||
// vpc id
|
||||
string vpc_id = 15;
|
||||
// 安全组id
|
||||
string security_group_id = 16;
|
||||
// 子网Id
|
||||
string SubnetId = 17;
|
||||
// 容器实例
|
||||
Container Container = 18;
|
||||
}
|
||||
|
||||
message Container {
|
||||
// 容器镜像
|
||||
string image = 1;
|
||||
int32 region_id = 5;
|
||||
// 镜像
|
||||
string container_image = 6;
|
||||
// 容器名称
|
||||
string name = 2;
|
||||
string container_name = 7;
|
||||
// vcpu数
|
||||
int32 cpu = 3;
|
||||
float cpu_pod = 8;
|
||||
// 内存MB
|
||||
int32 memory = 4;
|
||||
// 重启次数
|
||||
int32 restart_count = 5;
|
||||
float memory_pod = 9;
|
||||
|
||||
//安全组ID 对应腾讯 SecurityGroupIds(腾讯必需)
|
||||
string security_group_id = 10;
|
||||
//子网ID 对应腾讯 SubnetId(腾讯必需)
|
||||
string subnet_id = 11;
|
||||
//VPC ID 对应腾讯 VpcId(腾讯必需)
|
||||
string vpc_id = 12;
|
||||
//名空间
|
||||
string namespace = 13;
|
||||
|
||||
}
|
||||
|
||||
message ListDetailReq {
|
||||
|
||||
message CreatePodReq {
|
||||
// 云类型
|
||||
pbtenant.CloudProvider provider = 1;
|
||||
// 账号名称
|
||||
string account_name = 2;
|
||||
// 实例id
|
||||
string pod_id = 3;
|
||||
// 实例名称
|
||||
string pod_name = 4;
|
||||
// 地域,数据中心
|
||||
int32 region_id = 5;
|
||||
// 镜像
|
||||
string container_image = 6;
|
||||
// 容器名称
|
||||
string container_name = 7;
|
||||
// v cpu数
|
||||
float cpu_pod = 8;
|
||||
// 内存MB
|
||||
float memory_pod = 9;
|
||||
//安全组ID 对应腾讯 SecurityGroupIds(腾讯必需)
|
||||
string security_group_id = 10;
|
||||
//子网ID 对应腾讯 SubnetId(腾讯必需)
|
||||
string subnet_id = 11;
|
||||
//VPC ID 对应腾讯 VpcId(腾讯必需)
|
||||
string vpc_id = 12;
|
||||
//名空间
|
||||
string namespace = 13;
|
||||
}
|
||||
|
||||
message CreatePodResp {
|
||||
// Pod集合
|
||||
repeated PodInstance pods = 1;
|
||||
// 查询是否完成,如果为否-false,则可以将下面三个分页参数填入到请求中,继续查询
|
||||
bool finished = 2;
|
||||
// 请求id,出现问题后提供给云厂商,排查问题
|
||||
string request_id = 3;
|
||||
}
|
||||
|
||||
|
||||
message ListPodDetailReq {
|
||||
// 云名称
|
||||
pbtenant.CloudProvider provider = 1;
|
||||
// 账户名称,根据config.yaml中的配置,默认为第一个配置的账户
|
||||
string account_name = 2;
|
||||
// 区域Id,参考 tenant.proto 中的各个云的区域
|
||||
int32 region_id = 3;
|
||||
// podID
|
||||
int32 pod_id = 4;
|
||||
// 分页相关参数,页码
|
||||
int32 page_number = 4;
|
||||
int32 page_number = 5;
|
||||
// 分页相关参数,每页数量
|
||||
int32 page_size = 5;
|
||||
int32 page_size = 6;
|
||||
// 分页相关参数,下一页的token
|
||||
string next_token = 6;
|
||||
// namespace
|
||||
string namespace = 7;
|
||||
string next_token = 7;
|
||||
}
|
||||
|
||||
message ListDetailResp {
|
||||
// pod 容器组集合
|
||||
message ListPodDetailResp {
|
||||
// Pod集合
|
||||
repeated PodInstance pods = 1;
|
||||
// 查询是否完成,如果为否-false,则可以将下面三个分页参数填入到请求中,继续查询
|
||||
bool finished = 2;
|
||||
|
@ -90,76 +109,56 @@ message ListDetailResp {
|
|||
string request_id = 6;
|
||||
}
|
||||
|
||||
message ListReq {
|
||||
message ListPodReq {
|
||||
// 云名称
|
||||
pbtenant.CloudProvider provider = 1;
|
||||
}
|
||||
|
||||
message ListResp {
|
||||
// Pod 容器组集合
|
||||
message ListPodResp {
|
||||
// pod集合
|
||||
repeated PodInstance pods = 1;
|
||||
}
|
||||
|
||||
message CreateReq {
|
||||
// 云名称
|
||||
pbtenant.CloudProvider provider = 1;
|
||||
// 账户名称,根据config.yaml中的配置,默认为第一个配置的账户
|
||||
string account_name = 2;
|
||||
// 区域Id,参考 tenant.proto 中的各个云的区域
|
||||
int32 region_id = 3;
|
||||
// 镜像地址
|
||||
string container_image = 4;
|
||||
// 容器名称
|
||||
string container_name = 5;
|
||||
// 容器实例名称
|
||||
string container_group_name = 6;
|
||||
// vcpu数
|
||||
int32 cpu = 7;
|
||||
// 内存MB
|
||||
int32 memory = 8;
|
||||
// namespace (华为云cci必需)
|
||||
string namespace = 9;
|
||||
// 安全组id(腾讯云eks必需)
|
||||
repeated string security_group_id = 10;
|
||||
//subnet_id 子网id (腾讯云eks必需)
|
||||
repeated string subnet_id = 11;
|
||||
// vpc id (腾讯云eks必需)
|
||||
string vpc_id = 12;
|
||||
}
|
||||
message ListPodAllReq{}
|
||||
|
||||
message CreateRep {
|
||||
repeated string id = 1;
|
||||
string request_id = 2;
|
||||
|
||||
}
|
||||
|
||||
// 容器组类产品接口
|
||||
// Pod类产品接口
|
||||
// 阿里云 - ECI
|
||||
// 腾讯云 - EKS
|
||||
// 腾讯云 - TKS
|
||||
// 华为云 - CCI
|
||||
|
||||
service PodService {
|
||||
|
||||
// 创建pod - 支持云类型、区域
|
||||
rpc CreatePod(CreateReq) returns (CreateRep) {
|
||||
// 创建Pod
|
||||
rpc CreatePod(CreatePodReq) returns (CreatePodResp) {
|
||||
option (google.api.http) = {
|
||||
post : "/apis/pod/create"
|
||||
body : "*"
|
||||
};
|
||||
}
|
||||
|
||||
// 查询Pod明细 - 支持云类型、区域、账户、分页等过滤条件
|
||||
rpc ListPodDetail(ListDetailReq) returns (ListDetailResp) {
|
||||
|
||||
// 查询Pod明细
|
||||
rpc ListPodDetail(ListPodDetailReq) returns (ListPodDetailResp) {
|
||||
option (google.api.http) = {
|
||||
post : "/apis/pod/detail"
|
||||
body : "*"
|
||||
};
|
||||
}
|
||||
|
||||
// 查询pod全量 - 根据云类型
|
||||
rpc ListPod(ListReq) returns (ListResp) {
|
||||
// 查询Pod全量 - 根据云类型
|
||||
rpc ListPod(ListPodReq) returns (ListPodResp) {
|
||||
option (google.api.http) = {
|
||||
post : "/apis/pod"
|
||||
body : "*"
|
||||
};
|
||||
}
|
||||
|
||||
// 查询所有云的Pod
|
||||
rpc ListPodAll(ListPodAllReq) returns (ListPodResp) {
|
||||
option (google.api.http) = {
|
||||
post : "/apis/pod/all"
|
||||
body : "*"
|
||||
};
|
||||
}
|
||||
}
|
|
@ -77,12 +77,13 @@ func RegisterDemoServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux
|
|||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/demo.DemoService/Echo")
|
||||
var err error
|
||||
ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/demo.DemoService/Echo", runtime.WithHTTPPathPattern("/apis/demo"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_DemoService_Echo_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
resp, md, err := local_request_DemoService_Echo_0(ctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
|
@ -139,12 +140,13 @@ func RegisterDemoServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux
|
|||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req, "/demo.DemoService/Echo")
|
||||
var err error
|
||||
ctx, err = runtime.AnnotateContext(ctx, mux, req, "/demo.DemoService/Echo", runtime.WithHTTPPathPattern("/apis/demo"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_DemoService_Echo_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
resp, md, err := request_DemoService_Echo_0(ctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
|
|
|
@ -145,12 +145,13 @@ func RegisterEcsServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux,
|
|||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pbecs.EcsService/ListEcsDetail")
|
||||
var err error
|
||||
ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pbecs.EcsService/ListEcsDetail", runtime.WithHTTPPathPattern("/apis/ecs/detail"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_EcsService_ListEcsDetail_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
resp, md, err := local_request_EcsService_ListEcsDetail_0(ctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
|
@ -168,12 +169,13 @@ func RegisterEcsServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux,
|
|||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pbecs.EcsService/ListEcs")
|
||||
var err error
|
||||
ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pbecs.EcsService/ListEcs", runtime.WithHTTPPathPattern("/apis/ecs"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_EcsService_ListEcs_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
resp, md, err := local_request_EcsService_ListEcs_0(ctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
|
@ -191,12 +193,13 @@ func RegisterEcsServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux,
|
|||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pbecs.EcsService/ListEcsAll")
|
||||
var err error
|
||||
ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pbecs.EcsService/ListEcsAll", runtime.WithHTTPPathPattern("/apis/ecs/all"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_EcsService_ListEcsAll_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
resp, md, err := local_request_EcsService_ListEcsAll_0(ctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
|
@ -253,12 +256,13 @@ func RegisterEcsServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux,
|
|||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req, "/pbecs.EcsService/ListEcsDetail")
|
||||
var err error
|
||||
ctx, err = runtime.AnnotateContext(ctx, mux, req, "/pbecs.EcsService/ListEcsDetail", runtime.WithHTTPPathPattern("/apis/ecs/detail"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_EcsService_ListEcsDetail_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
resp, md, err := request_EcsService_ListEcsDetail_0(ctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
|
@ -273,12 +277,13 @@ func RegisterEcsServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux,
|
|||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req, "/pbecs.EcsService/ListEcs")
|
||||
var err error
|
||||
ctx, err = runtime.AnnotateContext(ctx, mux, req, "/pbecs.EcsService/ListEcs", runtime.WithHTTPPathPattern("/apis/ecs"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_EcsService_ListEcs_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
resp, md, err := request_EcsService_ListEcs_0(ctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
|
@ -293,12 +298,13 @@ func RegisterEcsServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux,
|
|||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req, "/pbecs.EcsService/ListEcsAll")
|
||||
var err error
|
||||
ctx, err = runtime.AnnotateContext(ctx, mux, req, "/pbecs.EcsService/ListEcsAll", runtime.WithHTTPPathPattern("/apis/ecs/all"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_EcsService_ListEcsAll_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
resp, md, err := request_EcsService_ListEcsAll_0(ctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -32,7 +32,7 @@ var _ = utilities.NewDoubleArray
|
|||
var _ = metadata.Join
|
||||
|
||||
func request_PodService_CreatePod_0(ctx context.Context, marshaler runtime.Marshaler, client PodServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq CreateReq
|
||||
var protoReq CreatePodReq
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
|
@ -49,7 +49,7 @@ func request_PodService_CreatePod_0(ctx context.Context, marshaler runtime.Marsh
|
|||
}
|
||||
|
||||
func local_request_PodService_CreatePod_0(ctx context.Context, marshaler runtime.Marshaler, server PodServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq CreateReq
|
||||
var protoReq CreatePodReq
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
|
@ -66,7 +66,7 @@ func local_request_PodService_CreatePod_0(ctx context.Context, marshaler runtime
|
|||
}
|
||||
|
||||
func request_PodService_ListPodDetail_0(ctx context.Context, marshaler runtime.Marshaler, client PodServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq ListDetailReq
|
||||
var protoReq ListPodDetailReq
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
|
@ -83,7 +83,7 @@ func request_PodService_ListPodDetail_0(ctx context.Context, marshaler runtime.M
|
|||
}
|
||||
|
||||
func local_request_PodService_ListPodDetail_0(ctx context.Context, marshaler runtime.Marshaler, server PodServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq ListDetailReq
|
||||
var protoReq ListPodDetailReq
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
|
@ -100,7 +100,7 @@ func local_request_PodService_ListPodDetail_0(ctx context.Context, marshaler run
|
|||
}
|
||||
|
||||
func request_PodService_ListPod_0(ctx context.Context, marshaler runtime.Marshaler, client PodServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq ListReq
|
||||
var protoReq ListPodReq
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
|
@ -117,7 +117,7 @@ func request_PodService_ListPod_0(ctx context.Context, marshaler runtime.Marshal
|
|||
}
|
||||
|
||||
func local_request_PodService_ListPod_0(ctx context.Context, marshaler runtime.Marshaler, server PodServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq ListReq
|
||||
var protoReq ListPodReq
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
|
@ -133,6 +133,40 @@ func local_request_PodService_ListPod_0(ctx context.Context, marshaler runtime.M
|
|||
|
||||
}
|
||||
|
||||
func request_PodService_ListPodAll_0(ctx context.Context, marshaler runtime.Marshaler, client PodServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq ListPodAllReq
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.ListPodAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_PodService_ListPodAll_0(ctx context.Context, marshaler runtime.Marshaler, server PodServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq ListPodAllReq
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.ListPodAll(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
// RegisterPodServiceHandlerServer registers the http handlers for service PodService to "mux".
|
||||
// UnaryRPC :call PodServiceServer directly.
|
||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||
|
@ -145,12 +179,13 @@ func RegisterPodServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux,
|
|||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pbpod.PodService/CreatePod")
|
||||
var err error
|
||||
ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pbpod.PodService/CreatePod", runtime.WithHTTPPathPattern("/apis/pod/create"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_PodService_CreatePod_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
resp, md, err := local_request_PodService_CreatePod_0(ctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
|
@ -168,12 +203,13 @@ func RegisterPodServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux,
|
|||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pbpod.PodService/ListPodDetail")
|
||||
var err error
|
||||
ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pbpod.PodService/ListPodDetail", runtime.WithHTTPPathPattern("/apis/pod/detail"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_PodService_ListPodDetail_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
resp, md, err := local_request_PodService_ListPodDetail_0(ctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
|
@ -191,12 +227,13 @@ func RegisterPodServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux,
|
|||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pbpod.PodService/ListPod")
|
||||
var err error
|
||||
ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pbpod.PodService/ListPod", runtime.WithHTTPPathPattern("/apis/pod"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_PodService_ListPod_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
resp, md, err := local_request_PodService_ListPod_0(ctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
|
@ -208,6 +245,30 @@ func RegisterPodServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux,
|
|||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_PodService_ListPodAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
var err error
|
||||
ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pbpod.PodService/ListPodAll", runtime.WithHTTPPathPattern("/apis/pod/all"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_PodService_ListPodAll_0(ctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_PodService_ListPodAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -253,12 +314,13 @@ func RegisterPodServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux,
|
|||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req, "/pbpod.PodService/CreatePod")
|
||||
var err error
|
||||
ctx, err = runtime.AnnotateContext(ctx, mux, req, "/pbpod.PodService/CreatePod", runtime.WithHTTPPathPattern("/apis/pod/create"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_PodService_CreatePod_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
resp, md, err := request_PodService_CreatePod_0(ctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
|
@ -273,12 +335,13 @@ func RegisterPodServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux,
|
|||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req, "/pbpod.PodService/ListPodDetail")
|
||||
var err error
|
||||
ctx, err = runtime.AnnotateContext(ctx, mux, req, "/pbpod.PodService/ListPodDetail", runtime.WithHTTPPathPattern("/apis/pod/detail"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_PodService_ListPodDetail_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
resp, md, err := request_PodService_ListPodDetail_0(ctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
|
@ -293,12 +356,13 @@ func RegisterPodServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux,
|
|||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req, "/pbpod.PodService/ListPod")
|
||||
var err error
|
||||
ctx, err = runtime.AnnotateContext(ctx, mux, req, "/pbpod.PodService/ListPod", runtime.WithHTTPPathPattern("/apis/pod"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_PodService_ListPod_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
resp, md, err := request_PodService_ListPod_0(ctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
|
@ -309,6 +373,27 @@ func RegisterPodServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux,
|
|||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_PodService_ListPodAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
var err error
|
||||
ctx, err = runtime.AnnotateContext(ctx, mux, req, "/pbpod.PodService/ListPodAll", runtime.WithHTTPPathPattern("/apis/pod/all"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_PodService_ListPodAll_0(ctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_PodService_ListPodAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -318,6 +403,8 @@ var (
|
|||
pattern_PodService_ListPodDetail_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"apis", "pod", "detail"}, ""))
|
||||
|
||||
pattern_PodService_ListPod_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"apis", "pod"}, ""))
|
||||
|
||||
pattern_PodService_ListPodAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"apis", "pod", "all"}, ""))
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -326,4 +413,6 @@ var (
|
|||
forward_PodService_ListPodDetail_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_PodService_ListPod_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_PodService_ListPodAll_0 = runtime.ForwardResponseMessage
|
||||
)
|
||||
|
|
|
@ -22,12 +22,14 @@ const _ = grpc.SupportPackageIsVersion7
|
|||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type PodServiceClient interface {
|
||||
// 创建pod - 支持云类型、区域
|
||||
CreatePod(ctx context.Context, in *CreateReq, opts ...grpc.CallOption) (*CreateRep, error)
|
||||
// 查询Pod明细 - 支持云类型、区域、账户、分页等过滤条件
|
||||
ListPodDetail(ctx context.Context, in *ListDetailReq, opts ...grpc.CallOption) (*ListDetailResp, error)
|
||||
// 查询pod全量 - 根据云类型
|
||||
ListPod(ctx context.Context, in *ListReq, opts ...grpc.CallOption) (*ListResp, error)
|
||||
// 创建Pod
|
||||
CreatePod(ctx context.Context, in *CreatePodReq, opts ...grpc.CallOption) (*CreatePodResp, error)
|
||||
// 查询Pod明细
|
||||
ListPodDetail(ctx context.Context, in *ListPodDetailReq, opts ...grpc.CallOption) (*ListPodDetailResp, error)
|
||||
// 查询Pod全量 - 根据云类型
|
||||
ListPod(ctx context.Context, in *ListPodReq, opts ...grpc.CallOption) (*ListPodResp, error)
|
||||
// 查询所有云的Pod
|
||||
ListPodAll(ctx context.Context, in *ListPodAllReq, opts ...grpc.CallOption) (*ListPodResp, error)
|
||||
}
|
||||
|
||||
type podServiceClient struct {
|
||||
|
@ -38,8 +40,8 @@ func NewPodServiceClient(cc grpc.ClientConnInterface) PodServiceClient {
|
|||
return &podServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *podServiceClient) CreatePod(ctx context.Context, in *CreateReq, opts ...grpc.CallOption) (*CreateRep, error) {
|
||||
out := new(CreateRep)
|
||||
func (c *podServiceClient) CreatePod(ctx context.Context, in *CreatePodReq, opts ...grpc.CallOption) (*CreatePodResp, error) {
|
||||
out := new(CreatePodResp)
|
||||
err := c.cc.Invoke(ctx, "/pbpod.PodService/CreatePod", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -47,8 +49,8 @@ func (c *podServiceClient) CreatePod(ctx context.Context, in *CreateReq, opts ..
|
|||
return out, nil
|
||||
}
|
||||
|
||||
func (c *podServiceClient) ListPodDetail(ctx context.Context, in *ListDetailReq, opts ...grpc.CallOption) (*ListDetailResp, error) {
|
||||
out := new(ListDetailResp)
|
||||
func (c *podServiceClient) ListPodDetail(ctx context.Context, in *ListPodDetailReq, opts ...grpc.CallOption) (*ListPodDetailResp, error) {
|
||||
out := new(ListPodDetailResp)
|
||||
err := c.cc.Invoke(ctx, "/pbpod.PodService/ListPodDetail", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -56,8 +58,8 @@ func (c *podServiceClient) ListPodDetail(ctx context.Context, in *ListDetailReq,
|
|||
return out, nil
|
||||
}
|
||||
|
||||
func (c *podServiceClient) ListPod(ctx context.Context, in *ListReq, opts ...grpc.CallOption) (*ListResp, error) {
|
||||
out := new(ListResp)
|
||||
func (c *podServiceClient) ListPod(ctx context.Context, in *ListPodReq, opts ...grpc.CallOption) (*ListPodResp, error) {
|
||||
out := new(ListPodResp)
|
||||
err := c.cc.Invoke(ctx, "/pbpod.PodService/ListPod", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -65,16 +67,27 @@ func (c *podServiceClient) ListPod(ctx context.Context, in *ListReq, opts ...grp
|
|||
return out, nil
|
||||
}
|
||||
|
||||
func (c *podServiceClient) ListPodAll(ctx context.Context, in *ListPodAllReq, opts ...grpc.CallOption) (*ListPodResp, error) {
|
||||
out := new(ListPodResp)
|
||||
err := c.cc.Invoke(ctx, "/pbpod.PodService/ListPodAll", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// PodServiceServer is the server API for PodService service.
|
||||
// All implementations must embed UnimplementedPodServiceServer
|
||||
// for forward compatibility
|
||||
type PodServiceServer interface {
|
||||
// 创建pod - 支持云类型、区域
|
||||
CreatePod(context.Context, *CreateReq) (*CreateRep, error)
|
||||
// 查询Pod明细 - 支持云类型、区域、账户、分页等过滤条件
|
||||
ListPodDetail(context.Context, *ListDetailReq) (*ListDetailResp, error)
|
||||
// 查询pod全量 - 根据云类型
|
||||
ListPod(context.Context, *ListReq) (*ListResp, error)
|
||||
// 创建Pod
|
||||
CreatePod(context.Context, *CreatePodReq) (*CreatePodResp, error)
|
||||
// 查询Pod明细
|
||||
ListPodDetail(context.Context, *ListPodDetailReq) (*ListPodDetailResp, error)
|
||||
// 查询Pod全量 - 根据云类型
|
||||
ListPod(context.Context, *ListPodReq) (*ListPodResp, error)
|
||||
// 查询所有云的Pod
|
||||
ListPodAll(context.Context, *ListPodAllReq) (*ListPodResp, error)
|
||||
mustEmbedUnimplementedPodServiceServer()
|
||||
}
|
||||
|
||||
|
@ -82,15 +95,18 @@ type PodServiceServer interface {
|
|||
type UnimplementedPodServiceServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedPodServiceServer) CreatePod(context.Context, *CreateReq) (*CreateRep, error) {
|
||||
func (UnimplementedPodServiceServer) CreatePod(context.Context, *CreatePodReq) (*CreatePodResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CreatePod not implemented")
|
||||
}
|
||||
func (UnimplementedPodServiceServer) ListPodDetail(context.Context, *ListDetailReq) (*ListDetailResp, error) {
|
||||
func (UnimplementedPodServiceServer) ListPodDetail(context.Context, *ListPodDetailReq) (*ListPodDetailResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ListPodDetail not implemented")
|
||||
}
|
||||
func (UnimplementedPodServiceServer) ListPod(context.Context, *ListReq) (*ListResp, error) {
|
||||
func (UnimplementedPodServiceServer) ListPod(context.Context, *ListPodReq) (*ListPodResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ListPod not implemented")
|
||||
}
|
||||
func (UnimplementedPodServiceServer) ListPodAll(context.Context, *ListPodAllReq) (*ListPodResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ListPodAll not implemented")
|
||||
}
|
||||
func (UnimplementedPodServiceServer) mustEmbedUnimplementedPodServiceServer() {}
|
||||
|
||||
// UnsafePodServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
|
@ -105,7 +121,7 @@ func RegisterPodServiceServer(s grpc.ServiceRegistrar, srv PodServiceServer) {
|
|||
}
|
||||
|
||||
func _PodService_CreatePod_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CreateReq)
|
||||
in := new(CreatePodReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -117,13 +133,13 @@ func _PodService_CreatePod_Handler(srv interface{}, ctx context.Context, dec fun
|
|||
FullMethod: "/pbpod.PodService/CreatePod",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(PodServiceServer).CreatePod(ctx, req.(*CreateReq))
|
||||
return srv.(PodServiceServer).CreatePod(ctx, req.(*CreatePodReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _PodService_ListPodDetail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListDetailReq)
|
||||
in := new(ListPodDetailReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -135,13 +151,13 @@ func _PodService_ListPodDetail_Handler(srv interface{}, ctx context.Context, dec
|
|||
FullMethod: "/pbpod.PodService/ListPodDetail",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(PodServiceServer).ListPodDetail(ctx, req.(*ListDetailReq))
|
||||
return srv.(PodServiceServer).ListPodDetail(ctx, req.(*ListPodDetailReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _PodService_ListPod_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListReq)
|
||||
in := new(ListPodReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -153,7 +169,25 @@ func _PodService_ListPod_Handler(srv interface{}, ctx context.Context, dec func(
|
|||
FullMethod: "/pbpod.PodService/ListPod",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(PodServiceServer).ListPod(ctx, req.(*ListReq))
|
||||
return srv.(PodServiceServer).ListPod(ctx, req.(*ListPodReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _PodService_ListPodAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListPodAllReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(PodServiceServer).ListPodAll(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/pbpod.PodService/ListPodAll",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(PodServiceServer).ListPodAll(ctx, req.(*ListPodAllReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
@ -177,6 +211,10 @@ var PodService_ServiceDesc = grpc.ServiceDesc{
|
|||
MethodName: "ListPod",
|
||||
Handler: _PodService_ListPod_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListPodAll",
|
||||
Handler: _PodService_ListPodAll_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "idl/pbpod/pod.proto",
|
||||
|
|
|
@ -68,14 +68,11 @@
|
|||
"protobufAny": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"typeUrl": {
|
||||
"@type": {
|
||||
"type": "string"
|
||||
},
|
||||
"value": {
|
||||
"type": "string",
|
||||
"format": "byte"
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties": {}
|
||||
},
|
||||
"rpcStatus": {
|
||||
"type": "object",
|
||||
|
|
|
@ -186,7 +186,7 @@
|
|||
},
|
||||
"vpcId": {
|
||||
"type": "string",
|
||||
"title": "vpc id"
|
||||
"title": "vcp id"
|
||||
},
|
||||
"resourceGroupId": {
|
||||
"type": "string",
|
||||
|
@ -303,14 +303,11 @@
|
|||
"protobufAny": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"typeUrl": {
|
||||
"@type": {
|
||||
"type": "string"
|
||||
},
|
||||
"value": {
|
||||
"type": "string",
|
||||
"format": "byte"
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties": {}
|
||||
},
|
||||
"rpcStatus": {
|
||||
"type": "object",
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
"paths": {
|
||||
"/apis/pod": {
|
||||
"post": {
|
||||
"summary": "查询pod全量 - 根据云类型",
|
||||
"summary": "查询Pod全量 - 根据云类型",
|
||||
"operationId": "PodService_ListPod",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/pbpodListResp"
|
||||
"$ref": "#/definitions/pbpodListPodResp"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
|
@ -40,7 +40,40 @@
|
|||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/pbpodListReq"
|
||||
"$ref": "#/definitions/pbpodListPodReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"PodService"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/apis/pod/all": {
|
||||
"post": {
|
||||
"summary": "查询所有云的Pod",
|
||||
"operationId": "PodService_ListPodAll",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/pbpodListPodResp"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "An unexpected error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/rpcStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/pbpodListPodAllReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
@ -51,13 +84,13 @@
|
|||
},
|
||||
"/apis/pod/create": {
|
||||
"post": {
|
||||
"summary": "创建pod - 支持云类型、区域",
|
||||
"summary": "创建Pod",
|
||||
"operationId": "PodService_CreatePod",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/pbpodCreateRep"
|
||||
"$ref": "#/definitions/pbpodCreatePodResp"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
|
@ -73,7 +106,7 @@
|
|||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/pbpodCreateReq"
|
||||
"$ref": "#/definitions/pbpodCreatePodReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
@ -84,13 +117,13 @@
|
|||
},
|
||||
"/apis/pod/detail": {
|
||||
"post": {
|
||||
"summary": "查询Pod明细 - 支持云类型、区域、账户、分页等过滤条件",
|
||||
"summary": "查询Pod明细",
|
||||
"operationId": "PodService_ListPodDetail",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/pbpodListDetailResp"
|
||||
"$ref": "#/definitions/pbpodListPodDetailResp"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
|
@ -106,7 +139,7 @@
|
|||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/pbpodListDetailReq"
|
||||
"$ref": "#/definitions/pbpodListPodDetailReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
@ -117,111 +150,90 @@
|
|||
}
|
||||
},
|
||||
"definitions": {
|
||||
"pbpodContainer": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"image": {
|
||||
"type": "string",
|
||||
"title": "容器镜像"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"title": "容器名称"
|
||||
},
|
||||
"cpu": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"title": "vcpu数"
|
||||
},
|
||||
"memory": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"title": "内存MB"
|
||||
},
|
||||
"restartCount": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"title": "重启次数"
|
||||
}
|
||||
}
|
||||
},
|
||||
"pbpodCreateRep": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"requestId": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"pbpodCreateReq": {
|
||||
"pbpodCreatePodReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"provider": {
|
||||
"$ref": "#/definitions/pbtenantCloudProvider",
|
||||
"title": "云名称"
|
||||
"title": "云类型"
|
||||
},
|
||||
"accountName": {
|
||||
"type": "string",
|
||||
"title": "账户名称,根据config.yaml中的配置,默认为第一个配置的账户"
|
||||
"title": "账号名称"
|
||||
},
|
||||
"podId": {
|
||||
"type": "string",
|
||||
"title": "实例id"
|
||||
},
|
||||
"podName": {
|
||||
"type": "string",
|
||||
"title": "实例名称"
|
||||
},
|
||||
"regionId": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"title": "区域Id,参考 tenant.proto 中的各个云的区域"
|
||||
"title": "地域,数据中心"
|
||||
},
|
||||
"containerImage": {
|
||||
"type": "string",
|
||||
"title": "镜像地址"
|
||||
"title": "镜像"
|
||||
},
|
||||
"containerName": {
|
||||
"type": "string",
|
||||
"title": "容器名称"
|
||||
},
|
||||
"containerGroupName": {
|
||||
"type": "string",
|
||||
"title": "容器实例名称"
|
||||
"cpuPod": {
|
||||
"type": "number",
|
||||
"format": "float",
|
||||
"title": "v cpu数"
|
||||
},
|
||||
"cpu": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"title": "vcpu数"
|
||||
},
|
||||
"memory": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"memoryPod": {
|
||||
"type": "number",
|
||||
"format": "float",
|
||||
"title": "内存MB"
|
||||
},
|
||||
"namespace": {
|
||||
"type": "string",
|
||||
"title": "namespace (华为云cci必需)"
|
||||
},
|
||||
"securityGroupId": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"title": "安全组id(腾讯云eks必需)"
|
||||
"type": "string",
|
||||
"title": "安全组ID 对应腾讯 SecurityGroupIds(腾讯必需)"
|
||||
},
|
||||
"subnetId": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"title": "subnet_id 子网id (腾讯云eks必需)"
|
||||
"type": "string",
|
||||
"title": "子网ID 对应腾讯 SubnetId(腾讯必需)"
|
||||
},
|
||||
"vpcId": {
|
||||
"type": "string",
|
||||
"title": "vpc id (腾讯云eks必需)"
|
||||
"title": "VPC ID 对应腾讯 VpcId(腾讯必需)"
|
||||
},
|
||||
"namespace": {
|
||||
"type": "string",
|
||||
"title": "名空间"
|
||||
}
|
||||
}
|
||||
},
|
||||
"pbpodListDetailReq": {
|
||||
"pbpodCreatePodResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"pods": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/pbpodPodInstance"
|
||||
},
|
||||
"title": "Pod集合"
|
||||
},
|
||||
"finished": {
|
||||
"type": "boolean",
|
||||
"title": "查询是否完成,如果为否-false,则可以将下面三个分页参数填入到请求中,继续查询"
|
||||
},
|
||||
"requestId": {
|
||||
"type": "string",
|
||||
"title": "请求id,出现问题后提供给云厂商,排查问题"
|
||||
}
|
||||
}
|
||||
},
|
||||
"pbpodListPodAllReq": {
|
||||
"type": "object"
|
||||
},
|
||||
"pbpodListPodDetailReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"provider": {
|
||||
|
@ -237,6 +249,11 @@
|
|||
"format": "int32",
|
||||
"title": "区域Id,参考 tenant.proto 中的各个云的区域"
|
||||
},
|
||||
"podId": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"title": "podID"
|
||||
},
|
||||
"pageNumber": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
|
@ -250,14 +267,10 @@
|
|||
"nextToken": {
|
||||
"type": "string",
|
||||
"title": "分页相关参数,下一页的token"
|
||||
},
|
||||
"namespace": {
|
||||
"type": "string",
|
||||
"title": "namespace"
|
||||
}
|
||||
}
|
||||
},
|
||||
"pbpodListDetailResp": {
|
||||
"pbpodListPodDetailResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"pods": {
|
||||
|
@ -265,7 +278,7 @@
|
|||
"items": {
|
||||
"$ref": "#/definitions/pbpodPodInstance"
|
||||
},
|
||||
"title": "pod 容器组集合"
|
||||
"title": "Pod集合"
|
||||
},
|
||||
"finished": {
|
||||
"type": "boolean",
|
||||
|
@ -291,7 +304,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"pbpodListReq": {
|
||||
"pbpodListPodReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"provider": {
|
||||
|
@ -300,7 +313,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"pbpodListResp": {
|
||||
"pbpodListPodResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"pods": {
|
||||
|
@ -308,7 +321,7 @@
|
|||
"items": {
|
||||
"$ref": "#/definitions/pbpodPodInstance"
|
||||
},
|
||||
"title": "Pod 容器组集合"
|
||||
"title": "pod集合"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -323,74 +336,52 @@
|
|||
"type": "string",
|
||||
"title": "账号名称"
|
||||
},
|
||||
"instanceId": {
|
||||
"podId": {
|
||||
"type": "string",
|
||||
"title": "实例id"
|
||||
},
|
||||
"instanceName": {
|
||||
"podName": {
|
||||
"type": "string",
|
||||
"title": "实例名称"
|
||||
},
|
||||
"regionName": {
|
||||
"type": "string",
|
||||
"regionId": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"title": "地域,数据中心"
|
||||
},
|
||||
"publicIps": {
|
||||
"containerImage": {
|
||||
"type": "string",
|
||||
"title": "公网ip"
|
||||
"title": "镜像"
|
||||
},
|
||||
"instanceType": {
|
||||
"containerName": {
|
||||
"type": "string",
|
||||
"title": "实例类型"
|
||||
"title": "容器名称"
|
||||
},
|
||||
"cpu": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"cpuPod": {
|
||||
"type": "number",
|
||||
"format": "float",
|
||||
"title": "vcpu数"
|
||||
},
|
||||
"memory": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"memoryPod": {
|
||||
"type": "number",
|
||||
"format": "float",
|
||||
"title": "内存MB"
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"title": "实例描述"
|
||||
},
|
||||
"status": {
|
||||
"type": "string",
|
||||
"title": "状态"
|
||||
},
|
||||
"creationTime": {
|
||||
"type": "string",
|
||||
"title": "创建时间,ISO8601"
|
||||
},
|
||||
"expireTime": {
|
||||
"type": "string",
|
||||
"title": "过期时间"
|
||||
},
|
||||
"innerIps": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"title": "内网ip"
|
||||
},
|
||||
"vpcId": {
|
||||
"type": "string",
|
||||
"title": "vpc id"
|
||||
},
|
||||
"securityGroupId": {
|
||||
"type": "string",
|
||||
"title": "安全组id"
|
||||
"title": "安全组ID 对应腾讯 SecurityGroupIds(腾讯必需)"
|
||||
},
|
||||
"SubnetId": {
|
||||
"subnetId": {
|
||||
"type": "string",
|
||||
"title": "子网Id"
|
||||
"title": "子网ID 对应腾讯 SubnetId(腾讯必需)"
|
||||
},
|
||||
"Container": {
|
||||
"$ref": "#/definitions/pbpodContainer",
|
||||
"title": "容器实例"
|
||||
"vpcId": {
|
||||
"type": "string",
|
||||
"title": "VPC ID 对应腾讯 VpcId(腾讯必需)"
|
||||
},
|
||||
"namespace": {
|
||||
"type": "string",
|
||||
"title": "名空间"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -409,14 +400,11 @@
|
|||
"protobufAny": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"typeUrl": {
|
||||
"@type": {
|
||||
"type": "string"
|
||||
},
|
||||
"value": {
|
||||
"type": "string",
|
||||
"format": "byte"
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties": {}
|
||||
},
|
||||
"rpcStatus": {
|
||||
"type": "object",
|
||||
|
|
|
@ -15,14 +15,11 @@
|
|||
"protobufAny": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"typeUrl": {
|
||||
"@type": {
|
||||
"type": "string"
|
||||
},
|
||||
"value": {
|
||||
"type": "string",
|
||||
"format": "byte"
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties": {}
|
||||
},
|
||||
"rpcStatus": {
|
||||
"type": "object",
|
||||
|
|
12
main.go
12
main.go
|
@ -3,17 +3,17 @@ package main
|
|||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"gitlink.org.cn/JCCE/PCM/common/server"
|
||||
"gitlink.org.cn/JCCE/PCM/common/tenanter"
|
||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/demo"
|
||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs"
|
||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod"
|
||||
"net"
|
||||
"net/http"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"github.com/pkg/errors"
|
||||
"gitlink.org.cn/JCCE/PCM/common/server"
|
||||
"gitlink.org.cn/JCCE/PCM/common/tenanter"
|
||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/demo"
|
||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs"
|
||||
"gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
|
@ -37,7 +37,7 @@ func run() error {
|
|||
} else if err = pbecs.RegisterEcsServiceHandlerFromEndpoint(ctx, mux, *grpcServerEndpoint, opts); err != nil {
|
||||
return errors.Wrap(err, "RegisterEcsServiceHandlerFromEndpoint error")
|
||||
} else if err = pbpod.RegisterPodServiceHandlerFromEndpoint(ctx, mux, *grpcServerEndpoint, opts); err != nil {
|
||||
return errors.Wrap(err, "RegisterPoderviceHandlerFromEndpoint error")
|
||||
return errors.Wrap(err, "RegisterPodServiceHandlerFromEndpoint error")
|
||||
}
|
||||
|
||||
// Start HTTP server (and proxy calls to gRPC server endpoint)
|
||||
|
|
Loading…
Reference in New Issue