Kenan
Assistant Engineer
Assistant Engineer
  • UID621
  • Fans1
  • Follows0
  • Posts55
Reads:2435Replies:0

Using ROS to Build the Applications Foundation Suite

Created#
More Posted time:Sep 30, 2016 10:13 AM
Abstract:  The article describes how to build the infrastructure (SLB+ECS+RDS) for enterprise-level applications using Alibaba Cloud resource orchestration service.
Background:
SLB + ECS + RDS is the basic mix of enterprise-level applications and the core component of infrastructure in small application scenarios.


As shown in the figure above, create a set of ECS instances and put it under SLB, and then create an ECS instance and add its IP to the access whitelist. As a user, you only need to estimate the quantity of ECSs based on service types and characteristics, while all other things are completed through Alibaba Cloud resource orchestration service (ROS) by one simple click.
The resources created include:
• ALIYUN::ECS::InstanceGroup
o Create a set of ECSs with the same configuration.
Note: If each ECS has the same weight for forwarding, it can be mounted under SLB using the method described in this article; otherwise you can mount it manually and set different weights.
• ALIYUN::SLB::LoadBalancer
o Create a load balance
• ALIYUN::SLB::Listener
o Listener configuration
• ALIYUN::SLB::BackendServerAttachment
o Mount ECS under load balance
• ALIYUN::RDS::DBInstance
o Create RDS instances
Detailed steps
• Step 1:  Create a set of ECS instances configured as two-core 4G (ecs.s2.large), choose non-IO-optimized general cloud storage and public mirror and create a security group. The upper limit of ECS quantity is set depending on specific service scenarios, defaulting to 2 in this instance.
"ecsInstanceGroup": {
      "Properties": {
        "ImageId": "centos7u2_64_40G_cloudinit_20160520.raw",
        "InstanceType": "ecs.s2.large",
        "MaxAmount": {
          "Ref": "EcsMaxAmount"
        },
        "MinAmount": 2,
        "SecurityGroupId": {
          "Fn::GetAtt": [
            "securityGroup",
            "SecurityGroupId"
          ]
        }
      },
      "Type": "ALIYUN::ECS::InstanceGroup"
    },
"securityGroup": {
      "Properties": {
        "SecurityGroupEgress": [
          {
            "DestCidrIp": "0.0.0.0/0",
            "IpProtocol": "all",
            "NicType": "internet",
            "PortRange": "-1/-1",
            "Priority": 1
          }
        ],
        "SecurityGroupIngress": [
          {
            "IpProtocol": "all",
            "NicType": "internet",
            "PortRange": "-1/-1",
            "Priority": 1,
            "SourceCidrIp": "0.0.0.0/0"
          }
        ],
        "SecurityGroupName": {
          "Ref": "SecurityGroupName"
        }
      },
      "Type": "ALIYUN::ECS::SecurityGroup"
    }


• Step 2:  Create a load balance and set the port mapping as 80 -> 8080
"LoadBalancer": {
      "Properties": {
        "AddressType": "internet",
        "InternetChargeType": "paybytraffic",
        "LoadBalancerName": "createByRos"
      },
      "Type": "ALIYUN::SLB::LoadBalancer"
    },
    "CreateListener": {
      "Type": "ALIYUN::SLB::Listener",
      "Properties": {
          "LoadBalancerId": {"Ref": "LoadBalancer"},
          "ListenerPort": "80",
          "BackendServerPort": 8080,
          "Bandwidth": 1,
          "Protocol": "http",
          "HealthCheck": {
              "HealthyThreshold": 3,
              "UnhealthyThreshold": 3,
              "Interval": 2,
              "Timeout": 5,
              "HttpCode": "http_2xx,http_3xx,http_4xx,http_5xx"
          },
          "Scheduler": "wrr"
      }
    }


• Step 3:  Mount ECS under SLB and set the same weight
"Attachment": {
      "Properties": {
        "BackendServerList":
        {
          "Fn::GetAtt": [
            "ecsInstanceGroup",
            "InstanceIds"
          ]
        },
        "LoadBalancerId": {
          "Ref": "LoadBalancer"
        }
      },
      "Type": "ALIYUN::SLB::BackendServerAttachment"
    }


• Step 4:  Create RDS instances and set the access whitelist
"RDSInstance": {
      "Properties": {
        "ConnectionMode": "Safty",
        "DBInstanceClass": "rds.mys2.large",
        "DBInstanceDescription": "createByRos",
        "DBInstanceNetType": "Intranet",
        "DBInstanceStorage": "100",
        "Engine": "MySQL",
        "EngineVersion": "5.6",
        "SecurityIPList": {
          "Fn::GetAtt": [
            "ecsInstanceGroup",
            "PrivateIps"
          ]
        }
      },
      "Type": "ALIYUN::RDS::DBInstance"
    }
Guest