LAB-08:Pod 扩容

LAB-08:Pod 扩容

LAB 需求

扩容名字为 loadbalancer 的 deployment 的副本数为 6

LAB 预配

# 创建一个名为 loadbalancer 的 deployment
user1@k8s-master:~/cka-2022-05-01/8$ cat loadbalancer.yaml 
apiVersion: apps/v1
kind: Deployment 
metadata:
  name: loadbalancer 
spec:
  replicas: 1
  selector:
    matchLabels:
      app: loadbalancer 
  template:
    metadata:
      labels:
        app: loadbalancer
    spec:
      containers:
      - name: nginx 
        image: nginx:1.18.0
        imagePullPolicy: IfNotPresent

# 部署 loadbalancer 应用
user1@k8s-master:~/cka-2022-05-01/8$ kubectl apply -f loadbalancer.yaml 
deployment.apps/loadbalancer created

# 查看 webserver 的 pod 数量
user1@k8s-master:~$ kubectl get pod loadbalancer-85767b4556-lddwx 
NAME                            READY   STATUS    RESTARTS   AGE
loadbalancer-85767b4556-lddwx   1/1     Running   0          23s

LAB 答案

# 切换 content
$ kubectl config use-context k8s

# 扩容副本为 6
$ kubectl scale deployment loadbalancer --replicas=6

LAB 验证

# 查看 pod 副本
user1@k8s-master:~$ kubectl get pod | grep loadbalancer-85767b4556
loadbalancer-85767b4556-8k5wg            1/1     Running       0               30s
loadbalancer-85767b4556-fkvkq            1/1     Running       0               30s
loadbalancer-85767b4556-lddwx            1/1     Running       0               2m49s
loadbalancer-85767b4556-v2kpx            1/1     Running       0               30s
loadbalancer-85767b4556-v8wg8            1/1     Running       0               30s
loadbalancer-85767b4556-xvkqd            1/1     Running       0               30s

参考资料

  • https://kubernetes.io/zh/docs/concepts/workloads/controllers/deployment/



posted @ 2022-06-21 15:16  武装小灰灰  阅读(47)  评论(0编辑  收藏  举报