文档

试用服务设置私网连接说明

试用服务实例支持VPC私网连接功能,通过私网连接可以打通用户VPC与服务实例所在的VPC,用户在计算巢部署试用服务实例并进行私网访问时可以有效降低网络影响并提升数据安全性。本文介绍如何配置试用服务的私网连接功能。

前提条件

仅服务模板内容中包含SLB(ALIYUN::SLB::LoadBalancer)资源的服务支持私网连接功能。

创建服务

介绍如何创建包含试用服务私网连接功能的服务。

  1. 登录计算巢控制台

  2. 在左侧导航栏中,选择我的服务,并在我的服务页面中选择我创建的服务,然后单击创建新服务

  3. 创建新服务界面,选择私有部署服务并设置服务信息。

    此处只列举试用服务私网连接需要特别配置的参数,其他参数,请参见创建私有部署服务

    1. 录入模板模板内容区域,填写模板内容。模板内容的详细信息,请参见模板示例

      填写模板内容时,需要包含SLB资源,模板中SLB资源定义如下所示。

      Slb:
          Type: ALIYUN::SLB::LoadBalancer
          Properties:
            VpcId:
              Ref: VpcId
            VSwitchId:
              Ref: VSwitchId
            LoadBalancerName:
              Fn::Join:
                - '-'
                - - slb
                  - Ref: ALIYUN::StackName
            PayType:
              Ref: PayType
            PricingCycle:
              Ref: PayPeriodUnit
            Duration:
              Ref: PayPeriod
            AddressType: intranet
            LoadBalancerSpec:
              Ref: LoadBalancerSpec
            AutoPay: true
    2. 开启支持试用

    3. 高级配置(选填)区域,配置试用服务的相关信息。

      • 试用设置处,开启支持试用,并选择服务模板和套餐,然后设置最长试用时间。

        若未创建套餐,可不选择。最长试用时间不能超过30天。

      • 网络设置处,设置试用服务的私网连接参数。

        1. 打开试用服务安全访问配置开关。

        2. 负载均衡处,指定用于创建试用服务实例时,需要打通的SLB资源。

          对于多模板,可以分别配置不同模板中的SLB。

        3. 自定义域名处,输入自定义域名。

          该参数填写后,用户在部署服务实例时可以选择是否使用该自定义域名。

      2023-11-13_17-57-16.png

  4. 单击创建服务,并在弹出的确认弹窗中单击确定

创建试用服务实例

服务商以用户的身份创建包含私网连接的试用服务实例。

此处只列举填写私网连接需要填写的参数,其他参数请参见创建私有部署服务实例

  1. 网络设置区域,选中VPC私网访问

  2. 专有网络信息框中,选择专有网络安全组可用区与交换机

    重要

    由于目前仅支持同可用区私网连接,网络设置中的可用区需要与基础资源配置中的交换机可用区保持一致。

  3. 选中云服务推荐使用以下自定义域名2023-11-13_18-08-37.png

验证私网连接是否生效

以用户视角在已创建的试用服务实例详情页查看具体的网络信息并访问服务。

  • 查看虚拟互联网信息。

    1. 在左侧导航栏中,单击服务实例管理,进入服务实例详情页面。

    2. 单击虚拟互联网页签,查看详细的网络信息。2023-11-13_18-12-28.png

  • 访问服务。

    因服务的个性化配置、依赖云服务支持的地域等情况,您可以通过如下方式找到服务的访问地址并访问服务。

    • 直接使用终端节点域名访问服务。2023-11-13_18-15-23.png

    • 使用自定义域名访问服务。

      若服务配置了自定义域名,则可以直接使用该域名访问终端节点。2023-11-13_18-15-23.png

模板示例

ROSTemplateFormatVersion: '2015-09-01'
Description:
  en: Use the existing VPC、VSWitch, create 1 SLB, 2 ECS instances, and bind all ECS instances to the SLB.
  zh-cn: 使用已有VPC、VSWitch,创建1个SLB、2个ECS实例,并将所有ECS实例绑定到SLB上。
