클라우드 관리자는 VMware Avi Load Balancer 리소스를 활용하여 인프라를 구축할 수 있습니다. 할당 도우미를 사용하여 Avi Load Balancer 리소스에 대한 할당 논리를 제공할 수도 있습니다.

시작하기 전에

템플릿 예제를 시작하기 전에 Automation Assembler에서 Avi Load Balancer 클라우드 계정을 생성하고, 프로젝트를 생성하고, 클라우드 영역을 추가해야 합니다. 자세한 내용은 VMware Avi Load Balancer 클라우드 계정 생성에서 참조하십시오.

단순 LBaaS 템플릿

이 샘플 템플릿은 최소 입력으로 가상 서비스, 풀 및 가상 IP 리소스를 생성하는 방법을 보여줍니다.

이 예에 사용된 모든 Avi Load Balancer 리소스는 Avi Load Balancer 컨트롤러를 가리키는 Avi Load Balancer 구조를 나타냅니다.

이 템플릿에 프로비저닝된 시스템이나 서버가 없습니다. 지속적으로 업데이트할 수 있는 서버 목록을 가져옵니다.

템플릿은 기본적으로 빈 풀로 설정되지만 실제 IP를 입력할 수 있도록 양식과 입력이 설정되어 일반 풀이 생성됩니다.

formatVersion: 1
name: ALB - LBaaS Demo - Simple
version: 1
inputs:
  port:
    type: integer
    title: Port
    description: Traffic sent to servers will use this destination server port unless overridden by the server's specific port attribute.
    default: 80
  servers:
    type: array
    title: Servers
    description: The pool directs load balanced traffic to this list of destination servers. The servers can be configured by IP address, name, network or via IP Address Group. Leaving 0.0.0.0 will result in an empty pool being created.
    items:
      type: string
    minItems: 0
    default:
      - 0.0.0.0
resources:
  VIP:
    type: Idem.AVILB.APPLICATIONS.VS_VIP
    properties:
      name: vip-${uuid()}
      account: avi-account
      description: Managed by Aria Automation
      vip:
        - vip_id: 0
          auto_allocate_ip: true
          ipam_network_subnet:
            network_ref: VMNetwork-PortGroup
  VirtualService:
    type: Idem.AVILB.APPLICATIONS.VIRTUAL_SERVICE
    properties:
      name: vs-${uuid()}
      account: avi-account
      description: Managed by Aria Automation
      services:
        - port: ${input.port}
      pool_ref: ${resource.Pool.name}
      vsvip_ref: ${resource.VIP.name}
  Pool:
    type: Idem.AVILB.APPLICATIONS.POOL
    properties:
      name: pool-${uuid()}
      account: avi-account
      description: Managed by Aria Automation
      default_server_port: ${input.port}
      servers: '${input.servers[0] == "0.0.0.0" ? null :map_by(input.servers, address => {"ip": {"addr": address, "type" : "V4"}})}'

고급 LBaaS 템플릿

이 샘플 템플릿은 클라우드 영역 할당 도우미와 함께 기존 네트워크에 연결된 가상 서비스, 풀 및 가상 IP 리소스를 생성하는 방법을 보여줍니다. 또한 풀은 시스템 HTTP 상태 모니터로 구성됩니다.

formatVersion: 1
name: ALB - LBaaS Demo
version: 1
inputs:
  env:
    type: string
    title: Environment
    description: Select Dev or Prod ALB environment
    default: env:dev
    oneOf:
      - title: Dev ALB
        const: env:dev
      - title: Prod ALB
        const: env:prod
  port:
    type: integer
    title: Port
    description: Input the server ip's to add to the pool.
    default: 80
  servers:
    type: array
    title: Servers
    description: Input the server ip's to add to the pool. Leaving 0.0.0.0 will result in an empty pool being created.
    items:
      type: string
    minItems: 0
    default:
      - 0.0.0.0
