关于pod的伸缩
手动更新代码
在对业务代码升级时,如果有多个pod副本在运行,先手动将pod数减少至1个,再对其代码升级更新,代码更新后再将pod复制为多个副本运行。这个样的好处是,如果多个pod副本在运行就开始了代码更新,会导致多个pod副本同时向harbor拉取新的容器,致使harbor的IO负载过高,整个代码更新较慢。也就是说整个代码更新的性能瓶颈在于拉取harbor镜像。
HPA-基于pod的资源利用率对pod自动扩缩容

HPA创建方式
1.创建metrics server,其形式为一个pod
1.1克隆metrics server项目
1.2下载metrics server镜像
1.3将metrics server以pod形式运行
2.修改Controller Manager启动参数
添加如下两项,后重启Controller Manager服务,如果是多台Master,每台都得改
--horizontal-pod-autoscaler-use-rest-clients=false \ #不使用其他客户端数据
--horizontal-pod-autoscaler-sync-period=10s \ #数据采集周期间隔时间
这样,自动扩缩容服务就有了,下面要给某一个deployment配置该服务
3.为deployment配置自动扩缩容服务
# kubectl autoscale deployment/linux-nginx-deployment --min=2 --max=10 --cpupercent=80 -n linux
horizontalpodautoscaler.autoscaling/linux-nginx-deployment autoscaled
查看是否配置成功
# kubectl get hpa -n linux