Distribution of kubernets among nodes

Is there a way to make kubernetes the most common containers? I have "Queries" for all deployments and global queries like HPA. all nodes are the same.

There was simply a situation where my ASG scaled down the node and one of the services became completely inaccessible, since all 4 modules were on the same node, which was reduced.

I would like to support a situation where each deployment must distribute its containers to at least 2 nodes.

+6
source share
1 answer

It looks like you want Inter-Pod Affinity and Pod Anti-affinity .

Affinity and anti-affinity between cells 1.4 were introduced in Kubernetes. Cross-breed affinity and anti-affinity allow you to limit which nodes of your module are allowed to plan based on labels on containers that are already running on node, and not based on labels on nodes. The rules are in the form "this package should (or, in the case of anti-affinity, should not) run in X if X already runs one or more containers that comply with rule Y." Y is expressed as a LabelSelector with an associated list of namespaces (or "all" namespaces); Unlike nodes, because containers have a namespace (and therefore labels on containers are implicitly called spaces), the selector label above label labels should indicate which namespace to apply the selector to. Conceptually, X is a topology area such as node, persistent, cloud provider area, cloud provider region, etc. You express this using the topology, which is the key for the node label, which the system uses to denote such a domain topology, for example. see the labels listed above in the โ€œInterlude: inline node labelsโ€ section.

Anti-affinity can be used to ensure that you distribute your containers in failure domains. You can specify these rules as preferences or hard rules. In the latter case, if it cannot satisfy your restrictions, the module will not be able to schedule.

+3
source

Source: https://habr.com/ru/post/1013177/


All Articles