resources:
  Allocations_CloudZone_1:
    type: Allocations.CloudZone
    properties:
      accountType: avilb
      constraints:
        - tag: ${input.env}
  VIP:
    type: Idem.AVILB.APPLICATIONS.VS_VIP
    properties:
      name: vip-${uuid()}
      account: ${resource.Allocations_CloudZone_1.selectedCloudAccount.name}
      description: Managed by Aria Automation
      vip:
        - vip_id: 0
          auto_allocate_ip: true
          ipam_network_subnet:
            network_ref: ${resource.Cloud_vSphere_Network_1.resourceName}
  VirtualService:
    type: Idem.AVILB.APPLICATIONS.VIRTUAL_SERVICE
    properties:
      name: vs-${uuid()}
      account: ${resource.Allocations_CloudZone_1.selectedCloudAccount.name}
      description: Managed by Aria Automation
      services:
        - port: ${input.port}
      pool_ref: ${resource.Pool.name}
      vsvip_ref: ${resource.VIP.name}
  Pool:
    type: Idem.AVILB.APPLICATIONS.POOL
    properties:
      name: pool-${uuid()}
      account: ${resource.Allocations_CloudZone_1.selectedCloudAccount.name}
      description: Managed by Aria Automation
      default_server_port: ${input.port}
      servers: '${input.servers[0] == "0.0.0.0" ? null :map_by(input.servers, address => {"ip": {"addr": address, "type" : "V4"}})}'
      health_monitor_refs:
        - System-HTTP
  Cloud_vSphere_Network_1:
    type: Cloud.vSphere.Network
    properties:
      networkType: existing
      constraints:
        - tag: net:vm

간단한 웹 서버 템플릿

이 샘플 템플릿은 기존 네트워크에 연결된 가상 서비스, 풀, 가상 IP 및 2개의 웹 서버 가상 시스템 리소스를 생성하는 방법을 보여줍니다. 풀은 라운드 로빈 알고리즘을 사용하여 포트 80을 모니터링하도록 구성됩니다.

formatVersion: 1
name: ALB - Web Servers
version: 1
inputs:
  env:
    type: string
    title: Environment
    description: Select Dev or Prod ALB environment
    default: env:dev
    oneOf:
      - title: Dev ALB
        const: env:dev
      - title: Prod ALB
        const: env:prod
  clusterSize:
    type: string
    enum:
      - small
      - medium
      - large
    default: small
    title: Web Server Cluster Size
    description: Web Server Cluster Size. Small creates one web server and no ALB. Medium creates 2 web servers and a ALB. Large creates 4 web servers and a ALB.
  username:
    type: string
    title: Username
    default: demouser
  password:
    type: string
    title: Password
    encrypted: false
    default: VMware1!
  port:
    type: integer
    title: Port
    default: 80
  health_monitor:
    type: array
    items:
      type: string
    title: Health Monitors
    default:
      - System-HTTP
    minItems: 1
    maxItems: 10
  lb_algorithm:
    type: string
    title: Load Balancer Algorithm
    description: The load balancing algorithm will pick a server within the pool's list of available servers.
    readOnly: false
    default: LB_ALGORITHM_LEAST_CONNECTIONS
    oneOf:
      - title: Least Connections
        const: LB_ALGORITHM_LEAST_CONNECTIONS
      - title: Round Robin
        const: LB_ALGORITHM_ROUND_ROBIN
      - title: Fastest Response
        const: LB_ALGORITHM_FASTEST_RESPONSE
      - title: Consistent Hash
        const: LB_ALGORITHM_CONSISTENT_HASH
      - title: Least Load
        const: LB_ALGORITHM_LEAST_LOAD
      - title: Fewest Servers
        const: LB_ALGORITHM_FEWEST_SERVERS
      - title: Random
        const: LB_ALGORITHM_RANDOM
      - title: Fewest Tasks
        const: LB_ALGORITHM_FEWEST_TASKS
      - title: Core Affinity
        const: LB_ALGORITHM_CORE_AFFINITY