Parameters:
  ZoneId:
    Type: String
    AssociationProperty: ALIYUN::ECS::Instance::ZoneId
    Label:
      en: VSwitch Availability Zone
      zh-cn: 交换机可用区
  VpcId:
    AssociationProperty: ALIYUN::ECS::VPC::VPCId
    Type: String
    Description:
      en: Please search the ID starting with (vpc-xxx) from console-Virtual Private Cloud
      zh-cn: 现有虚拟专有网络的实例ID
    Label:
      en: VPC ID
      zh-cn: 专有网络VPC实例ID
  VSwitchId:
    AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId
    AssociationPropertyMetadata:
      VpcId: ${VpcId}
      ZoneId: ${ZoneId}
    Type: String
    Description:
      en: Instance ID of existing business network switches, console-Virtual Private Cloud-VSwitches under query
      zh-cn: 现有业务网络交换机的实例ID
    Label:
      en: VSwitch ID
      zh-cn: 交换机实例ID
  EcsInstanceType:
    Type: String
    Label:
      en: Instance Type
      zh-cn: 实例类型
    AssociationProperty: ALIYUN::ECS::Instance::InstanceType
    AssociationPropertyMetadata:
      ZoneId: ${ZoneId}
      InstanceChargeType: ${InstanceChargeType}
  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: '[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
  PayType:
    Type: String
    Label:
      en: ECS Instance Charge Type
      zh-cn: 付费类型
    Default: PostPaid
    AllowedValues:
      - PostPaid
      - PrePaid
    AssociationProperty: ChargeType
    AssociationPropertyMetadata:
      LocaleKey: InstanceChargeType
  PayPeriodUnit:
    Type: String
    Description:
      en: The long cycle of purchasing resources. <br>Week is a Week and Month is a Month. <br> The default value is month.<br><b><font color='red'> When ECS instance types are PrePaid valid </b></font>
      zh-cn: 购买资源时长的周期。<br>Week为周,Month为月<br>默认值为月<br><b><font color='red'>当ECS实例类型为PrePaid有效</b></font>
    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
  LoadBalancerSpec:
    Type: String
    AssociationProperty: ALIYUN::SLB::Instance::InstanceType
    Label:
      en: LoadBalancer Specifications
      zh-cn: 负载均衡实例规格
    AssociationPropertyMetadata:
      ZoneId: ${ZoneId}
