From 0f9f149c2176208c27e43145c3ba8f0c91d6aa46 Mon Sep 17 00:00:00 2001 From: qitan Date: Thu, 27 Jun 2024 14:17:36 +0800 Subject: [PATCH] add technical solution 129 --- ...verless-high-availability-architecture.yml | 268 ++++++++++++++++++ .../elastic-scaling-container-through-hpa.yml | 6 +- 2 files changed, 271 insertions(+), 3 deletions(-) create mode 100644 documents/solution/high-availability-architecture/serverless-high-availability-architecture.yml diff --git a/documents/solution/high-availability-architecture/serverless-high-availability-architecture.yml b/documents/solution/high-availability-architecture/serverless-high-availability-architecture.yml new file mode 100644 index 00000000..ab3419c1 --- /dev/null +++ b/documents/solution/high-availability-architecture/serverless-high-availability-architecture.yml @@ -0,0 +1,268 @@ +ROSTemplateFormatVersion: '2015-09-01' +Description: + en: Serverless high availability architecture. + zh-cn: Serverless高可用架构。 +Parameters: + CommonName: + Type: String + Default: serverless + ZoneId1: + Type: String + AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId' + AssociationPropertyMetadata: + ExclusiveTo: + - ZoneId2 + Label: + en: Availability Zone + zh-cn: 可用区1 + ZoneId2: + Type: String + AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId' + AssociationPropertyMetadata: + ExclusiveTo: + - ZoneId1 + Label: + en: Availability Zone + zh-cn: 可用区2 + DBUserName: + Type: String + ConstraintDescription: + en: >- + Consist of 2 to 32 characters of lowercase letters, underline. + Must begin with a letter and be end with an alphanumeric character + zh-cn: >- + 由 2 到 32 个小写字母组成,支持小写字母、数字和下划线,以小写字母开头。 + Label: + zh-cn: RDS数据库账号 + en: RDS DB Username + Default: applets + AllowedPattern: '^[a-z][a-z0-9_]{0,31}$' + DBPassword: + NoEcho: true + Type: String + Description: + en: >- + RDS user password, Length 8-30, must contain three(Capital letters, + lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special + symbol in) + zh-cn: >- + 数据库账号密码,长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ + 中的特殊符号) + Label: + en: RDS Instance Password + zh-cn: RDS数据库密码 + ConstraintDescription: + en: >- + Length 8-30, must contain three(Capital letters, lowercase letters, + numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in) + zh-cn: '长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;''<>,.?/ 中的特殊符号)' + AssociationProperty: 'ALIYUN::ECS::Instance::Password' +Resources: + Vpc: + Type: 'ALIYUN::ECS::VPC' + Properties: + CidrBlock: 192.168.0.0/16 + VpcName: + Fn::Sub: ${CommonName}-vpc + VSwitch1: + Type: 'ALIYUN::ECS::VSwitch' + Properties: + VpcId: + Ref: Vpc + CidrBlock: 192.168.1.0/24 + ZoneId: + Ref: ZoneId1 + VSwitchName: + Fn::Sub: ${CommonName}-vsw + VSwitch2: + Type: 'ALIYUN::ECS::VSwitch' + Properties: + VpcId: + Ref: Vpc + CidrBlock: 192.168.2.0/24 + ZoneId: + Ref: ZoneId2 + VSwitchName: + Fn::Sub: ${CommonName}-vsw + SecurityGroup: + Type: 'ALIYUN::ECS::SecurityGroup' + Properties: + VpcId: + Ref: Vpc + SecurityGroupName: + Fn::Sub: ${CommonName}-sg + SecurityGroupIngress: + - PortRange: 22/22 + SourceCidrIp: 0.0.0.0/0 + IpProtocol: tcp + - PortRange: 443/443 + SourceCidrIp: 0.0.0.0/0 + IpProtocol: tcp + - PortRange: 80/80 + SourceCidrIp: 0.0.0.0/0 + IpProtocol: tcp + PolarDBCluster: + Type: 'ALIYUN::POLARDB::DBCluster' + Properties: + VpcId: + Ref: Vpc + DBType: MySQL + ClusterNetworkType: VPC + ZoneId: + Ref: ZoneId1 + SecurityGroupIds: + - Ref: SecurityGroup + DBVersion: '8.0' + DBMinorVersion: '8.0.2' + DBNodeClass: polar.mysql.sl.small + VSwitchId: + Ref: VSwitch1 + CreationCategory: Normal + ScaleRoNumMin: 1 + ScaleRoNumMax: 4 + ScaleMin: 1 + ScaleMax: 16 + ProxyType: GENERAL + PayType: Postpaid + ServerlessType: AgileServerless + PolarDBDatabase: + Type: 'ALIYUN::POLARDB::DBInstance' + Properties: + DBClusterId: + Ref: PolarDBCluster + CharacterSetName: utf8mb4 + DBName: applets + DBDescription: serverless demo + PolarDBAccount: + Type: 'ALIYUN::POLARDB::Account' + Properties: + DBClusterId: + Ref: PolarDBCluster + AccountName: + Ref: DBUserName + AccountType: Normal + AccountPassword: + Ref: DBPassword + AccountPrivilege: ReadWrite + DBName: + Ref: PolarDBDatabase + Alb: + Type: 'ALIYUN::ALB::LoadBalancer' + Properties: + LoadBalancerName: + Fn::Sub: ${CommonName}-alb + LoadBalancerEdition: Basic + VpcId: + Ref: Vpc + LoadBalancerBillingConfig: + PayType: PostPay + AddressType: Internet + ZoneMappings: + - ZoneId: + Ref: ZoneId1 + VSwitchId: + Ref: VSwitch1 + - ZoneId: + Ref: ZoneId2 + VSwitchId: + Ref: VSwitch2 + SaeNamespace: + Type: 'ALIYUN::SAE::Namespace' + Properties: + NamespaceName: serverless-demo + NamespaceId: + Fn::Sub: + - '${Region}:serverless${Suffix}' + - Region: + Ref: ALIYUN::Region + Suffix: + Fn::Jq: + - First + - .StackId[:5] + - StackId: + Ref: ALIYUN::StackId + SaeApp: + Type: 'ALIYUN::SAE::Application' + DependsOn: SaeNamespace + Properties: + AppName: + Fn::Sub: + - 'serverless-demo-${Suffix}' + - Suffix: + Fn::Jq: + - First + - .StackId[:5] + - StackId: + Ref: ALIYUN::StackId + AppDescription: serverless-demo + VpcId: + Ref: Vpc + SecurityGroupId: + Ref: SecurityGroup + VSwitchId: + Fn::Sub: '${VSwitch1},${VSwitch2}' + Replicas: 2 + NamespaceId: + Ref: SaeNamespace + Cpu: 2000 + Memory: 4096 + PackageType: FatJar + PackageVersion: '1718956564756' + Jdk: Open JDK 8 + PackageUrl: https://help-static-aliyun-doc.aliyuncs.com/demos/sae-demo-0.0.1-SNAPSHOT.jar + Timezone: Asia/Shanghai + JarStartArgs: '$JAVA_HOME/bin/java $Options -jar $CATALINA_OPTS "$package_path" $args' + Envs: + Fn::Sub: >- + [{"name":"APPLETS_RDS_ENDPOINT","value":"${PolarDBCluster.PrimaryConnectionString}"}, + {"name":"APPLETS_RDS_USER","value":"${DBUserName}"}, + {"name":"APPLETS_RDS_PASSWORD","value":"${DBPassword}"}, + {"name":"APPLETS_RDS_DB_NAME","value":"applets"}] + WaitApp: + Type: 'ALIYUN::ROS::Sleep' + DependsOn: SaeApp + Properties: + CreateDuration: 180 + SaeIngress: + Type: 'ALIYUN::SAE::Ingress' + DependsOn: WaitApp + Properties: + NamespaceId: + Ref: SaeNamespace + Description: serverless-demo-router + LoadBalanceType: alb + SlbId: + Ref: Alb + ListenerProtocol: HTTP + ListenerPort: 80 + Rules: + - Domain: example.com + Path: / + AppId: + Ref: SaeApp + ContainerPort: 80 + BackendProtocol: http + DefaultRule: + AppId: + Ref: SaeApp + ContainerPort: 80 + BackendProtocol: http +Outputs: + WebUrl: + Description: + zh-cn: Web 访问地址。 + en: The Addresses of Web. + Value: + 'Fn::Sub': 'http://${Alb.DNSName}' +Metadata: + ALIYUN::ROS::Interface: + ParameterGroups: + - Parameters: + - DBUserName + - DBPassword + - ZoneId1 + - ZoneId2 + TemplateTags: + - acs:technical-solution:high-availability-architecture:Serverless高可用架构-tech_solu_129 + Hidden: + - CommonName diff --git a/documents/solution/micro/elastic-scaling-container-through-hpa.yml b/documents/solution/micro/elastic-scaling-container-through-hpa.yml index 9a9a5551..51a64064 100644 --- a/documents/solution/micro/elastic-scaling-container-through-hpa.yml +++ b/documents/solution/micro/elastic-scaling-container-through-hpa.yml @@ -212,7 +212,7 @@ Resources: ClusterId: Ref: AckCluster NodePoolInfo: - Name: default-nodepool + Name: k8s-hpa-cluster-nodepool ScalingGroup: VSwitchIds: - Ref: VSwitch1 @@ -490,7 +490,7 @@ Resources: number: 80 Hpa: Type: 'ALIYUN::CS::ClusterApplication' - DependsOn: Ingress + DependsOn: WaitAlbIngress Properties: ClusterId: Ref: AckCluster @@ -533,7 +533,7 @@ Resources: type: Utilization type: Resource WaitAlbIngress: - Type: ALIYUN::ROS::Sleep + Type: 'ALIYUN::ROS::Sleep' DependsOn: Ingress Properties: CreateDuration: 120