4장. 자동 스케일링에 오케스트레이션 서비스(heat) 사용


자동 스케일링을 제공하는 데 필요한 서비스를 배포한 후 오케스트레이션 서비스(heat)에서 자동 스케일링을 위한 인스턴스를 관리할 수 있도록 환경을 구성해야 합니다.

사전 요구 사항

  • 배포된 Red Hat OpenStack Services on OpenShift(RHOSO) 환경.
  • 컨트롤 플레인에서 Ceilometer, 자동 확장, MetricStorage 및 오케스트레이션 서비스가 활성화됩니다.

4.1. 자동 스케일링을 위한 heat 템플릿 구성

프로세스

인스턴스를 생성하고 트리거할 때 인스턴스를 생성하고 확장하는 알람을 구성하도록 오케스트레이션 서비스(heat) 템플릿을 구성할 수 있습니다. 이 절차에서는 환경과 다를 수 있는 예제 값을 사용합니다.

사전 요구 사항

  • 자동 확장 서비스와 함께 클라우드를 배포했습니다.

프로세스

  1. openstackclient Pod에 액세스합니다.

    $ oc rsh openstackclient
  2. 템플릿의 디렉터리를 생성합니다(예: /tmp/templates/:)

    $ mkdir -p /tmp/templates
  3. 인스턴스 구성 템플릿을 생성합니다(예: /tmp/templates/instance.yaml ):
  4. instance.yaml 파일에 다음 구성을 추가합니다.

    cat <<EOF > /tmp/templates/instance.yaml
    heat_template_version: wallaby
    description: Template to control scaling of VNF instance
    
    parameters:
      metadata:
        type: json
      image:
        type: string
        description: image used to create instance
        default: cirros
      flavor:
        type: string
        description: instance flavor to be used
        default: m1.small
      network:
        type: string
        description: project network to attach instance to
        default: private
      external_network:
        type: string
        description: network used for floating IPs
        default: public
    
    resources:
      vnf:
        type: OS::Nova::Server
        properties:
          flavor: {get_param: flavor}
          image: { get_param: image }
          metadata: { get_param: metadata }
          networks:
            - port: { get_resource: port }
    
      port:
        type: OS::Neutron::Port
        properties:
          network: {get_param: network}
          security_groups:
            - basic
    
      floating_ip:
        type: OS::Neutron::FloatingIP
        properties:
          floating_network: {get_param: external_network }
    
      floating_ip_assoc:
        type: OS::Neutron::FloatingIPAssociation
        properties:
          floatingip_id: { get_resource: floating_ip }
          port_id: { get_resource: port }
    EOF
  5. heat 템플릿에서 참조할 리소스를 생성합니다.

    $ cat <<EOF > /tmp/templates/resources.yaml
    resource_registry:
      "OS::Nova::Server::VNF": /tmp/templates/instance.yaml
    EOF
  6. 오케스트레이션 서비스에 대한 배포 템플릿을 생성하여 인스턴스 스케일링을 제어합니다.

    cat <<EOF > /tmp/templates/autoscaling.yaml
    heat_template_version: wallaby
    description: Example auto scale group, policy and alarm
    resources:
      autoscalinggroup:
        type: OS::Heat::AutoScalingGroup
        properties:
          cooldown: 300
          desired_capacity: 1
          max_size: 3
          min_size: 1
          resource:
            # Configure the resource to be autoscaled
            type: OS::Nova::Server::VNF
            properties:
              metadata: {"metering.server_group": {get_param: "OS::stack_id"}}
    
      scaleup_policy:
        type: OS::Heat::ScalingPolicy
        properties:
          adjustment_type: change_in_capacity
          auto_scaling_group_id: { get_resource: autoscalinggroup }
          cooldown: 300
          scaling_adjustment: 1
    
      scaledown_policy:
        type: OS::Heat::ScalingPolicy
        properties:
          adjustment_type: change_in_capacity
          auto_scaling_group_id: { get_resource: autoscalinggroup }
          cooldown: 300
          scaling_adjustment: -1
    
      cpu_alarm_high:
        type: OS::Aodh::PrometheusAlarm
        properties:
          description: Scale up if CPU > 80%
          threshold: 80 # 80%
          comparison_operator: gt
          alarm_actions:
            - str_replace:
                template: trust+url
                params:
                  url: {get_attr: [scaleup_policy, signal_url]}
          query:
            str_replace:
              # ceilometer_cpu metric is in ns. Divide the rate by 10000000 to get percentage
              # The time duration in [] should be higher than ceilometer polling interval
              # You can add {ceilometer polling} to {prometheus scrape interval} to calculate the value.
              # The default value is 150s.
              template: "(rate(ceilometer_cpu{server_group=~'stack_id'}[150s]))/10000000"
              params:
                stack_id: {get_param: OS::stack_id}
    
      cpu_alarm_low:
        type: OS::Aodh::PrometheusAlarm
        properties:
          description: Scale up if CPU < 20%
          threshold: 20 # 20%
          comparison_operator: lt
          alarm_actions:
            - str_replace:
                template: trust+url
                params:
                  url: {get_attr: [scaledown_policy, signal_url]}
          query:
            str_replace:
              # ceilometer_cpu metric is in ns. Divide the rate by 10000000 to get percentage
              # The time duration in [] should be higher than ceilometer polling interval
              # You can add {ceilometer polling} to {prometheus scrape interval} to calculate the value.
              # The default value is 150s.
              template: "(rate(ceilometer_cpu{server_group=~'stack_id'}[150s]))/10000000"
              params:
                stack_id: {get_param: OS::stack_id}
    
    outputs:
      scaleup_policy_signal_url:
        value: {get_attr: [scaleup_policy, signal_url]}
    
      scaledown_policy_signal_url:
        value: {get_attr: [scaledown_policy, signal_url]}
    EOF
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 문서 정보

Legal Notice

Theme

© 2026 Red Hat
맨 위로 이동