Resources:
  EcsSecurityGroup:
    Type: ALIYUN::ECS::SecurityGroup
    Properties:
      SecurityGroupName:
        Ref: ALIYUN::StackName
      VpcId:
        Ref: VpcId
      SecurityGroupIngress:
        - PortRange: 80/80
          Priority: 1
          SourceCidrIp: 0.0.0.0/0
          IpProtocol: tcp
          NicType: internet
      SecurityGroupEgress:
        - PortRange: '-1/-1'
          Priority: 1
          IpProtocol: all
          DestCidrIp: 0.0.0.0/0
          NicType: internet
        - PortRange: '-1/-1'
          Priority: 1
          IpProtocol: all
          DestCidrIp: 0.0.0.0/0
          NicType: intranet
  WaitCondition:
    Type: ALIYUN::ROS::WaitCondition
    Properties:
      Count: 1
      Handle:
        Ref: WaitConditionHandle
      Timeout: 300
  WaitConditionHandle:
    Type: ALIYUN::ROS::WaitConditionHandle
  EcsInstanceGroup:
    Type: ALIYUN::ECS::InstanceGroup
    Properties:
      InstanceChargeType:
        Ref: PayType
      PeriodUnit:
        Ref: PayPeriodUnit
      Period:
        Ref: PayPeriod
      IoOptimized: optimized
      SystemDiskCategory: cloud_essd
      SystemDiskSize: 200
      DiskMappings:
        - Category: cloud_essd
          Size: 200
      VpcId:
        Ref: VpcId
      ZoneId:
        Ref: ZoneId
      SecurityGroupId:
        Ref: EcsSecurityGroup
      VSwitchId:
        Ref: VSwitchId
      MaxAmount: 2
      ImageId: centos_7
      InstanceType:
        Ref: EcsInstanceType
      Password:
        Ref: InstancePassword
      AllocatePublicIP: false
      UserData:
        Fn::Sub:
          - |
            #!/bin/bash
            # 挂盘到/disk1
            cat >> /root/InitDataDisk.sh << "EOF"
            #!/bin/bash
            echo "p
            n
            p
            w
            " |  fdisk -u /dev/vdb
            EOF
            /bin/bash /root/InitDataDisk.sh
            rm -f /root/InitDataDisk.sh
            rm -f InitDataDisk.sh
            mkfs -t ext4 /dev/vdb1
            cp /etc/fstab /etc/fstab.bak
            mkdir /disk1
            echo `blkid /dev/vdb1 | awk '{print $2}' | sed 's/\\\"//g'` /disk1 ext4 defaults 0 0 >> /etc/fstab
            mount -a

            # 这里配置安装脚本
            yum install -y nginx
            # 配置启动脚本
            systemctl start nginx.service

            # 执行成功回调WaitCondition结束waitCondition的等待
            ${CurlCli} -d "{\"Data\" : \"Success\", \"status\" : \"SUCCESS\"}"
          - CurlCli:
              Fn::GetAtt:
                - WaitConditionHandle
                - CurlCli
  Slb:
    Type: ALIYUN::SLB::LoadBalancer
    Properties:
      VpcId:
        Ref: VpcId
      VSwitchId:
        Ref: VSwitchId
      LoadBalancerName:
        Fn::Join:
          - '-'
          - - slb
            - Ref: ALIYUN::StackName
      PayType:
        Ref: PayType
      PricingCycle:
        Ref: PayPeriodUnit
      Duration:
        Ref: PayPeriod
      AddressType: intranet
      LoadBalancerSpec:
        Ref: LoadBalancerSpec
      AutoPay: true
  EipSlbAddress:
    Type: ALIYUN::VPC::EIP
    Properties:
      Name:
        Ref: ALIYUN::StackName
      InternetChargeType: PayByTraffic
      Bandwidth: 100
  EipSlbAddressAssociation:
    Type: ALIYUN::VPC::EIPAssociation
    Properties:
      InstanceId:
        Ref: Slb
      AllocationId:
        Ref: EipSlbAddress
  SlbBackendServerAttachment:
    DependsOn:
      - EcsInstanceGroup
    Type: ALIYUN::SLB::BackendServerAttachment
    Properties:
      BackendServerList:
        Fn::GetAtt:
          - EcsInstanceGroup
          - InstanceIds
      LoadBalancerId:
        Ref: Slb
      BackendServerWeightList:
        - 100
        - 100
  SlbListener:
    DependsOn:
      - Slb
    Type: ALIYUN::SLB::Listener
    Properties:
      Persistence:
        CookieTimeout: 60
        StickySession: 'on'
        PersistenceTimeout: 180
        XForwardedFor: 'off'
        StickySessionType: insert
      ListenerPort: 80
      Bandwidth: -1
      HealthCheck:
        HttpCode: http_2xx,http_3xx,http_4xx,http_5xx
        HealthCheckType: tcp
        UnhealthyThreshold: 3
        Timeout: 5
        HealthyThreshold: 3
        Port: 80
        URI: /
        Interval: 2
      LoadBalancerId:
        Ref: Slb
      BackendServerPort: 80
      Protocol: tcp
Outputs:
  Endpoint:
    Description:
      zh-cn: 对外暴露的公网IP地址
      en: Public IP Addresses
    Value:
      Fn::Sub:
        - http://${ServerAddress}
        - ServerAddress:
            Fn::GetAtt:
              - EipSlbAddress
              - EipAddress
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
      - Parameters:
          - ZoneId
        Label:
          default:
            zh-cn: 可用区配置
            en: Zone Configuration
      - Parameters:
          - VpcId
          - VSwitchId
        Label:
          default:
            zh-cn: 选择已有基础资源配置
            en: Choose existing Infrastructure Configuration
      - Parameters:
          - PayType
          - PayPeriodUnit
          - PayPeriod
        Label:
          default:
            en: PayType Configuration
            zh-cn: 付费类型
      - Parameters:
          - EcsInstanceType
          - InstancePassword
        Label:
          default:
            en: Instance Configure
            zh-cn: ECS实例配置
      - Parameters:
          - LoadBalancerSpec
        Label:
          default:
            en: SLB Configure
            zh-cn: 负载均衡配置
            
  • 本页导读 (0)
文档反馈