Skip to content

Anti-affinity for k8s nodes (#226) - #336

Merged
cah-hbaum merged 2 commits into
mainfrom
issue/226
Sep 22, 2023
Merged

cah-hbaum merged 2 commits into
mainfrom
issue/226

Conversation

@cah-hbaum

Copy link
Copy Markdown
Contributor

Adds a standard decision for K8s node anti-affinity. This should lead to a standard, which ensures anti-affinity, and therefore high-availability and fault-tolerance on systems of SCS users.

@cah-hbaum cah-hbaum added Container Issues or pull requests relevant for Team 2: Container Infra and Tooling standards Issues / ADR / pull requests relevant for standardization & certification SCS is standardized SCS is standardized SCS-VP10 Related to tender lot SCS-VP10 labels Aug 25, 2023
@cah-hbaum cah-hbaum self-assigned this Aug 25, 2023
@cah-hbaum cah-hbaum linked an issue Aug 25, 2023 that may be closed by this pull request
2 tasks done

## Design considerations

SCS plans to require a Hard Anti Affinity and/or Redundancy for the control plane and

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In line 56 you exclude affinity for worker nodes and here you include it. Isn't this contradicting?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe its not perfectly formulated. What I meant is that (Anti) Affinity isn't relevant for the SCS internally, since SCS in the end only standardizes the infrastructure, not the workload. But it is nonetheless important to standardize the possibility for (Anti) Affinity usage in the clusters.

@matofeder matofeder left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Adds a standard decision for K8s node anti-affinity. This should lead to a standard, which ensures anti-affinity, and therefore high-availability and fault-tolerance on systems of SCS users.

Signed-off-by: Hannes Baum <[email protected]>
Some small updates and changes to the Decision Record due to the comments of @matofeder and @anjastrunk.

Signed-off-by: Hannes Baum <[email protected]>
@cah-hbaum
cah-hbaum merged commit eabd7d9 into main Sep 22, 2023
@cah-hbaum
cah-hbaum deleted the issue/226 branch September 22, 2023 07:03
@garloff

garloff commented Sep 29, 2023

Copy link
Copy Markdown
Member

Hmmm, reading through the document, it looks more complicated than it needs to be.

Maybe my view of the world is too simple and I'm happy to learn. But here's my understanding:

  • Users of k8s clusters can schedule containers/pods such that they run on multiple worker nodes (e.g. by using a daemonset). For properly designed workloads, the loss of a worker node can then be survived without problems.
  • The control plane -- when deployed on multiple nodes -- runs a clustered etcd (and multiple stateless components such as the kube-apiserver), so it survives the failure of a control plane node and can schedule a new one to run and join the cluster to achieve full redundancy again.

Both mechanisms are not very useful if several worker nodes or several control planes nodes are VMs that are running on the same host (hypervisor) system. Because then, one event (a host failure) would affect several k8s nodes of one type at once.

We have thus determined that

  • Control plane node VMs of one cluster must never be scheduled to the same host. (This applies to solutions that have dedicated control plane nodes -- for a Gardener style solution with a shared control plane, we would require it to also run on several hosts, though the scheduling happens beforehand not on cluster creation.)
    For our cluster-API based implementation on OpenStack, we can simply set hard anti-affinity for the VMs that host the control plane nodes. This ensures survival of the etcd data store and thus the ability for users to make API calls to do CRUD operations in the cluster.
    (You are touching on an advanced topic here: If there are several availabiity zones / failure domains, going a step further and not just requiring different hosts but different AZs would be even better.)
  • Worker node VMs of one cluster should not be scheduled on the same host. This is a soft requirement -- there are valid cases, where one woud want to have more worker nodes than there are hosts of the required type. In the reference implementation this is achieved by using soft anti-affiinity for the VMs that host the worker nodes.

I seem to be missing something here, as the proposed standards document looks a lot more complicated than my explanation here. You seem to imply that the control plane still does not survive a host failure?

@cah-hbaum

Copy link
Copy Markdown
Contributor Author

I seem to be missing something here, as the proposed standards document looks a lot more complicated than my explanation here. You seem to imply that the control plane still does not survive a host failure?

The main goal I had with this Decision Record (that is also something we should keep in mind, this is only a DR) was to set clearer goals and guidelines for the following standard. You're completely right with your observation about the essence of this document and that this could probably be cut a bit shorter. But I also wanted to make clear, that this document is more about "availability" with/trough "cluster distribution" and not really about "Anti Affinity", since this is (in my opinion) more widely used in the context of workloads, at least in the K8s space. So this document was more about clearing that up and finding the right concepts to apply to the standard following it.

About the the depth of commitments to get an (high)-available, fault-tolerant cluster: this is something I would put and discuss in the standard. I think there's always a scenario, where a cluster could go down due to some unexpected problems. Wider distribution of the underlying infrastructure (different physical machines, buildings, AZs, regions) most likely help, but this obviously increases the costs and isn't feasible for every business. I think the final decision how to implement this aspect should be left to the providers, but we can probably give out a recommendation.

Another aspect of the length of this document can be found here:

Worker node VMs of one cluster should not be scheduled on the same host. This is a soft requirement -- there are valid cases, where one woud want to have more worker nodes than there are hosts of the required type. In the reference implementation this is achieved by using soft anti-affiinity for the VMs that host the worker nodes.

In the document, I wanted to make clear that the distribution of the worker nodes over several physical nodes isn't very useful, if the customers/users can't use them properly. They need clear information about the worker nodes and their distribution, otherwise all workloads could be scheduled (maybe unintentionally) on the same node, in which case a single worker node failure would bring down the whole environment of a single customer. Not good! Thats why I mentioned the labeling and communication in the DR.

Also, just to ask the question about this:

Both mechanisms are not very useful if several worker nodes or several control planes nodes are VMs that are running on the same host (hypervisor) system. Because then, one event (a host failure) would affect several k8s nodes of one type at once.

I thought (at least from my experience and experiments), if all control plane nodes except one go down, the cluster should still be working. It's maybe not very responsable due to a high request load, but at least the data would still be secure. Rebuilding the cluster would take some time of course.

I hope that made it more clear.

@cah-hbaum

cah-hbaum commented Oct 5, 2023 •

Copy link
Copy Markdown
Contributor Author

I now created the follow-up PR for the real standard here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Container Issues or pull requests relevant for Team 2: Container Infra and Tooling SCS is standardized SCS is standardized SCS-VP10 Related to tender lot SCS-VP10 standards Issues / ADR / pull requests relevant for standardization & certification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Anti-affinity for k8s nodes (control-plane and workers)

4 participants