V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
jitongxi

k8s 某个 deployment 如何自动伸缩到 node 的数量

  •  
  •   jitongxi · Dec 12, 2023 · 2470 views
    This topic created in 872 days ago, the information mentioned may be changed or developed.

    如果,如何自动伸缩后,保持每个 node 上都有这个 deployment 的 pod

    有没有运维大佬指点一下

    9 replies    2023-12-13 15:28:23 +08:00
    longfei210
        1
    longfei210  
       Dec 12, 2023
    容器编排的控制器改为 DaemonSet
    midjourney
        2
    midjourney  
       Dec 12, 2023   ❤️ 1
    1. Deployment -> DaemonSet
    2. hpa 最小为 node 数量,并开启 pod 节点反亲和
    jitongxi
        3
    jitongxi  
    OP
       Dec 12, 2023
    好了 , 谢谢两位运维大佬
    kevin123456
        4
    kevin123456  
       Dec 12, 2023
    2 楼的#2 是多余的吧
    CivAx
        5
    CivAx  
       Dec 12, 2023   ❤️ 2
    @kevin123456 不多余。如果应用不适用于 DaemonSet ,比如我现有 5 个 Pod 跑在 3 个 node 上,当我的 node scaling 到 20 个的时候我希望 pod 能扩编到 12 个、且均匀分布在所有节点上时,HPA 的 autoscaling + podAntiAffinity 才是正确且优雅的解法,忽视场景粗暴使用 DaemonSet 会造成 Pod 数量过少,或者资源浪费。
    freemoon
        6
    freemoon  
       Dec 13, 2023
    @kevin123456 #4 第一个方法太局限,第二个才是更普遍的做法。
    jitongxi
        7
    jitongxi  
    OP
       Dec 13, 2023
    @midjourney 有个问题,如果用第二种方法,Deployment 特别多的时候,加一个 node ,然后每个都要去改吗
    Insa
        8
    Insa  
       Dec 13, 2023
    @jitongxi 后面加 node 不用调整
    midjourney
        9
    midjourney  
       Dec 13, 2023
    @jitongxi 不需要 hpa 会自动扩容
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2637 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 03:39 · PVG 11:39 · LAX 20:39 · JFK 23:39
    ♥ Do have faith in what you're doing.