Containers distribution via Cattle

Hello,
I’am using rancher 1.1.4 and I’d like to know if there is a way to change the way cattle distributes the containers on different hosts.

Today I have 4 hosts (A,B,C and D) and when I scale up a logstash (or whatever) container from 2 to 8 instances, I ended up with :
A => 1 instance
B => 1 instance
C => 2 instances
D => 4 instances

I expected to have something much more like :

A => 2 instances
B => 2 instances
C => 2 instances
D => 2 instances

When using swarm I can choose between 3 strategies : binpack, spread or round robin. Does something similar exists in Cattle?

Thank you

1 Like

We had the same problem today. An equal distribution is critical for our infrastructure, so I scaled down and up until this state was reached. Strange is that it “just worked” the last time I setup the environment.

I think I’ve found an answer to this phenomenon : Cattle does not distribute containers equaly across the stack, but across hosts.

Suppose you have 2 hosts (A and B). You also have one stack called firstStack with 3 containers on hosts “A”:

A => (firstStack)( [x] [x] [x] ) B => (firstStack)( )

Now, suppose that you create a new stack called “secondStack” and you start deploying one container inside, then you scale up to 3 instances. You will have something like this :

A => (firstStack)( [x] [x] [x] ) - (secondStack)( ) B => (firstStack)( ) - (secondStack)( [x] [x] [x] )

Because Cattle considers all containers across hosts, it begins to pack them on the host B because A already had 3 containers.

Then, if you continue to scale up to 6, I think you may have something like this :

A => (firstStack)( [x] [x] [x] ) - (secondStack)( [x] [x]) B => (firstStack)( ) - (secondStack)( [x] [x] [x] [x] )

It’s true that if you focuse on your secondStack, you will see a disorder in the distribution of its containers (4 on B and 2 on A), but if you consider firstStack AND secondStack, this distribution seems to be more balanced (5 on A, 4 on B).

1 Like