k8s deployment控制器水平扩容

1. k8s-deployment水平扩缩容(启动多实例,提高并发)

  • 第一种方式,修改配置文件

    修改yaml里replicas值,再apply
    
  • 使用命令方式扩容

    kubectl scale deployment web --replicas=10
    
  • 注:replicas参数控制Pod副本数量

2. 使用命令方式进行扩容

  • 先查询pod

    [root@k8s-master deployment]# kubectl get pods
    NAME                  READY   STATUS    RESTARTS   AGE
    web-548b9bcc8-fktlm   1/1     Running   0          97m
    web-548b9bcc8-njf5m   1/1     Running   0          97m
    web-548b9bcc8-prxff   1/1     Running   0          97m
    
  • 进行扩容

    [root@k8s-master deployment]# kubectl scale deployment web  --replicas=9
    deployment.apps/web scaled
    
  • 验证

    [root@k8s-master deployment]# kubectl get pods
    NAME                  READY   STATUS    RESTARTS   AGE
    web-548b9bcc8-2mrx9   1/1     Running   0          74s
    web-548b9bcc8-2qg7h   1/1     Running   0          74s
    web-548b9bcc8-fktlm   1/1     Running   0          98m
    web-548b9bcc8-kn8zp   1/1     Running   0          74s
    web-548b9bcc8-njf5m   1/1     Running   0          98m
    web-548b9bcc8-prxff   1/1     Running   0          98m
    web-548b9bcc8-rxflx   1/1     Running   0          74s
    web-548b9bcc8-wnfp6   1/1     Running   0          74s
    web-548b9bcc8-x24pv   1/1     Running   0          74s
    
posted @ 2021-10-29 18:23  七月流星雨  阅读(253)  评论(0编辑  收藏  举报