1、通过下面的定义创建应用的pod
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: 172.20.58.152/tools/hpa-example:latest 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
2、通过下面的服务,模拟负载
kubectl run -i --tty load-generator --rm \ --image=172.20.58.152/middleware/busybox:latest \ --restart=Never -- /bin/sh -c \ "while sleep 0.01; do wget -q -O- http://php-apache; done"
3、通过下面的命令,查看HPA,应用负载的变化,实例数的变化
kubectl get hpa php-apache --watch
其中:
36%是已经扩容到7个实例之后,每个pod的平均cpu使用率
标签:负载,php,run,--,扩缩容,apache,HPA,k8s,cpu From: https://www.cnblogs.com/chuanzhang053/p/17215725.html