云容器引擎 CCE-应用扩缩容优先级策略:默认应用扩缩容优先级策略

时间:2024-04-23 19:45:32

默认应用扩缩容优先级策略

使用默认应用扩缩容优先级策略的情况下,集群中存在两个默认CR资源:

  • Balancer CRD对应的CR资源
    apiVersion: autoscaling.volcano.sh/v1alpha1
    kind: Balancer
    metadata:
      name: default-balancer
    spec:
      balancerPolicyTemplateName: default-balancerpolicytemplate
      targets:
      - namespaceSelector:
          matchExpressions:
            - key: kubernetes.io/metadata.name
              operator: Exists
      weight: 10 
    表1 Balancer对象关键参数说明

    字段

    含义

    类型

    备注

    metadata.name

    名称

    String

    必填字段。

    spec. balancerPolicyTemplateName

    优先级策略名称

    String

    必填字段。值为集群中相应BalancerPolicyTemplate CR资源名。

    spec.targets

    优先级策略作用范围

    Slice

    必填字段。举例:

    • 针对default命名空间下的应用生效
      spec:
        targets:
        - namespaceSelector:
            matchLabels:
              kubernetes.io/metadata.name: default
    • 针对default、other、another多个命名空间下的应用生效
      spec:
        targets:
        - namespaceSelector:
            matchExpressions:
              - key: kubernetes.io/metadata.name
                operator: In
                values:
                - default
                - other
                - another
    • 针对所有命名空间下的应用生效
      spec:
        targets:
        - namespaceSelector:
            matchExpressions:
              - key: kubernetes.io/metadata.name
                operator: Exists
    • 只针对名为xxx-xxx-xxx,类型为Deployment的应用生效
      spec:
        targets:
        - objectSelectors:
            - name: xxx-xxx-xxx
              kind: Deployment
    • 只针对命名空间为default,名为xxx-xxx-xxx类型为Deployment的应用生效
      spec:
        targets:
        - namespaceSelector:
            matchLabels:
              kubernetes.io/metadata.name: default
          objectSelectors:
            - name: xxx-xxx-xxx
              kind: Deployment

    spec.weight

    优先级策略权重

    int32

    必填字段。在集群存在多个Balancer 对象资源情况下,某个应用可能存在于多个Balancer对象作用范围的交集中,此时选择weight值大的Balancer对象生效。

  • BalancerPolicyTemplate CRD对应的CR资源
    apiVersion: autoscaling.volcano.sh/v1alpha1
    kind: BalancerPolicyTemplate
    metadata:
      name: default-balancerpolicytemplate
    spec:
      policy:
        policyName: Priority
        priorities:
          priorityGroups:
          - priority: 10
            requirements:
            - key: node.cce.io/billing-mode
              operator: In
              values:
              - post-paid
          - priority: 100
            requirements:
            - key: node.cce.io/billing-mode
              operator: In
              values:
              - pre-paid
          - priority: 1
            requirements:
            - key: kubernetes.io/role
              operator: In
              values:
              - virtual-kubelet
              - bursting
    表2 BalancerPolicyTemplate对象关键参数说明

    字段

    含义

    类型

    备注

    metadata.name

    名称

    String

    必填字段。

    spec.policy

    优先级策略内容

    Struct

    必填字段。

    spec.policy.policyname

    优先级策略名

    String

    必填字段。当前只支持名为“Priority”的优先级策略。

    spec.policy.priorities. priorityGroups

    优先级策略中定义的具体优先级

    Slice

    必填字段。举例:

    • 将包周期节点的优先级设置为100
            priorityGroups:
            - priority: 100
              requirements:
              - key: node.cce.io/billing-mode
                operator: In
                values:
                - pre-paid
    • 将按需计费节点的优先级设置为10
            priorityGroups:
            - priority: 10
              requirements:
              - key: node.cce.io/billing-mode
                operator: In
                values:
                - post-paid
    • 将virtual-kubelet/bursting节点的优先级设置为1
            priorityGroups:
            - priority: 1
              requirements:
              - key: kubernetes.io/role
                operator: In
                values:
                - virtual-kubelet
                - bursting
support.huaweicloud.com/usermanual-cce/cce_10_0746.html