client

package
v1.67.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PodClient

type PodClient struct {
	core.JDCloudClient
}

func NewPodClient

func NewPodClient(credential *core.Credential) *PodClient

func (*PodClient) AssociateElasticIp

func (c *PodClient) AssociateElasticIp(request *pod.AssociateElasticIpRequest) (*pod.AssociateElasticIpResponse, error)
pod 绑定弹性公网 IP,绑定的是主网卡、主内网IP对应的弹性IP. <br>

一个 pod 只能绑定一个弹性公网 IP(主网卡),若主网卡已存在弹性公网IP,会返回错误。<br> 如果是黑名单中的用户,会返回错误。

func (*PodClient) Attach

func (c *PodClient) Attach(request *pod.AttachRequest) (*pod.AttachResponse, error)

将容器连接到本地标准输入输出

func (*PodClient) CheckPodName

func (c *PodClient) CheckPodName(request *pod.CheckPodNameRequest) (*pod.CheckPodNameResponse, error)

podName 是否符合命名规范,以及查询指定 podName 区域内是否已经存在。

func (*PodClient) CreateConfigFile added in v1.56.0

func (c *PodClient) CreateConfigFile(request *pod.CreateConfigFileRequest) (*pod.CreateConfigFileResponse, error)

创建一个 configFile,存放文件内容(键值对)。

func (*PodClient) CreateImageCache added in v1.63.0

func (c *PodClient) CreateImageCache(request *pod.CreateImageCacheRequest) (*pod.CreateImageCacheResponse, error)
创建一个镜像缓存信息。镜像缓存加速是将镜像预先拉取到一个云盘中并制作为云盘快照,

用户在创建Pod/NC时,若使用的镜像已经有镜像缓存,则可以直接基于该镜像缓存对应的快照制作云盘,并挂载为该容器的系统盘,避免重复拉取镜像并加快创建速度。

func (*PodClient) CreateImageCaches added in v1.63.0

func (c *PodClient) CreateImageCaches(request *pod.CreateImageCachesRequest) (*pod.CreateImageCachesResponse, error)

批量创建镜像缓存。

func (*PodClient) CreatePodTemplate added in v1.63.0

func (c *PodClient) CreatePodTemplate(request *pod.CreatePodTemplateRequest) (*pod.CreatePodTemplateResponse, error)

创建Pod模板

func (*PodClient) CreatePods

func (c *PodClient) CreatePods(request *pod.CreatePodsRequest) (*pod.CreatePodsResponse, error)
创建一台或多台 pod

- 创建pod需要通过实名认证 - 可用区

  • Pod所属的可用区
  • 创建Pod,需要使用中心可用区的相关资源:
  • 具有中心可用区属性的子网
  • 公网IP服务商

- hostname规范

  • 支持两种方式:以标签方式书写或以完整主机名方式书写
  • 标签规范
  • 0-9,a-z(不分大小写)和-(减号),其他的都是无效的字符串
  • 不能以减号开始,也不能以减号结尾
  • 最小1个字符,最大63个字符
  • 完整的主机名由一系列标签与点连接组成
  • 标签与标签之间使用“.”(点)进行连接
  • 不能以“.”(点)开始,也不能以“.”(点)结尾
  • 整个主机名(包括标签以及分隔点“.”)最多有63个ASCII字符

- 网络配置

  • 指定主网卡配置信息
  • 必须指定subnetId
  • 可以指定elasticIp规格来约束创建的弹性IP,带宽取值范围[1-100]Mbps,步进1Mbps
  • 可以指定网卡的主IP(primaryIpAddress)和辅助IP(secondaryIpAddresses),此时maxCount只能为1
  • 可以设置网卡的自动删除autoDelete属性,指明是否删除实例时自动删除网卡
  • 安全组securityGroup需与子网Subnet在同一个私有网络VPC内
  • 一个 pod 创建时至多指定5个安全组
  • 主网卡deviceIndex设置为1

- 存储

  • volume分为container system disk和pod data volume,container system disk的挂载目录是/,data volume的挂载目录可以随意指定
  • container system disk
  • 支持cloud和local
  • 云硬盘类型可以选择hdd.std1、ssd.gp1、ssd.io1
  • 磁盘大小
  • 所有类型:范围[20,100]GB,步长为10G
  • 自动删除
  • 默认自动删除
  • 可以选择已存在的云硬盘
  • data volume -cloudDisk
  • 云硬盘类型可以选择hdd.std1、ssd.gp1、ssd.io1
  • 磁盘大小
  • 所有类型:范围[20,2000]GB,步长为10G
  • 自动删除
  • 默认自动删除
  • 可以选择已存在的云硬盘
  • 可以从快照创建磁盘 -CFS
  • 从zbs去获取数据,挂载到当前的volume -configFile
  • 提前创建好configFile相关数据,然后挂载到volume

- pod 容器日志

  • default:默认在本地分配10MB的存储空间,自动rotate

- DNS-1123 label规范

  • 支持数字、小写字母、英文中划线“-”,但不支持以“-”作为开始字符和结束字符,1~63字符。
  • 例子: my-name, 123-abc

