How can I ensure two replicas are on different node types using Karpenter?

0
10
Asked By CuriousCoder99 On

I'm trying to configure a deployment with 2 replicas in Kubernetes, where each replica is scheduled on different nodes of different instance types. For example, I want one replica on a node of type X1 and the other on type X2, rather than having both on X1 nodes, even if they are different X1 nodes. I've set up some anti-affinity rules for this, but I'm running into issues with Karpenter not provisioning nodes of the required class. However, I've discovered that deleting existing nodes allows Karpenter to refresh and provision the necessary nodes. Any advice or tips would be appreciated!

3 Answers

Answered By DevNinja42 On

It sounds like what you're trying to do is a bit unconventional, as replicas are generally identical. However, your approach with anti-affinity rules is on the right track. Have you considered using `topologySpreadConstraints` with `maxSkew: 1`? This should help you spread the pods across different node types. Just remember to check if your `Provisioner` resource allows for both instance types under its requirements.

Answered By TechWhisperer17 On

If balancing between two node types becomes tricky, one simple solution might be to create two separate deployments—one for each instance type. You could use node selectors to manage where each deployment goes. Alternatively, adding the node class to your `topologySpreadConstraints` could help, though it might be less effective with very few nodes.

Answered By CloudGuru88 On

Using Azure Spot nodes is a smart move, especially for stability. Your idea of having different node types for replicas makes sense to avoid losing them all at once when Azure reclaims nodes. If you’re having issues with node provisioning, just deleting existing nodes like you mentioned can definitely help reset things and allow Karpenter to do its job efficiently.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.