You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/proposals/20250513-propogate-taints.md
+37-25Lines changed: 37 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,7 +72,7 @@ This proposal introduces taints as a first-class citizen in Cluster API's core t
72
72
The proposal defines two different kind of propagation modes for taints:
73
73
74
74
-**Always**: Taints are continuously reconciled and maintained on nodes
75
-
-**Initialize**: Taints are set once during node initialization and then left unmanaged
75
+
-**OnInitialization**: Taints are set once during node initialization and then left unmanaged
76
76
77
77
NOTE: This new proposal has been created rather than updating the prior [in-place metadata propagation](20221003-In-place-propagation-of-Kubernetes-objects-only-changes.md) proposal because taints are not yet part of the Core Provider's API types and are different enough from labels or annotations that a different set of constraints will need to be considered.
78
78
Very early versions of Kubernetes tracked taints as annotations, but they have long since been [promoted to their own API type](https://github.com/kubernetes/kubernetes/commit/9b640838a5f5e28db1c1f084afa393fa0b6d1166)
@@ -156,16 +156,16 @@ It also means that Server-Side Apply ownership rules could not be applied to ind
156
156
157
157
For Cluster API to support propagating `Taint`s, it will need to:
158
158
159
-
- implement its own mechanism for tracking what `Taint`s it owns.
159
+
- implement its own mechanism for tracking what `Taint`s it owns. This will be similar to the implementation for annotations and labels. See [Changes to the Machine and MachinePool controllers](#changes-to-the-machine-and-machinepool-controllers) for more details.
160
160
- ensure there are no conflicts with other actors by always setting the `metadata.resourceVersion` on API calls changing the taints on a Node.
161
161
162
162
#### Propagation of taints
163
163
164
164
A taint for a Node may be defined for different use-cases:
165
165
166
-
-Taint's supposed to stay on the Node to ensure only certain workload runs on such a `Node` aka. `Always`:
167
-
-This taint are supposed to be set on the `Node` object as long as it is defined on its parent core CAPI object.
168
-
- Example: Nodes where only run GPU related workload should run
166
+
-Taints supposed to stay on the Node to ensure only certain workload runs on such a `Node` aka. `Always`:
167
+
-These taints are supposed to be set on the `Node` object as long as it is defined on its parent core CAPI object.
168
+
- Example: Nodes where only GPU related workload should run
169
169
- CAPI controllers should ensure via reconciliation that such a taint gets added again in case a third party removes it.
170
170
- Taint's supposed to get added once to a Node aka. `Initialize`
171
171
- This taints are supposed to be set **once** on the `Node` object.
@@ -200,7 +200,7 @@ type MachineTaint struct {
200
200
201
201
// propagation defines how this taint should be propagated to Nodes.
202
202
// Always: The taint will be continuously reconciled. If removed from a node, it will be re-added.
203
-
//Initialize: The taint will be added during node initialization. If removed, it will not be re-added.
203
+
//OnInitialization: The taint will be added during node initialization. If removed, it will not be re-added.
Proper validations on the new field should ensure that no taint with a key of `node.cluster.x-k8s.io/uninitialized` is getting added, because that one is restricted to be used by CAPI and providers.
224
-
225
-
Open question: alternative to consider, e.g. specific struct, (negative: not as extensible):
* FIXME(chrischdi): if decided this should move down to alternative approaches.
223
+
Proper validations on the new field should ensure that no taint with a key of `node.cluster.x-k8s.io/uninitialized` or `node.cluster.x-k8s.io/outdated-revision` is getting added, because that one is restricted to be used by CAPI and providers.
224
+
Other taints normally set by kubeadm should be able to get set.
234
225
235
226
##### Changes to the Machine, MachineSet, MachineDeployment and MachinePool resources via MachineSpec
236
227
@@ -258,7 +249,6 @@ type MachineSpec struct{
258
249
// +optional
259
250
// +listType=map
260
251
// +listMapKey=key
261
-
// +listMapKey=value
262
252
// +listMapKey=effect
263
253
Taints []MachineTaint`json:"taints,omitempty"`
264
254
@@ -285,7 +275,7 @@ The propagation of the fields should follow the prior art and is summarized in t
285
275
286
276

287
277
288
-
As implemented for the ReadinessGates, add taints on a Cluster should lead to only adding the taints from the ClusterClass.
278
+
As implemented for the ReadinessGates, add taints on a Cluster should lead to only adding the taints from the Cluster.
289
279
290
280
```golang
291
281
typeControlPlaneClassstruct {
@@ -361,6 +351,12 @@ The MachineDeployment and MachineSet controllers will watch their associated `Ma
361
351
362
352
This should be done similar to how the existing in-place mutable fields like `ReadinessGates`, `NodeDrainTimeout`, etc. for a Machine are handled today.
363
353
354
+
##### Changes to the cluster-autoscaler
355
+
356
+
The cluster-autoscaler implementation for CAPI as of today consumes the `capacity.cluster-autoscaler.kubernetes.io/taints` (see [Pre-defined labels and taints on nodes scaled from zero](https://cluster-api.sigs.k8s.io/tasks/automated-machine-management/autoscaling#pre-defined-labels-and-taints-on-nodes-scaled-from-zero)).
357
+
358
+
It should be adjusted to also consider the cofnigured taints.
359
+
364
360
### Security Model
365
361
366
362
Users who can define `Taint`s that get placed on `Node`s will be able to steer workloads, possibly to malicious hosts in order to extract sensitive data.
@@ -372,10 +368,10 @@ This proposal therefore does not present any heightened security requirements th
372
368
373
369
With the introduction of the new fields, bootstrap providers could start deprecating their equivalent fields.
374
370
375
-
For CABPK, adding a taint at a KubeadmConfigTemplate at `.spec.template.spec.joinConfiguration.nodeRegistration.taints`. is almost equivalent to adding a `Initialization` typed taint by the new API.
371
+
For CABPK, adding a taint at a KubeadmConfigTemplate at `.spec.template.spec.joinConfiguration.nodeRegistration.taints`. is almost equivalent to adding a `OnInitialization` typed taint by the new API.
376
372
The only difference is that the taint does get added by the controllers after the Node joined the Cluster.
377
373
378
-
This is considered okay, because workload should not be able to be schedule workload unless the `node.cluster.x-k8s.io/uninitialized` taint was removed and the implementation should take care to have added the `Initialization` taints before or at the time removing this taint.
374
+
This is considered okay, because workload should not be able to be schedule workload unless the `node.cluster.x-k8s.io/uninitialized` taint was removed and the implementation should take care to have added the `OnInitialization` taints before or at the time removing this taint.
379
375
380
376
### Risks and Mitigations
381
377
@@ -387,6 +383,8 @@ This risk can be mitigated by ensuring Cluster API only modifies taints that it
387
383
388
384
## Alternatives
389
385
386
+
### Continuous reconciliation
387
+
390
388
Deciding whether or not to reconcile taint changes continuously has been a challenge for the Cluster API.
391
389
Historically, the v1alpha1 API included a `Machine.Taints` field.
392
390
However, since this field was mostly used in cluster bootstrapping, it was later extracted into bootstrap provider implementations.
@@ -398,6 +396,19 @@ While this simplifies the implementation logic for Cluster API, it may be surpri
398
396
This would also mean that there are two different behaviors when modifying metadata within Cluster API, which could again be very confusing.
399
397
There is already precedent for leaving infrastructure in-place when Kubernetes-only fields are modified, and this proposal seeks to align with the established function.
400
398
399
+
### Type definition of a taint in Cluster API objects
400
+
401
+
An alternative to define the taints as writtetn above is using slices per type as follows:
0 commit comments