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

k8s deployment 怎样指定 1 个 pod 调度到 node1, 2 个 pod 调度到 node2?

  •  
  •   cassidyhere · Oct 10, 2023 · 2547 views
    This topic created in 933 days ago, the information mentioned may be changed or developed.
    10 replies    2023-10-11 09:31:48 +08:00
    zhoudaiyu
        2
    zhoudaiyu  
    PRO
       Oct 10, 2023
    弄两个 Deployment ,除了名字、节点亲和性配置和副本数外啥都一样
    xx6412223
        3
    xx6412223  
       Oct 10, 2023
    你这个问题可以简单理解为:“如何调度 pod”吗?
    和 1 个 2 个有啥关系
    birdhk
        4
    birdhk  
       Oct 10, 2023
    Cola98
        5
    Cola98  
       Oct 10, 2023
    像楼上老哥说的,弄成两个 deployment ,一个是 1 ,一个是 2 ,1 选择 node1 节点,2 选择 node2 节点。可以通过亲和性去设置的
    cheng6563
        6
    cheng6563  
       Oct 10, 2023
    想无脑一点就用这个反亲和,他会优先用不同的 node 调度 pod.

    affinity:
    podAntiAffinity:
    preferredDuringSchedulingIgnoredDuringExecution:
    - podAffinityTerm:
    topologyKey: kubernetes.io/hostname
    weight: 50
    ch2
        7
    ch2  
       Oct 10, 2023
    严格指定的话,得拆开成两个不同的 deployment
    eudore
        8
    eudore  
       Oct 11, 2023
    设置 node 亲和性指定 node1node2 ,优先调度到这两个机器上;设置 pod 反亲和性时同一个 deploy 的 pod 调度到不同的 node 上;在机器数量充足且 node12 在线时,就可以优先选择 node12 ,然后再被反亲分别放到两个 node 上;如果 node 数量不足或 node12 存在下线时会优先 1 个或 2 个 pod(两个亲和规则权重影响)在 node12 ,然后在分配到其他 node 或在同一个 node 上。
    fluyy
        9
    fluyy  
       Oct 11, 2023 via iPhone
    亲和性和反亲和性设置,看看能不能满足
    AmaQuinton
        10
    AmaQuinton  
       Oct 11, 2023
    使用 节点选择器 nodeSelector 和 亲和性 两个搭配是不是可以满足
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2486 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 07:14 · PVG 15:14 · LAX 00:14 · JFK 03:14
    ♥ Do have faith in what you're doing.