- DNS-1123 subdomain规范

  • 由一或多个标签组成,标签之间用'.'分隔;标签可由小写字母、数字、英文中划线'-'构成,标签首尾不可为'-';所有字符总长度为1~253。
  • 例子: example.com, registry.docker-cn.com

- 其他

  • 创建完成后,pod 状态为running
  • maxCount为最大努力,不保证一定能达到maxCount

func (*PodClient) CreateSecret

func (c *PodClient) CreateSecret(request *pod.CreateSecretRequest) (*pod.CreateSecretResponse, error)

创建一个 secret,用于存放镜像仓库机密相关信息。

func (*PodClient) DeleteConfigFile added in v1.56.0

func (c *PodClient) DeleteConfigFile(request *pod.DeleteConfigFileRequest) (*pod.DeleteConfigFileResponse, error)

删除单个 configFile

func (*PodClient) DeleteImageCache added in v1.63.0

func (c *PodClient) DeleteImageCache(request *pod.DeleteImageCacheRequest) (*pod.DeleteImageCacheResponse, error)

删除镜像缓存,镜像缓存状态必须为Ready或Error状态。

func (*PodClient) DeletePod

func (c *PodClient) DeletePod(request *pod.DeletePodRequest) (*pod.DeletePodResponse, error)
pod 状态必须为 stopped、running 或 error状态。 <br>

按量付费的实例,如不主动删除将一直运行,不再使用的实例,可通过本接口主动停用。<br> 只能支持主动删除按量计费类型的实例。包年包月过期的 pod 也可以删除,其它的情况还请发工单系统。计费状态异常的容器无法删除。

[MFA enabled]

func (*PodClient) DeletePodTemplate added in v1.63.0

func (c *PodClient) DeletePodTemplate(request *pod.DeletePodTemplateRequest) (*pod.DeletePodTemplateResponse, error)

删除单个pod模板

func (*PodClient) DeleteSecret

func (c *PodClient) DeleteSecret(request *pod.DeleteSecretRequest) (*pod.DeleteSecretResponse, error)

删除单个 secret

func (*PodClient) DescribeConfigFile added in v1.56.0

func (c *PodClient) DescribeConfigFile(request *pod.DescribeConfigFileRequest) (*pod.DescribeConfigFileResponse, error)

查询单个 configFile 详情

func (*PodClient) DescribeContainer added in v1.11.0

func (c *PodClient) DescribeContainer(request *pod.DescribeContainerRequest) (*pod.DescribeContainerResponse, error)

获取 pod 中某个容器的详情

func (*PodClient) DescribeImageCache added in v1.63.0

func (c *PodClient) DescribeImageCache(request *pod.DescribeImageCacheRequest) (*pod.DescribeImageCacheResponse, error)

查询镜像缓存的详细信息

func (*PodClient) DescribeImageCaches added in v1.63.0

func (c *PodClient) DescribeImageCaches(request *pod.DescribeImageCachesRequest) (*pod.DescribeImageCachesResponse, error)

批量查询镜像缓存。支持分页查询,默认每页20条。

func (*PodClient) DescribeInstanceTypes added in v1.11.0

func (c *PodClient) DescribeInstanceTypes(request *pod.DescribeInstanceTypesRequest) (*pod.DescribeInstanceTypesResponse, error)

查询实例规格信息列表

func (*PodClient) DescribePod

func (c *PodClient) DescribePod(request *pod.DescribePodRequest) (*pod.DescribePodResponse, error)

查询一个 pod 的详细信息

func (*PodClient) DescribePodTemplate added in v1.63.0

func (c *PodClient) DescribePodTemplate(request *pod.DescribePodTemplateRequest) (*pod.DescribePodTemplateResponse, error)

查询Pod模板的详细信息

func (*PodClient) DescribePodTemplates added in v1.63.0

func (c *PodClient) DescribePodTemplates(request *pod.DescribePodTemplatesRequest) (*pod.DescribePodTemplatesResponse, error)

批量查询Pod模板。支持分页查询,默认每页20条。

func (*PodClient) DescribePods

func (c *PodClient) DescribePods(request *pod.DescribePodsRequest) (*pod.DescribePodsResponse, error)
批量查询 pod 的详细信息<br>

此接口支持分页查询,默认每页20条。

func (*PodClient) DescribePodsStatus added in v1.63.0

func (c *PodClient) DescribePodsStatus(request *pod.DescribePodsStatusRequest) (*pod.DescribePodsStatusResponse, error)
批量查询 pod 的状态信息<br>

此接口支持分页查询,默认每页20条。

func (*PodClient) DescribeQuota

func (c *PodClient) DescribeQuota(request *pod.DescribeQuotaRequest) (*pod.DescribeQuotaResponse, error)

查询资源的配额,支持:原生容器,pod,secret,镜像缓存,Pod模板

func (*PodClient) DescribeSecret

func (c *PodClient) DescribeSecret(request *pod.DescribeSecretRequest) (*pod.DescribeSecretResponse, error)

查询单个 secret 详情

