测试Hpa自动扩缩容

一、Hpa设置

  • 最大pod副本数为5,最小pod副本数为3
  • 平均cpu为10%
    image

二、查看当前pod资源消耗

`kubectl top pod -n test`

image

三、创建一个service服务,type使用NodePort,方便压测

apiVersion: v1
kind: Service
metadata:
  name: nginx-service
  namespace: test
spec:
  selector:
    app: nginx
  ports:
    - protocol: TCP
      targetPort: 80
      port: 80
  type: NodePort
  sessionAffinity: ClientIP

四、 压测工具使用jmeter

image
image

五、接下来设置并发用户数(线程数),并持续压测,观察pod、hpa情况

  • 持续监控pod资源占用率
    watch -n 1 kubectl top pod -n test
    image

  • 持续监控hpa情况
    kubectl get hpa -n test -w
    image

  • 持续查看pod情况
    kubectl get pod -n test -w

六、通过观察发现,当压力上来后,pod自动扩容了,负载减小后,默认缩容时间绪等待5分钟

image

posted @ 2022-12-06 17:24  弩哥++  阅读(55)  评论(0)    收藏  举报