调用UpdateContainerGroup更新实例。

接口说明

  • 仅支持处于启动中(Pending)或运行中(Running)状态的ECI实例进行更新。更新操作后,ECI实例状态将变更为更新中(Updating)。
  • 不支持ECI实例级别的规格变配,仅支持在不影响实例规格的情况下,容器级别的规格变配。
  • 创建时间早于2019-03-07 15:00:00的ECI实例不支持更新。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

请求参数

名称 类型 是否必选 示例值 描述
Action String UpdateContainerGroup

系统规定参数。取值:UpdateContainerGroup。

ContainerGroupId String eci-2zelg8vwnlzdhf8hv****

指定需要更新的ECI实例ID,即容器组ID。

RegionId String cn-hangzhou

所属地域ID。

RestartPolicy String Always

ECI实例(容器组)的重启策略。

Tag.N.Key String name

标签键。

Tag.N.Value String hxh

标签值。

Volume.N.Name String test-empty

数据卷名称。

Volume.N.Type String EmptyDirVolume

数据卷类型,取值范围:

  • EmptyDirVolume
  • NFSVolume
  • ConfigFileVolume
Volume.N.NFSVolume.Server String 0eaf24bfc1-xxxxx.cn-hangzhou.nas.aliyuncs.com

NFS服务器地址。

Volume.N.NFSVolume.Path String /

NFS数据卷路径。

Volume.N.NFSVolume.ReadOnly Boolean false

是否只读。默认为false。

Volume.N.ConfigFileVolume.ConfigFileToPath.N.Content String bGl1bWk=

配置文件内容 (32KB)。

Volume.N.ConfigFileVolume.ConfigFileToPath.N.Path String liu/name

相对文件路径。

Volume.N.EmptyDirVolume.Medium String Memory

EmptyDirVolume的存储媒介。默认为空,表示使用node文件系统,您也可以配置为Memory,表述使用内存。

DnsConfig.NameServer.N RepeatList 1.2.3.4

DNS服务器的IP地址列表。

DnsConfig.Search.N RepeatList my.dns.search.suffix

DNS搜索域列表。

DnsConfig.Option.N.Name String ndots

选项变量名。

DnsConfig.Option.N.Value String 2

选项变量值。

Container.N.Name String jenkins

容器名称。

Container.N.Image String jenkins

容器镜像。

Container.N.Cpu Float 1.0

容器vCPU大小。

Container.N.Memory Float 2.0

容器内存大小。

Container.N.WorkingDir String /usr/share/

容器工作目录。

Container.N.ImagePullPolicy String Never

镜像拉取策略。

Container.N.Stdin Boolean false

此容器是否应在容器运行时为标准输入分配缓冲区。如果未设置,则容器中标准输入的读取值将导致EOF。默认为false。

Container.N.StdinOnce Boolean true

当标准输入为true时,标准输入流将在多个附加会话中保持开启状态。如果StdinOnce设为true,标准输入在容器开启时被打开,在首个客户端附加到标准输入之前都为空,然后会一直保持开启状态,接收数据,直到客户端连接断开,此时标准输入被关闭,在容器重启前一直保持关闭状态。

Container.N.Tty Boolean false

是否开启交互。默认为false,如果Command为/bin/bash类型,需要设置为true。

Container.N.Command.N RepeatList echo

容器启动命令。最多20个,单个命令支持256个字符。

Container.N.Arg.N RepeatList hello

容器启动参数。最多10个。

Container.N.EnvironmentVar.N.Key String PATH

容器的环境变量名。

Container.N.EnvironmentVar.N.Value String /usr/bin/local/

容器的环境变量值。

Container.N.EnvironmentVar.N.FieldRef.FieldPath String status.podIP

使用Pod字段作为环境变量。目前仅支持status.podIP。

Container.N.Port.N.Protocol String TCP

TCP/UDP。

Container.N.Port.N.Port Integer 8080

端口号。取值范围:1~65535

Container.N.VolumeMount.N.Name String test-empty

