Skip to content

Commit

Permalink
Add worker bootstrap-node-taints setting
Browse files Browse the repository at this point in the history
The control-plane charm already allows defining node taints. We'll
add the same for worker nodes.
  • Loading branch information
petrutlucian94 committed Dec 10, 2024
1 parent 8d9e361 commit b4c32ec
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
13 changes: 13 additions & 0 deletions charms/worker/charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions charms/worker/k8s/src/config/extra_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit b4c32ec

Please sign in to comment.