Documentation
¶
Index ¶
- type ContainerService
- func (cs *ContainerService) CommitContainer(name string, spec model.ContainerCommit) (imageName string, err error)
- func (cs *ContainerService) DeleteContainer(name string, spec *model.ContainerDelete) error
- func (cs *ContainerService) ExecuteContainer(name string, exec *model.ContainerExecute) (resp *string, err error)
- func (cs *ContainerService) GetContainerInfo(name string) (info model.EtcdContainerInfo, err error)
- func (cs *ContainerService) PatchContainerGpuInfo(name string, spec *model.ContainerGpuPatch) (id, newContainerName string, err error)
- func (cs *ContainerService) PatchContainerVolumeInfo(name string, spec *model.ContainerVolumePatch) (id, newContainerName string, err error)
- func (cs *ContainerService) RestartContainer(name string) (id, newContainerName string, err error)
- func (cs *ContainerService) RunGpuContainer(spec *model.ContainerRun) (id, containerName string, err error)
- func (cs *ContainerService) StopContainer(name string, spec *model.ContainerStop) error
- type VolumeService
- func (vs *VolumeService) CreateVolume(spec *model.VolumeCreate) (resp volume.Volume, err error)
- func (vs *VolumeService) DeleteVolume(name string, spec *model.VolumeDelete) error
- func (vs *VolumeService) GetVolumeInfo(name string) (info model.EtcdVolumeInfo, err error)
- func (vs *VolumeService) PatchVolumeSize(name string, spec *model.VolumeSize) (resp volume.Volume, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContainerService ¶
type ContainerService struct{}
func (*ContainerService) CommitContainer ¶
func (cs *ContainerService) CommitContainer(name string, spec model.ContainerCommit) (imageName string, err error)
CommitContainer 提交容器为镜像,镜像名称默认为镜像的 ID
func (*ContainerService) DeleteContainer ¶
func (cs *ContainerService) DeleteContainer(name string, spec *model.ContainerDelete) error
DeleteContainer 删除一个容器,归还端口资源,如果是 GPU 容器,会归还使用的 GPU 资源 根据入参选择是否要删除 etcd 中关于容器的描述,以及版本号记录
func (*ContainerService) ExecuteContainer ¶
func (cs *ContainerService) ExecuteContainer(name string, exec *model.ContainerExecute) (resp *string, err error)
ExecuteContainer 执行容器中的命令并返回输出
func (*ContainerService) GetContainerInfo ¶
func (cs *ContainerService) GetContainerInfo(name string) (info model.EtcdContainerInfo, err error)
func (*ContainerService) PatchContainerGpuInfo ¶
func (cs *ContainerService) PatchContainerGpuInfo(name string, spec *model.ContainerGpuPatch) (id, newContainerName string, err error)
PatchContainerGpuInfo 变更容器的 GPU 资源 关于容器即将变为无卡容器,还是变为有卡容器,全由入参中的 GpuCount 决定,你只需要告诉我你想要的 GPU 资源数量 例如 GPUCount 为 0,就是要将旧容器变为无卡容器,GPUCount 为 1,就是要将旧容器变为有卡容器 对于状态未发生变化,如:无卡变无卡,有卡容器 GPU 数量变更前后一致,会直接跳过,以提高效率
func (*ContainerService) PatchContainerVolumeInfo ¶
func (cs *ContainerService) PatchContainerVolumeInfo(name string, spec *model.ContainerVolumePatch) (id, newContainerName string, err error)
PatchContainerVolumeInfo 变更容器的 Volume 资源 需要注意的是,这个方法只是会替换新容器绑定的 Volume 资源 例如 foo-0 容器绑定了 volume-0 到 /root/example 目录,现在要使用的是 volume-1,那么就会将 volume-0 替换成 volume-1,然后创建新容器
func (*ContainerService) RestartContainer ¶
func (cs *ContainerService) RestartContainer(name string) (id, newContainerName string, err error)
RestartContainer 重启动容器 无卡容器会直接 docker restart 有卡容器会重新申请 GPU 资源,然后创建一个新的容器,用来替换旧的容器
func (*ContainerService) RunGpuContainer ¶
func (cs *ContainerService) RunGpuContainer(spec *model.ContainerRun) (id, containerName string, err error)
RunGpuContainer 创建并启动一个 GPU 容器
func (*ContainerService) StopContainer ¶
func (cs *ContainerService) StopContainer(name string, spec *model.ContainerStop) error
StopContainer 停止容器 restoreGpus 是否释放 gpu 资源 restorePorts 是否释放端口资源
type VolumeService ¶
type VolumeService struct{}
func (*VolumeService) CreateVolume ¶
func (vs *VolumeService) CreateVolume(spec *model.VolumeCreate) (resp volume.Volume, err error)
CreateVolume 创建一个可指定名称和大小的 Volume
func (*VolumeService) DeleteVolume ¶
func (vs *VolumeService) DeleteVolume(name string, spec *model.VolumeDelete) error
DeleteVolume 删除一个 Volume
func (*VolumeService) GetVolumeInfo ¶
func (vs *VolumeService) GetVolumeInfo(name string) (info model.EtcdVolumeInfo, err error)
func (*VolumeService) PatchVolumeSize ¶
func (vs *VolumeService) PatchVolumeSize(name string, spec *model.VolumeSize) (resp volume.Volume, err error)
PatchVolumeSize 变更 Volume 的大小 包括扩容和缩容两个操作,如果操作前后的大小相同,则直接返回,不做任何操作 需要注意的是,缩容操作会判断已经使用的 Volume 大小是否大于缩容之后的 Volume 大小,如果大于,则返回错误 例如:缩容前的 Volume 大小为 10G,缩容后的 Volume 大小为 5G,但是已经使用了 6G,则返回错误