容器挂载的数据卷名称。从ECI实例(容器组)挂载的数据卷中选择,即取值范围为配置的Volume.N.Name参数。

Container.N.VolumeMount.N.MountPath String /usr/share/

容器挂载的目录。容器挂载目录下的内容会被volume的内容直接覆盖,请谨慎使用。

Container.N.VolumeMount.N.SubPath String /usr/share/sub/

数据卷的子目录,方便Pod将同一个Volume下不同目录挂载到容器不同目录。

Container.N.VolumeMount.N.ReadOnly Boolean false

是否只读。默认值:false

Container.N.VolumeMount.N.MountPropagation String None

数据卷的挂载传播设置。挂载传播允许将Container挂载的卷共享到同一Pod中的其他Container,甚至可以共享到同一节点上的其他Pod。取值范围:

  • None:该卷不感知任何后续在此卷或其子目录上执行的挂载操作。
  • HostToCotainer:该卷将会感知到后续在此卷或其子目录上的挂载操作。
  • Bidirectional:和HostToCotainer类似,能感知挂载操作。另外,该卷将被传播回主机和使用同一卷的所有Pod的所有容器。

默认值:None

Container.N.ReadinessProbe.TcpSocket.Port Integer 5000

TcpSocket检测的端口。

Container.N.ReadinessProbe.Exec.Command.N RepeatList [/bin/sh cat /tmp/healthy]

容器内检测的命令。

Container.N.ReadinessProbe.HttpGet.Path String /usr/

HttpGet检测的路径。

Container.N.ReadinessProbe.HttpGet.Port Integer 8080

HttpGet检测的端口号。

Container.N.ReadinessProbe.HttpGet.Scheme String HTTP

HTTP/HTTPS 。

Container.N.ReadinessProbe.InitialDelaySeconds Integer 10

检查开始执行的时间。以容器启动完成为起点开始计算。

Container.N.ReadinessProbe.PeriodSeconds Integer 10

检查执行的周期。默认为10秒,最小为1秒。

Container.N.ReadinessProbe.SuccessThreshold Integer 3

从上次检查失败后重新认定检查成功的检查次数阈值(必须是连续成功)。默认为1次。

Container.N.ReadinessProbe.FailureThreshold Integer 3

从上次检查成功后认定检查失败的检查次数阈值(必须是连续失败)。默认为3次。

Container.N.ReadinessProbe.TimeoutSeconds Integer 5

检查超时的时间。默认为1秒,最小为1秒。

Container.N.LivenessProbe.TcpSocket.Port Integer 80

TcpSocket检测的端口。

Container.N.LivenessProbe.Exec.Command.N RepeatList [/bin/sh cat /tmp/healthy]

容器内检测命令。

Container.N.LivenessProbe.HttpGet.Path String /usr/local/bin

HttpGet检测的路径。

Container.N.LivenessProbe.HttpGet.Port Integer 8080

HttpGet检测的端口号。

Container.N.LivenessProbe.HttpGet.Scheme String HTTP

HTTP/HTTPS。

Container.N.LivenessProbe.InitialDelaySeconds Integer 10

检查开始执行的时间。以容器启动完成为起点开始计算。

Container.N.LivenessProbe.PeriodSeconds Integer 10

检查执行的周期。默认为10秒,最小为1秒。

Container.N.LivenessProbe.SuccessThreshold Integer 1

从上次检查失败后重新认定检查成功的检查次数阈值(必须是连续成功)。默认为1次,当前必须为1次。

Container.N.LivenessProbe.FailureThreshold Integer 3

从上次检查成功后认定检查失败的检查次数阈值(必须是连续失败)。默认为3次。

Container.N.LivenessProbe.TimeoutSeconds Integer 1

检查超时的时间。默认为1秒,最小为1秒。

Container.N.SecurityContext.ReadOnlyRootFilesystem Boolean true

是否只读根文件系统。取值目前仅支持:true。

Container.N.SecurityContext.RunAsUser Long 1337

用于运行容器进程入口点的UID。

Container.N.SecurityContext.Capability.Add.N RepeatList NET_ADMIN