resources:
  ALB_HEALTH_MONITOR:
    type: Idem.AVILB.PROFILES.HEALTH_MONITOR
    properties:
      name: web-health-${uuid()}
      description: Managed by Aria Assembler
      type: ${input.health_monitor}
      account: ${resource.Allocations_CloudZone_1.selectedCloudAccount.name}
  Allocations_CloudZone_1:
    type: Allocations.CloudZone
    properties:
      accountType: avilb
      constraints:
        - tag: ${input.env}
  ALB_APPLICATION_PERSISTENCE_PROFILE:
    type: Idem.AVILB.PROFILES.APPLICATION_PERSISTENCE_PROFILE
    properties:
      name: apache-appprofile-${uuid()}
      account: ${resource.Allocations_CloudZone_1.selectedCloudAccount.name}
      description: Managed by Aria Automation
      persistence_type: PERSISTENCE_TYPE_CLIENT_IP_ADDRESS
      server_hm_down_recovery: HM_DOWN_PICK_NEW_SERVER
      ip_persistence_profile:
        ip_mask: 24
        ip_persistent_timeout: 20
  SecurityGroup:
    type: Cloud.SecurityGroup
    properties:
      constraints:
        - tag: ${input.env}
      securityGroupType: existing
  VIP:
    type: Idem.AVILB.APPLICATIONS.VS_VIP
    properties:
      name: web-vip-${uuid()}
      description: Managed by Aria Automation
      count: ${input.clusterSize == "small" ? 0:1}
      account: ${resource.Allocations_CloudZone_1.selectedCloudAccount.name}
      vip:
        - vip_id: 0
          auto_allocate_ip: true
          ipam_network_subnet:
            network_ref: ${resource.Cloud_vSphere_Network_1.resourceName}
  VirtualService:
    type: Idem.AVILB.APPLICATIONS.VIRTUAL_SERVICE
    properties:
      name: web-vs-${uuid()}
      description: Managed by Aria Assembler
      count: ${input.clusterSize == "small" ? 0:1}
      account: ${resource.Allocations_CloudZone_1.selectedCloudAccount.name}
      cloud_type: CLOUD_VCENTER
      services:
        - port: ${input.port}
      vsvip_ref: ${resource.VIP[0].name}
      pool_ref: ${resource.Pool[0].name}
  Pool:
    type: Idem.AVILB.APPLICATIONS.POOL
    properties:
      name: web-pool-${uuid()}
      description: Managed by Aria Automation
      count: ${input.clusterSize == "small" ? 0:1}
      account: ${resource.Allocations_CloudZone_1.selectedCloudAccount.name}
      default_server_port: ${input.port}
      health_monitor_refs:
        - ${resource.ALB_HEALTH_MONITOR.name}
      lb_algorithm: ${input.lb_algorithm}
      application_persistence_profile_ref: ${resource.ALB_APPLICATION_PERSISTENCE_PROFILE.name}
      servers: '${map_by(resource.Web_Server[*].address, address => {"ip": {"addr": address, "type" : "V4"}})}'
  Web_Server:
    type: Cloud.vSphere.Machine
    properties:
      name: web
      count: 2
      flavor: small
      imageRef: https://cloud-images.ubuntu.com/releases/18.04/release/ubuntu-18.04-server-cloudimg-amd64.ova
      cloudConfig: |
        packages:
          - apache2
          - open-vm-tools

        runcmd:
          ### update the top of the web page to the web servers resource name
          - sed -i 's/Apache2 Ubuntu Default Page/${self.resourceName}/g' /var/www/html/index.html
          
          ### Restart services
          - systemctl reload apache2
          - systemctl restart apache2
          
          ### Log completion
          - echo 'Cloud-init is done!' >> /tmp/finished.txt
      networks:
        - network: ${resource.Cloud_vSphere_Network_1.id}
          securityGroups:
            - ${resource.SecurityGroup.id}
  Cloud_vSphere_Network_1:
    type: Cloud.vSphere.Network
    properties:
      networkType: existing
      constraints:
        - tag: net:vm

고급 웹 서버 템플릿

이 템플릿은 클라우드 영역 할당 도우미와 함께 기존 네트워크에 연결된 가상 서비스, 풀 및 가상 IP 리소스를 생성하는 방법을 보여줍니다. 또한 상태 모니터 및 애플리케이션 지속성 프로파일이 풀에 생성 및 구성됩니다. 마지막으로 보안 그룹은 태그로 열거되고 VM 웹 서버가 여기에 추가됩니다.

formatVersion: 1
name: ALB - Web Servers
version: 1
inputs:
  env:
    type: string
    title: Environment
    description: Select Dev or Prod ALB environment
    default: env:dev
    oneOf:
      - title: Dev ALB
        const: env:dev
      - title: Prod ALB
        const: env:prod
  clusterSize:
    type: string
    enum:
      - small
      - medium
      - large
    default: small
    title: Web Server Cluster Size
    description: Web Server Cluster Size. Small creates one web server and no ALB. Medium creates 2 web servers and a ALB. Large creates 4 web servers and a ALB.
  username:
    type: string
    title: Username
    default: demouser
  password:
    type: string
    title: Password
    encrypted: false
    default: VMware1!
  port:
    type: integer
    title: Port
    default: 80
  health_monitor:
    type: array
    items:
      type: string
    title: Health Monitors
    default:
      - System-HTTP
    minItems: 1
    maxItems: 10
  lb_algorithm:
    type: string
    title: Load Balancer Algorithm
    description: The load balancing algorithm will pick a server within the pool's list of available servers.
    readOnly: false
    default: LB_ALGORITHM_LEAST_CONNECTIONS
    oneOf:
      - title: Least Connections
        const: LB_ALGORITHM_LEAST_CONNECTIONS
      - title: Round Robin
        const: LB_ALGORITHM_ROUND_ROBIN
      - title: Fastest Response
        const: LB_ALGORITHM_FASTEST_RESPONSE
      - title: Consistent Hash
        const: LB_ALGORITHM_CONSISTENT_HASH
      - title: Least Load
        const: LB_ALGORITHM_LEAST_LOAD
      - title: Fewest Servers
        const: LB_ALGORITHM_FEWEST_SERVERS
      - title: Random
        const: LB_ALGORITHM_RANDOM
      - title: Fewest Tasks
        const: LB_ALGORITHM_FEWEST_TASKS
      - title: Core Affinity
        const: LB_ALGORITHM_CORE_AFFINITY
