hpa 动态扩展

方式
https://kubernetes.io/zh/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/
kubectl autoscale deployment php-apache --cpu-percent=50 --min=1 --max=10
kubectl autoscale deployment nginx-deployment --cpu-percent=50 --min=1 --max=10 --dry-run=client -oyaml
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  creationTimestamp: null
  name: php-apache
spec:
  maxReplicas: 10
  minReplicas: 1
  scaleTargetRef:  ### 将要扩展的目标引用
    apiVersion: apps/v1
    kind: Deployment
    name: php-apache  ## Pod limit: 100m  
  targetCPUUtilizationPercentage: 50  ### cpu使用超过50%就扩容,低于就缩容

### 计算方式  100m   100m   100m   100m  100m  
#  kubectl run -i --tty load-generator --rm --image=busybox --restart=Never -- /bin/sh -c "while sleep 0.01; do wget -q -O- http://php-apache; done"
posted @ 2022-05-29 12:35  z_先生  阅读(26)  评论(0编辑  收藏  举报