枚举值。取值目前仅支持:NET_ADMIN

Container.N.Gpu Integer 1

指定容器使用的GPU个数。

InitContainer.N.Name String init-nginx

Init容器名称。

InitContainer.N.Image String nginx

Init容器镜像。

InitContainer.N.Cpu Float 2.0

Init容器vCPU大小。

InitContainer.N.Memory Float 4.0

Init容器内存大小。

InitContainer.N.WorkingDir String /bin/local/

Init容器工作目录。

InitContainer.N.ImagePullPolicy String Onfailure

镜像拉取策略。

InitContainer.N.Stdin Boolean false

此容器是否应在容器运行时为标准输入分配缓冲区。如果未设置,则容器中标准输入的读取值将导致EOF。默认为false。

InitContainer.N.StdinOnce Boolean true

当标准输入为true时,标准输入流将在多个附加会话中保持开启状态。如果StdinOnce设为true,标准输入在容器开启时被打开,在首个客户端附加到标准输入之前都为空,然后会一直保持开启状态,接收数据,直到客户端连接断开,此时标准输入被关闭,在容器重启前一直保持关闭状态。

InitContainer.N.Tty Boolean true

是否开启交互。默认为false,如果Command为/bin/bash类型时,需要设置为true。

InitContainer.N.Command.N RepeatList /bin/sh sleep

Init容器指令。

InitContainer.N.Arg.N RepeatList 10

Init容器启动参数。

InitContainer.N.EnvironmentVar.N.Key String PATH

Init容器的环境变量名。

InitContainer.N.EnvironmentVar.N.Value String /usr/local/bin

Init容器的环境变量值。

InitContainer.N.EnvironmentVar.N.FieldRef.FieldPath String status.podIP

用Pod字段作为环境变量值。

InitContainer.N.Port.N.Port Integer 9000

Init容器端口号 。取值范围:1~65535。

InitContainer.N.Port.N.Protocol String TCP

TCP/UDP。

InitContainer.N.VolumeMount.N.Name String default-volume1

Init容器挂载的数据卷名称。从ECI实例(容器组)挂载的数据卷中选择,即取值范围为配置的Volume.N.Name参数。

InitContainer.N.VolumeMount.N.MountPath String /pod/data

Init容器挂载目录。容器挂载目录下的内容将被volume的内容直接覆盖,请谨慎使用。

InitContainer.N.VolumeMount.N.SubPath String data2/

数据卷的子目录,方便Pod将同一个Volume下不同目录挂载到容器不同目录。

InitContainer.N.VolumeMount.N.ReadOnly Boolean false

是否只读。默认值:false

InitContainer.N.VolumeMount.N.MountPropagation String None

数据卷的挂载传播设置。挂载传播允许将Container挂载的卷共享到同一Pod中的其他Container,甚至可以共享到同一节点上的其他Pod。取值范围:

  • None:该卷不感知到任何后续在此卷或其任何子目录上执行的挂载变化。
  • HostToContainer:该卷将会感知到主机后续针对此卷或其任何子目录的挂载操作。
  • Bidirectional:和HostToContainer类似。另外,该卷将被传播回实例和使用同一卷的所有Pod的所有容器。

默认值:None

InitContainer.N.SecurityContext.ReadOnlyRootFilesystem Boolean true

是否只读根文件系统。

InitContainer.N.SecurityContext.RunAsUser Long 1000

用于运行容器进程入口点的UID。

InitContainer.N.SecurityContext.Capability.Add.N RepeatList NET_ADMIN

枚举值。取值目前仅支持:NET_ADMIN

InitContainer.N.Gpu Integer 1

指定Init容器使用的GPU个数。

ImageRegistryCredential.N.Server String registry.cn-shanghai.aliyuncs.com/ecitest/nginx:alpine

不带 http://https:// 前缀的镜像仓库地址。

  • 只支持全量更新
  • 如果是单独更新ImageRegistryCredentials,且更新后的ImageRegistryCredentials的数量不超过之前原ImageRegistryCredentials,则无需重启ECI,其他情况会重启ECI。