resources:
  ALB_HEALTH_MONITOR:
    type: Idem.AVILB.PROFILES.HEALTH_MONITOR
    properties:
      name: web-health-${uuid()}
      description: Managed by Aria Assembler
      type: ${input.health_monitor}
      account: ${resource.Allocations_CloudZone_1.selectedCloudAccount.name}
  Allocations_CloudZone_1:
    type: Allocations.CloudZone
    properties:
      accountType: avilb
      constraints:
        - tag: ${input.env}
  ALB_APPLICATION_PERSISTENCE_PROFILE:
    type: Idem.AVILB.PROFILES.APPLICATION_PERSISTENCE_PROFILE
    properties:
      name: apache-appprofile-${uuid()}
      account: ${resource.Allocations_CloudZone_1.selectedCloudAccount.name}
      description: Managed by Aria Automation
      persistence_type: PERSISTENCE_TYPE_CLIENT_IP_ADDRESS
      server_hm_down_recovery: HM_DOWN_PICK_NEW_SERVER
      ip_persistence_profile:
        ip_mask: 24
        ip_persistent_timeout: 20
  SecurityGroup:
    type: Cloud.SecurityGroup
    properties:
      constraints:
        - tag: ${input.env}
      securityGroupType: existing
  VIP:
    type: Idem.AVILB.APPLICATIONS.VS_VIP
    properties:
      name: web-vip-${uuid()}
      description: Managed by Aria Automation
      count: ${input.clusterSize == "small" ? 0:1}
      account: ${resource.Allocations_CloudZone_1.selectedCloudAccount.name}
      vip:
        - vip_id: 0
          auto_allocate_ip: true
          ipam_network_subnet:
            network_ref: ${resource.Cloud_vSphere_Network_1.resourceName}
  VirtualService:
    type: Idem.AVILB.APPLICATIONS.VIRTUAL_SERVICE
    properties:
      name: web-vs-${uuid()}
      description: Managed by Aria Assembler
      count: ${input.clusterSize == "small" ? 0:1}
      account: ${resource.Allocations_CloudZone_1.selectedCloudAccount.name}
      cloud_type: CLOUD_VCENTER
      services:
        - port: ${input.port}
      vsvip_ref: ${resource.VIP[0].name}
      pool_ref: ${resource.Pool[0].name}
  Pool:
    type: Idem.AVILB.APPLICATIONS.POOL
    properties:
      name: web-pool-${uuid()}
      description: Managed by Aria Automation
      count: ${input.clusterSize == "small" ? 0:1}
      account: ${resource.Allocations_CloudZone_1.selectedCloudAccount.name}
      default_server_port: ${input.port}
      health_monitor_refs:
        - ${resource.ALB_HEALTH_MONITOR.name}
      lb_algorithm: ${input.lb_algorithm}
      application_persistence_profile_ref: ${resource.ALB_APPLICATION_PERSISTENCE_PROFILE.name}
      servers: '${map_by(resource.Web_Server[*].address, address => {"ip": {"addr": address, "type" : "V4"}})}'
  Web_Server:
    type: Cloud.vSphere.Machine
    properties:
      name: web
      count: 2
      flavor: small
      imageRef: https://cloud-images.ubuntu.com/releases/18.04/release/ubuntu-18.04-server-cloudimg-amd64.ova
      cloudConfig: |
        packages:
          - apache2
          - open-vm-tools

        runcmd:
          ### update the top of the web page to the web servers resource name
          - sed -i 's/Apache2 Ubuntu Default Page/${self.resourceName}/g' /var/www/html/index.html
          
          ### Restart services
          - systemctl reload apache2
          - systemctl restart apache2
          
          ### Log completion
          - echo 'Cloud-init is done!' >> /tmp/finished.txt
      networks:
        - network: ${resource.Cloud_vSphere_Network_1.id}
          securityGroups:
            - ${resource.SecurityGroup.id}
  Cloud_vSphere_Network_1:
    type: Cloud.vSphere.Network
    properties:
      networkType: existing
      constraints:
        - tag: net:vm