diff --git a/charms/worker/charmcraft.yaml b/charms/worker/charmcraft.yaml index 218a7a6c..b73516e0 100644 --- a/charms/worker/charmcraft.yaml +++ b/charms/worker/charmcraft.yaml @@ -60,6 +60,19 @@ bases: config: options: + bootstrap-node-taints: + type: string + default: "" + description: | + Space-separated list of taints to apply to this node at registration time. + + This config is only used at bootstrap time when Kubelet first registers the + node with Kubernetes. To change node taints after deploy time, use kubectl + instead. + + For more information, see the upstream Kubernetes documentation about + taints: + https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/ node-labels: default: "" type: string diff --git a/charms/worker/k8s/src/config/extra_args.py b/charms/worker/k8s/src/config/extra_args.py index b3be1d8f..f8160bc3 100644 --- a/charms/worker/k8s/src/config/extra_args.py +++ b/charms/worker/k8s/src/config/extra_args.py @@ -70,3 +70,13 @@ def craft( cmd = _parse(src["kubelet-extra-args"]) dest.extra_node_kubelet_args = cmd + + is_worker_node = ( + isinstance(dest, NodeJoinConfig) and not + isinstance(dest, ControlPlaneNodeJoinConfig)) + if is_worker_node: + # We'll only do this for worker nodes, control plane nodes are handled + # separately. + taints = src['bootstrap-node-taints'].strip().split() + if taints: + dest.extra_node_kubelet_args['--register-with-taints'] = ",".join(taints)