ImageRegistryCredential.N.UserName String yourname

镜像仓库用户名。

ImageRegistryCredential.N.Password String yourpassword

镜像仓库密码。

ClientToken String 123e4567-e89b-12d3-a456-426655440000

保证请求幂等性。从您的客户端生成一个参数值,确保不同请求间该参数值唯一。只支持ASCII字符,且不能超过64个字符。更多详情,请参阅如何保证幂等性

Cpu Float 2.0

实例(容器组)级别的vCPU。

Memory Float 4.0

实例(容器组)级别的内存数。

ResourceGroupId String rg-2df3isufhi38****

所属资源组ID。

参数说明

Container和InitContainer

InitContainer和Container均仅支持全量更新。更新InitContainer需要重启实例。

更新包括以下几种情况:

  • 原ECI实例同时有InitContainer和Container,但只更新InitContainer。
  • 原ECI实例同时有InitContainer和Container,但只更新Container。
  • 原ECI实例同时有InitContainer和Container,InitContainer和Container全部更新。
  • 原ECI实例只有Container,更新Container。
  • 原ECI实例只有Container,增加InitContainer。
  • 原ECI实例只有Container,增加InitContainer,同时更新Container。
Volumes

更新volume的参数要求和创建时的参数要求一致。

  • 仅支持全量更新。
  • 需要重启ECI实例。
    说明 Container通过Volume Name来匹配挂载的Volume,所以单独更新Volume只是修改Voulme内部一些基本参数,大的更新需要伴随Container一起更新,比如数量、Name发生变化。
ImageRegistryCredentials
  • 仅支持全量更新。
  • 如果是单独更新ImageRegistryCredentials,且更新后的ImageRegistryCredentials的数量不超过之前原ImageRegistryCredentials,则无需重启ECI实例,其他情况会重启ECI实例。
Tag
  • 仅支持全量更新。
  • 无需重启ECI。
DnsConfig
  • 仅支持全量更新。
  • 需要重启ECI实例。
说明 全量更新:如果参数是一个List,不支持单独更新某个item,如果参数是一个结构体,不支持单独更新某个内部成员。

返回数据

名称 类型 示例值 描述
RequestId String CB8D2B22-D636-4182-****-1FC9DBDAD66F

请求ID,唯一标识。

示例

请求示例

https://eci.aliyuncs.com//?Action=UpdateContainerGroup
&ContainerGroupId=eci-2zelg8vwnlzdhf8hv****
&RegionId=cn-hangzhou
&<公共请求参数>

正常返回示例

XML格式

<UpdateContainerGroup>
      <RequestId>CB8D2B22-D636-4182-****-1FC9DBDAD66F</RequestId>
</UpdateContainerGroup>

JSON格式

{
    "RequestId":"CB8D2B22-D636-4182-****-1FC9DBDAD66F"
}

错误码

HttpCode 错误码 错误信息 描述
400 InvalidParameter.CPU.Memory The specified cpu and memory are not allowed cpu,mem不符合规格
400 InvalidParameter.DuplicatedName The container group include containers with duplicate names. 容器组内有重复名字的容器。
400 InvalidParameter.DuplicatedVolumeName The container group includes volumes with duplicate names. 容器组内有重复名字的数据卷。
400 InvalidParameter.LengthExceeded %s List型参数的长度超过规定值
404 InvalidParameter.NotFound %s 参数未找到
400 InvalidParameter.ValueExceeded %s 参数值超过规定范围
400 IncorrectStatus %s 指定的实例状态不正确。
403 InvalidAction The specified action is invalid 不合法的操作
400 InvalidParam.CpuOrMemorySpec The specified specification is invalid. 指定的规格还未开放售卖,不提供价格查询。
400 InvalidParameter %s 不合法的参数
400 MissingParameter %s 必填参数缺失
400 NoNeedUpdate There are no changes to be updated for current resource. 本次操作没有需要更新的参数

访问错误中心查看更多错误码。