跳转至

cce scale

Prerequisites

HPA(HorizontalPodAutoscaler) can increase and decrease pods according to policies.

HPA

When the node resources under the cluster are insufficient or wasted, CA can increase and decrease Node according to the policy.

cluster autoscaler

To use HPA, you need to install an add-on that provides metrics APIs. Select one of the following add-ons based on your cluster version and actual requirements.

Before using the node scaling function, you must install the autoscaler add-on of v1.13.8 or later.

hpa & CA

HPA(HorizontalPodAutoscaler) test

HPA mechanisim

hpa mechanism

Run a demo deployment(Run and expose php-apache server)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
apiVersion: apps/v1
kind: Deployment
metadata:
  name: php-apache
spec:
  selector:
    matchLabels:
      run: php-apache
  template:
    metadata:
      labels:
        run: php-apache
    spec:
      containers:
      - name: php-apache
        image: registry.k8s.io/hpa-example
        ports:
        - containerPort: 80
        resources:
          limits:
            cpu: 500m
          requests:
            cpu: 200m
---
apiVersion: v1
kind: Service
metadata:
  name: php-apache
  labels:
    run: php-apache
spec:
  ports:
  - port: 80
  selector:
    run: php-apache

Resource Management for Pods and Containers

create the deployment

1
2
3
4
5
6
7
8
9
kubectl apply -f https://k8s.io/examples/application/php-apache.yaml
kubectl autoscale deployment php-apache --cpu-percent=50 --min=1 --max=10
kubectl get hpa

# Increase the load 
kubectl run -i --tty load-generator --rm --image=busybox:1.28 --restart=Never -- /bin/sh -c "while sleep 0.01; do wget -q -O- http://php-apache; done"

kubectl get hpa php-apache --watch
kubectl get deployment php-apache

Install the metrics-server plug-in, and add a loop access test to the corresponding load to mode high concurrent requests.

hpa-demo-test

We can view the expansion and contraction process through the log.

hpa-operator-events

Command operation is difficult for many people, but the graphical interface will be much simpler. CCE supports both command operation and easier click configuration through the web interface.

CCE create HPA

Huaweicloud CCE support customedHPA, we can set more step's actions.

customedHPA

HorizontalPodAutoscaler Walkthrough

Using HPA and CA for Auto Scaling of Workloads and Nodes

CA(Cluster autoscaler)

Create a CCE nodepool, update enable the node pool autoscaling.

cluster autoscaling enable

Configure the node scaling rules:

node scaling

Setting CA rules by yaml

Elastic Scaling of CCE Pods to CCI

Elastic Scaling of CCE Pods to CCI

Auto scaling

捐赠本站(Donate)

weixin_pay
如您感觉文章有用,可扫码捐赠本站!(If the article useful, you can scan the QR code to donate))