本文问您介绍通过自定义镜像创建ECS部署物的方式,创建计算巢私有部署服务。
前提条件
您已申请成为软件服务商。
操作步骤
一、制作服务镜像
在云服务器ECS-实例页面中,根据您的服务要求创建实例。
将您的服务部署到ECS实例中,并测试。请参见部署自建项目。
测试完成后,根据您的需求使用快照创建自定义镜像或使用实例创建自定义镜像。
创建完成后如下图所示。
二、创建计算巢部署物
进入计算巢-服务部署物页面。根据提示填写部署物信息。
在部署物内容区域中,选择ECS镜像,勾选自定义镜像并选择您制作的服务镜像。
根据业务需求设置分发的地域。本节以全部地域为例。
单击发布部署物,完成创建。
详细操作,请参见ECS镜像部署物。
三、使用ECS部署物创建私有部署服务
进入计算巢-我的服务-创建新服务页面。
选择自定义创建服务,并在服务类型处,选择私有部署服务,然后单击下一步:配置服务。
在基本信息区域,上传服务图标,填写服务名称、服务简介和版本描述。
在服务部署区域,配置服务部署信息。
在模板录入处选择经典场景或选择自定义模板,对应操作如下所示。
自定义模板
选择手动录入模板, 本节的以部署方式选择ROS为例。
在部署地域选择全部地域。
模板内容选择YAML,并填入服务模板,您可以使用如下示例模板。
示例模板
ROSTemplateFormatVersion: '2015-09-01' Conditions: CreateVpcConditions: Fn::Equals: - NewVPC - Ref: VpcOption Parameters: Model: Type: String Label: en: Model zh-cn: 内置模型 AssociationPropertyMetadata: ValueLabelMapping: DeepSeek-R1_32b: zh-cn: DeepSeek-R1:32b en: DeepSeek-R1:32b AllowedValues: - DeepSeek-R1_32b Default: DeepSeek-R1_32b VpcOption: Type: String AllowedValues: - NewVPC - ExistingVPC AssociationPropertyMetadata: ValueLabelMapping: NewVPC: zh-cn: 新建专有网络 en: New VPC ExistingVPC: zh-cn: 已有专有网络 en: Existing VPC Label: en: Select Existing or New VPC zh-cn: 选择已有/新建的专有网络 Required: true Default: NewVPC VpcCidrBlock: Type: String Label: en: VPC CIDR IPv4 Block zh-cn: 专有网络IPv4网段 Description: zh-cn: VPC的ip地址段范围,<br>您可以使用以下的ip地址段或其子网:<br><font color='green'>[10.0.0.0/8]</font><br><font color='green'>[172.16.0.0/12]</font><br><font color='green'>[192.168.0.0/16]</font> en: 'The ip address range of the VPC in the CidrBlock form; <br>You can use the following ip address ranges and their subnets: <br><font color=''green''>[10.0.0.0/8]</font><br><font color=''green''>[172.16.0.0/12]</font><br><font color=''green''>[192.168.0.0/16]</font>' Default: 192.168.0.0/16 Required: Fn::Equals: - NewVPC - ${VpcOption} AssociationProperty: ALIYUN::VPC::VPC::CidrBlock AssociationPropertyMetadata: Visible: Condition: Fn::Equals: - NewVPC - ${VpcOption} VSwitchCidrBlock: Type: String Label: en: VSwitch CIDR Block zh-cn: 交换机子网网段 Description: zh-cn: 必须属于VPC的子网段。 en: Must belong to the subnet segment of VPC. Default: 192.168.1.0/24 Required: Fn::Equals: - NewVPC - ${VpcOption} AssociationProperty: ALIYUN::VPC::VSwitch::CidrBlock AssociationPropertyMetadata: VpcCidrBlock: VpcCidrBlock Visible: Condition: Fn::Equals: - NewVPC - ${VpcOption} PayType: Type: String Label: en: ECS Instance Charge Type zh-cn: 付费类型 Default: PostPaid AllowedValues: - PostPaid - PrePaid AssociationProperty: ChargeType AssociationPropertyMetadata: LocaleKey: InstanceChargeType PayPeriodUnit: Type: String Label: en: Pay Period Unit zh-cn: 购买资源时长周期 Default: Month AllowedValues: - Month - Year AssociationProperty: PayPeriodUnit AssociationPropertyMetadata: Visible: Condition: Fn::Not: Fn::Equals: - ${PayType} - PostPaid PayPeriod: Type: Number Label: en: Period zh-cn: 购买资源时长 Default: 1 AllowedValues: - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 AssociationProperty: PayPeriod AssociationPropertyMetadata: Visible: Condition: Fn::Not: Fn::Equals: - ${PayType} - PostPaid EcsInstanceType: Type: String Label: en: Instance Type zh-cn: 实例类型 AssociationProperty: ALIYUN::ECS::Instance::InstanceType AssociationPropertyMetadata: InstanceChargeType: ${PayType} AllowedValues: - ecs.g9i.48xlarge Default: ecs.g9i.48xlarge InstancePassword: NoEcho: true Type: String Description: en: Server login password, Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in) zh-cn: 服务器登录密码,长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号) AllowedPattern: '^[a-zA-Z0-9-\(\)\`\~\!\@\#\$\%\^\&\*\_\-\+\=\|\{\}\[\]\:\;\<\>\,\.\?\/]*$' Label: en: Instance Password zh-cn: 实例密码 ConstraintDescription: en: Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in) zh-cn: 长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号) MinLength: 8 MaxLength: 30 AssociationProperty: ALIYUN::ECS::Instance::Password ZoneId: Type: String Label: en: Zone ID zh-cn: 可用区ID AssociationProperty: ALIYUN::ECS::Instance::ZoneId AssociationPropertyMetadata: DefaultValueStrategy: random InstanceChargeType: ${PayType} SystemDiskCategory: cloud_essd InstanceType: ${EcsInstanceType} VpcId: Type: String Label: en: VPC ID zh-cn: 专有网络VPC实例ID AssociationProperty: 'ALIYUN::ECS::VPC::VPCId' Required: Fn::Equals: - ExistingVPC - ${VpcOption} Default: '' AssociationPropertyMetadata: AutoSelectFirst: true Visible: Condition: Fn::Equals: - ExistingVPC - ${VpcOption} VSwitchId: Type: String Label: en: VSwitch ID zh-cn: 交换机实例ID Default: '' AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId Required: Fn::Equals: - ExistingVPC - ${VpcOption} AssociationPropertyMetadata: AutoSelectFirst: true VpcId: ${VpcId} ZoneId: ${ZoneId} Visible: Condition: Fn::Equals: - ExistingVPC - ${VpcOption} Resources: # 新建vpc EcsVpc: Type: ALIYUN::ECS::VPC Condition: CreateVpcConditions Properties: VpcName: Ref: ALIYUN::StackName CidrBlock: Ref: VpcCidrBlock # 新建vswitch EcsVSwitch: Condition: CreateVpcConditions Type: ALIYUN::ECS::VSwitch Properties: VSwitchName: Ref: ALIYUN::StackName VpcId: Ref: EcsVpc ZoneId: Ref: ZoneId CidrBlock: Ref: VSwitchCidrBlock SecurityGroup: Type: ALIYUN::ECS::SecurityGroup Properties: SecurityGroupName: Ref: ALIYUN::StackName VpcId: Fn::If: - CreateVpcConditions - Ref: EcsVpc - Ref: VpcId SecurityGroupIngress: - PortRange: 8000/8000 Priority: 1 SourceCidrIp: 0.0.0.0/0 IpProtocol: tcp NicType: internet - PortRange: 11434/11434 Priority: 1 SourceCidrIp: 0.0.0.0/0 IpProtocol: tcp NicType: internet EcsInstanceGroup: Type: ALIYUN::ECS::InstanceGroup Properties: # 付费类型 InstanceChargeType: Ref: PayType PeriodUnit: Ref: PayPeriodUnit Period: Ref: PayPeriod VpcId: Fn::If: - CreateVpcConditions - Ref: EcsVpc - Ref: VpcId VSwitchId: 'Fn::If': - CreateVpcConditions - Ref: EcsVSwitch - Ref: VSwitchId ZoneId: Ref: ZoneId SecurityGroupId: Ref: SecurityGroup Password: Ref: InstancePassword InstanceType: Ref: EcsInstanceType SystemDiskCategory: cloud_essd SystemDiskSize: 1024 MaxAmount: 1 # 镜像 ImageId: centos_7 InternetMaxBandwidthOut: 5 IoOptimized: optimized RunInstallCommand: Type: ALIYUN::ECS::RunCommand Properties: InstanceIds: Fn::GetAtt: - EcsInstanceGroup - InstanceIds Type: RunShellScript Sync: true Timeout: 3600 CommandContent: |- bash /root/run.sh Metadata: ALIYUN::ROS::Interface: TemplateTags: - 'acs:integrate:计算巢:ModelScope' # 分组信息 ParameterGroups: - Parameters: - Model Label: default: zh-cn: 选择模型 en: Choose Model - Parameters: - PayType - PayPeriodUnit - PayPeriod Label: default: en: PayType Configuration zh-cn: 付费类型配置 - Parameters: - EcsInstanceType - InstancePassword Label: default: en: Instance zh-cn: ECS实例配置 - Parameters: - ZoneId - VpcOption - VpcId - VSwitchId - VpcCidrBlock - VSwitchCidrBlock Label: default: zh-cn: 选择网络配置 en: Choose existing Infrastructure Configuration
您可根据场景修改示例模板的参数:
服务实例所用规格:修改
InstacneType
参数限制。服务在安全组的端口:修改
SecurityGroup
资源中的端口。服务启动命令:替换
RunInstallCommand
属性中的命令。服务输出:调整
Outpus
属性中的IP和端口。
经典场景
在部署地域选择全部地域。
选择自定义镜像创建单实例ECS服务器-支持新建/选择已有专有网络、支持公网访问、不带数据盘场景。
选择完场景后,模板内容框中会自动填充内容,您无需修改。
单击添加套餐,设置两个套餐且不支持自定义套餐。
在部署物关联区域中,单击设置ECS镜像关联的选择部署物。
在弹框中,选择您已创建的部署物,并单击确定。
不设置应用分组。
若您需要将模板中的资源进行分组,可单击创建应用分组,对资源分组。
在服务运维(选填)区域,设置服务配置运维功能。
在运维处,选择需要用户授予的权限。
若要启用代运维功能,则选择的权限中,必须包含全部权限或报警权限其中的一个权限。
在监控处的资源监控处,并在统一设置云监控告警模板处,选择代运维报警模板。
单击创建服务。