controller+worker multi-master not scheduling pods
Hi there,
I'm setting up a "particular" configuration of k0s via k0sctl, creating a cluster with 3+ nodes that must work in a controller+worker configuration.
All nodes are behind a HAProxy load balancer and the cluster is apparently correctly created and running after k0sctl apply. here is the config:
apiVersion: k0sctl.k0sproject.io/v1beta1
kind: Cluster
metadata:
name: k0s
spec:
hosts:
- role: controller+worker
privateAddress: 10.128.0.16
ssh:
address: {pub-ip1}
user: ...
port: 22
keyPath: ...
- role: controller+worker
privateAddress: 10.128.0.18
ssh:
address: {pub-ip2}
user: ...
port: 22
keyPath: ...
- role: controller+worker
privateAddress: 10.128.0.17
ssh:
address: {pub-ip3}
user: ...
port: 22
keyPath: ...
k0s:
version: v1.23.5+k0s.0
config:
spec:
api:
port: 6443
k0sApiPort: 9443
externalAddress: 10.128.0.12
sans:
- 10.128.0.12
- {pub-ip-loadbalancer}
However, all nodes are started with the taint node-role.kubernetes.io/master:NoSchedule and this prevents any workload to be run on the nodes.
Is this the expected behavior for a controller+worker confutation.
A possible solution is to remove the taint via
kubectl taint nodes $(hostname) node-role.kubernetes.io/master:NoSchedule-
however, this does not seems to be the intended use of controller+worker configuration in the setup of the cluster.
Please assist. Thanks!
Hmm, https://github.com/k0sproject/k0s/pull/1332 made k0s add the NoSchedule taint to controllers unless you give --no-taints. You can do this via the installFlags but sounds like this needs to be taken care of by k0sctl automatically.
I think the intention is that you can still run daemonsets with NoSchedule toleration on controller nodes that have the worker running.
Undecided what k0sctl should actually do. If it automatically adds the --no-taints, then there's no way to stop it from doing so.
So, what you can do to avoid the taints is:
- role: controller+worker
installFlags:
- --no-taints
privateAddress: 10.128.0.16
ssh:
address: {pub-ip1}
user: ...
port: 22
keyPath: ...
Maybe a new controller+workloads role? :) @jnummelin @mviitane
What was the reasoning for adding the flag? Feels somehow counter intuitive to me, --enable-worker not being enough to actually enable workloads. Maybe it would have been more straight forward to have an inverted flag --add-taints instead.
So, what you can do to avoid the taints is:
- role: controller+worker installFlags: - --no-taints privateAddress: 10.128.0.16 ssh: address: {pub-ip1} user: ... port: 22 keyPath: ...
Thanks @kke I will use this approach. However, from the documentation it seems that the controller+worker role is meant to run workloads on the controller - there seems to be no difference between the this and and the --single-node option - and not just DeamonSets with toleration.
Thus the application of taint seems to be the incorrect approach under a user/reader perspective. Meanwhile I completely agree on the use of label as per the issue you mentioned.
Thanks!
What was the reasoning for adding the flag? Feels somehow counter intuitive to me, --enable-worker not being enough to actually enable workloads. Maybe it would have been more straight forward to have an inverted flag --add-taints instead.
From what I understood, people use the --enable-worker to be able to run certain daemonsets on controller nodes (with the taint toleration) and this is the expected behavior as it is the same way on other distributions. So, --enable-worker just makes it POSSIBLE to run workloads if you specifically really want to (by adding the toleration), but doesn't make kube schedule ordinary workloads on the nodes.
K0sctl could solve this by just always adding the --no-taints when --enable-worker or controller+worker rule is used, but that would make it impossible to stop it from doing so without adding a new config parameter.
I think the solution could be to a) add a controller+workloads role that would enable both --enable-worker and --no-taints or b) add workloads: true that would only be accepted when using the controller+worker role.
After discussion, decided that we should probably add NoTaints: true and maybe even a warning if it's false (something like "this node is a controller with worker enabled but it will not schedule any workloads unless they have specific tolerations, to allow regular pod scheduling on the node, set NoTaints: true").
k0sctl now has notaints (check docs updated at https://github.com/k0sproject/k0sctl)
spec.hosts[*].noTaints <boolean> (optional) (default: false)
When true and used in conjuction with the controller+worker role, the default taints are disabled making regular workloads schedulable on the node. By default, k0s sets a node-role.kubernetes.io/master:NoSchedule taint on controller+worker nodes and only workloads with toleration for it will be scheduled.