func (*PodClient) DescribeSecrets

func (c *PodClient) DescribeSecrets(request *pod.DescribeSecretsRequest) (*pod.DescribeSecretsResponse, error)
查询 secret 列表。<br>

此接口支持分页查询,默认每页20条。

func (*PodClient) DisableLogger added in v1.13.0

func (c *PodClient) DisableLogger()

func (*PodClient) DisassociateElasticIp

func (c *PodClient) DisassociateElasticIp(request *pod.DisassociateElasticIpRequest) (*pod.DisassociateElasticIpResponse, error)

pod 解绑公网 IP,解绑的是主网卡、主内网 IP 对应的弹性 IP.

func (*PodClient) ExecCreate

func (c *PodClient) ExecCreate(request *pod.ExecCreateRequest) (*pod.ExecCreateResponse, error)

创建 exec

func (*PodClient) ExecGetExitCode

func (c *PodClient) ExecGetExitCode(request *pod.ExecGetExitCodeRequest) (*pod.ExecGetExitCodeResponse, error)

获取exec退出码

func (*PodClient) ExecStart

func (c *PodClient) ExecStart(request *pod.ExecStartRequest) (*pod.ExecStartResponse, error)

执行exec,此接口需要升级Http协议到WebSocket

func (*PodClient) GetContainerLogs

func (c *PodClient) GetContainerLogs(request *pod.GetContainerLogsRequest) (*pod.GetContainerLogsResponse, error)

查询单个容器日志

func (*PodClient) GetMostSuitableImageCache added in v1.63.0

func (c *PodClient) GetMostSuitableImageCache(request *pod.GetMostSuitableImageCacheRequest) (*pod.GetMostSuitableImageCacheResponse, error)

根据镜像信息匹配镜像缓存,根据镜像缓存的体积(体积小的优先)和创建时间(创建时间晚的优先)进行匹配

func (*PodClient) ModifyPodAttribute

func (c *PodClient) ModifyPodAttribute(request *pod.ModifyPodAttributeRequest) (*pod.ModifyPodAttributeResponse, error)

修改 pod 的描述。

func (*PodClient) RebuildPod added in v1.10.0

func (c *PodClient) RebuildPod(request *pod.RebuildPodRequest) (*pod.RebuildPodResponse, error)

对 pod 中的容器使用新的镜像进行重置,pod 需要处于关闭状态。

func (*PodClient) ResizePod added in v1.13.0

func (c *PodClient) ResizePod(request *pod.ResizePodRequest) (*pod.ResizePodResponse, error)
调整pod实例类型配置。

- pod phase 需是停止状态; - 支持升配、降配;**不支持原有规格** - 计费类型不变

  • 包年包月:需要计算配置差价,如果所选配置价格高,需要补齐到期前的差价,到期时间不变;如果所选配置价格低,需要延长到期时间
  • 按配置:按照所选规格,进行计费

- 支持对 pod 中的容器进行资源限制、资源需求的调整

  • 容器需求的总资源占用不得超过 pod 的实例类型
  • 容器资源限制不得超过 pod 的实例类型

func (*PodClient) ResizeTTY

func (c *PodClient) ResizeTTY(request *pod.ResizeTTYRequest) (*pod.ResizeTTYResponse, error)

设置TTY大小

func (*PodClient) SetConfig

func (c *PodClient) SetConfig(config *core.Config)

func (*PodClient) SetLogger

func (c *PodClient) SetLogger(logger core.Logger)

func (*PodClient) StartPod

func (c *PodClient) StartPod(request *pod.StartPodRequest) (*pod.StartPodResponse, error)
启动处于关闭状态的单个 pod ,处在任务执行中的 pod 无法启动。<br>

pod 实例或其绑定的云盘已欠费时,容器将无法正常启动。<br>

func (*PodClient) StopPod

func (c *PodClient) StopPod(request *pod.StopPodRequest) (*pod.StopPodResponse, error)

停止处于运行状态的单个实例,处于任务执行中的 pod 无法启动。

func (*PodClient) UpdateConfigFile added in v1.56.0

func (c *PodClient) UpdateConfigFile(request *pod.UpdateConfigFileRequest) (*pod.UpdateConfigFileResponse, error)

更新configFile信息

func (*PodClient) UpdateImageCache added in v1.63.0

func (c *PodClient) UpdateImageCache(request *pod.UpdateImageCacheRequest) (*pod.UpdateImageCacheResponse, error)

修改镜像缓存的属性。

func (*PodClient) UpdatePodTemplate added in v1.63.0

func (c *PodClient) UpdatePodTemplate(request *pod.UpdatePodTemplateRequest) (*pod.UpdatePodTemplateResponse, error)

修改Pod模板的配置

func (*PodClient) VerifyPodTemplate added in v1.63.0

func (c *PodClient) VerifyPodTemplate(request *pod.VerifyPodTemplateRequest) (*pod.VerifyPodTemplateResponse, error)
校验pod模板的有效性。

## 接口说明 - 调用该接口可以校验Pod模板是否有效,例如某些关联资源(如子网、镜像等)已经被删除了。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL