• LAB08: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/



  • 相关阅读:
    idea 提示不能打开cmd.exe,idea 编译项目 CreateProcess error=740, 请求的操作需要提升 --->如何设置cmd以管理员身份运行
    Maven之--安装nexus 私服
    如何生成effective-pom
    maven之---资源过滤 在java/main/resourse/*.xml ,*.properties引用maven属性${db.username}
    使用JavaMailSender 发送邮件
    spring 读取account-service中的值
    spring web.xml 标签<param-name>contextConfigLocation</param-name>
    application.properties案例
    解决mybatis-plus的updateById报错的问题
    postman百度云下载
  • 原文地址:https://www.cnblogs.com/quqibinggan/p/16396953.html
Copyright © 2020-2023  润新知