ROSTemplateFormatVersion: '2015-09-01'
Description:
en: 新建ack部署
zh-cn: new ack
Parameters:
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
Description:
en: When the resource purchase duration is Month, the value of Period ranges from 1 to 9, 12, 24, 36, 48, or 60. <br><b><font color='red'> When ECS instance types are PrePaid valid </b></font>
zh-cn: 当购买资源时长为Month时,Period取值:1~9 <br><b><font color='red'>当ECS实例类型为PrePaid有效</b></font>
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
ZoneId:
Type: String
AssociationProperty: ALIYUN::ECS::Instance:ZoneId
Label:
en: Zone ID
zh-cn: 可用区
EcsInstanceType:
Type: String
Label:
en: Instance Type
zh-cn: 实例类型
AssociationProperty: ALIYUN::ECS::Instance::InstanceType
AssociationPropertyMetadata:
ZoneId: ${ZoneId}
InstanceChargeType: ${InstanceChargeType}
EcsInstancePassword:
NoEcho: true
Type: String
AllowedPattern: '[0-9A-Za-z\_\-\&:;''<>,=%`~!@#\(\)\$\^\*\+\|\{\}\[\]\.\?\/]+$'
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
ServerSystemDiskCategory:
Type: String
AllowedValues:
- cloud_efficiency
- cloud_ssd
- cloud_essd
AssociationPropertyMetadata:
LocaleKey: DiskCategory
InstanceType: ${EcsInstanceType}
Label:
en: Server System Disk Category
zh-cn: Server系统盘磁盘类型
Default: cloud_essd
ServerSystemDiskSize:
Type: Number
Label:
en: Server System Disk Size(GB)
zh-cn: Server节点系统盘大小(GB)
MinValue: 1
Default: 500
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
AssociationProperty: ALIYUN::VPC::VPC::CidrBlock
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
AssociationProperty: ALIYUN::VPC::VSwitch::CidrBlock
AssociationPropertyMetadata:
VpcCidrBlock: VpcCidrBlock
PodCidr:
Type: String
Description:
zh-cn: 请填写有效的私有网段,即以下网段及其子网:10.0.0.0/8,172.16-31.0.0/12-16,192.168.0.0/16<br>不能与 VPC 及 VPC 内已有 Kubernetes 集群使用的网段重复。<font color='blue'><b>创建成功后不能修改</b></font>
en: 'Please fill in a valid private segment, i.e. the following segments and their subnets: 10.0.0.0/8, 172.16-31.0.0/12-16, 192.168.0.0/16<br> which cannot duplicate the network segments already used by clusters in VPC and VPC Kunetberes. <font color=''blue''><b>Cannot be modified after successful creation</b></font>'
Label:
zh-cn: Pod 网络 CIDR
en: Pod Network CIDR
AssociationProperty: ALIYUN::CS::ManagedKubernetesCluster::PodCidr
Default: 10.0.0.0/16
ServiceCidr:
Type: String
Description:
zh-cn: 可选范围:10.0.0.0/16-24,172.16-31.0.0/16-24,192.168.0.0/16-24<br>不能与 VPC 及 VPC 内已有 Kubernetes 集群使用的网段重复。<font color='blue'><b>创建成功后不能修改</b></font>
en: 'Optional range: 10.0.0.0/16-24, 172.16-31.0.0/16-24, 192.168.0.0/16-24<br> cannot duplicate segments already used by existing Kubernetes clusters in VPC and VPC.<font color=''blue''><b>Cannot be modified after successful creation</b></font>'
Label:
zh-cn: Service CIDR
en: Service CIDR
AssociationProperty: ALIYUN::CS::ManagedKubernetesCluster::ServiceCidr
Default: 172.16.0.0/16
Resources:
EcsVpc:
Type: ALIYUN::ECS::VPC
Properties:
VpcName:
Ref: ALIYUN::StackName
CidrBlock:
Ref: VpcCidrBlock
EcsVSwitch:
Type: ALIYUN::ECS::VSwitch
Properties:
VSwitchName:
Ref: ALIYUN::StackName
VpcId:
Ref: EcsVpc
ZoneId:
Ref: ZoneId
CidrBlock:
Ref: VSwitchCidrBlock
EcsSecurityGroup:
Type: ALIYUN::ECS::SecurityGroup
Properties:
SecurityGroupName:
Ref: ALIYUN::StackName
VpcId:
Ref: EcsVpc
SecurityGroupEgress:
- PortRange: '-1/-1'
Priority: 1
IpProtocol: all
DestCidrIp: 0.0.0.0/0
NicType: intranet
SecurityGroupIngress:
- PortRange: '-1/-1'
Priority: 1
IpProtocol: all
SourceCidrIp:
Ref: PodCidr
Description: pod网络访问开放
NicType: intranet
- PortRange: '-1/-1'
Priority: 1
IpProtocol: all
SourceCidrIp:
Ref: VpcCidrBlock
Description: vpc网络访问开放
NicType: intranet
- PortRange: '-1/-1'
Priority: 1
IpProtocol: icmp
SourceCidrIp: 0.0.0.0/0
Description: icmp协议端口放开
NicType: intranet
- Priority: 1
PortRange: 22/22
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
- Priority: 1
PortRange: 443/443
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
- Priority: 1
PortRange: 3001/3001
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
- Priority: 1
PortRange: 31001/31001
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
- Priority: 1
PortRange: 9000/9000
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
- Priority: 1
PortRange: 3389/3389
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
- Priority: 1
PortRange: 80/80
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
CsghubServerInstance:
Type: ALIYUN::ECS::InstanceGroup
Properties:
ZoneId:
Ref: ZoneId
IoOptimized: optimized
InstanceChargeType:
Ref: PayType
PeriodUnit:
Ref: PayPeriodUnit
Period:
Ref: PayPeriod
VpcId:
Ref: EcsVpc
VSwitchId:
Ref: EcsVSwitch
SecurityGroupId:
Ref: EcsSecurityGroup
SystemDiskCategory:
Ref: ServerSystemDiskCategory
SystemDiskSize:
Ref: ServerSystemDiskSize
MaxAmount: 1
ImageId: centos_7
InstanceType:
Ref: EcsInstanceType
Password:
Ref: EcsInstancePassword
InternetMaxBandwidthOut: 50
InstanceName:
Fn::Join:
- '-'
- - Ref: ALIYUN::StackName
- '[1,4]'
InstanceRunCommand:
Type: ALIYUN::ECS::RunCommand
Properties:
Type: RunShellScript
Sync: true
CommandContent:
Fn::Sub:
- |
#!/bin/bash
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin jq
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": [
"https://docker.m.daocloud.io",
"https://mirror.baidubce.com",
"https://dockerproxy.com",
"https://mirror.iscas.ac.cn",
"https://huecker.io",
"https://dockerhub.timeweb.cloud",
"https://noohub.ru",
"https://vlgh0kqj.mirror.aliyuncs.com"
]
}
EOF
systemctl enable docker
systemctl start docker
sleep 10
# 安装Server
wget '{{ computenest::file::csgserver }}' -O csghub-main.tar.gz
tar -xvf csghub-main.tar.gz
cd /root/csghub-main/deploy/all_in_one
sed -i 's/SERVER_DOMAIN=[^,)]*/SERVER_DOMAIN=${PublicAddress}/' .env
sleep 10
chmod 777 startup.sh
./startup.sh
sleep 10
docker compose restart user_server
sleep 10
docker compose restart nginx
docker compose restart user_server
# 执行成功回调WaitCondition结束waitCondition的等待
- PublicAddress:
Fn::Select:
- 0
- Fn::GetAtt:
- CsghubServerInstance
- PublicIps
InstanceIds:
Fn::GetAtt:
- CsghubServerInstance
- InstanceIds
Timeout: 3600