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
Allow karpenter to set arbitrary k8s labels on NodeClaim/Nodes
nodeClaim Labels are the source for core karpenter to sync Node Labels in a centralized fashion.
Some bootstrap userdata provider implementations also consume this labels and pass them through kubelet self setting.
That results in a coupling between a centralized and a kubelet self setting approach.
This coupling results in conflicting criteria for validations and degraded UX.
This PR removes the coupling.
As a consequence, Node Labels are not unncessarily restricted for the centralized sync anymore.
This better empowers administrators reducing the reliance on self setting kubelet and minimizing the risk of a Node steering privileged workloads to itself.
A subset of labels, excluding those disallowed by the node restriction admission, is now stored in json within the "karpenter.sh/kubelet-labels" NodeClaim annotation.
This enables bootstrap userdata providers to continue utilizing the labels if needed.
returnfmt.Errorf("label %s is restricted; specify a well known label: %v, or a custom label that does not use a restricted domain: %v", key, sets.List(WellKnownLabels), sets.List(RestrictedLabelDomains))
113
+
}
114
+
}
115
+
116
+
ifRestrictedLabels.Has(key) {
113
117
returnfmt.Errorf("label %s is restricted; specify a well known label: %v, or a custom label that does not use a restricted domain: %v", key, sets.List(WellKnownLabels), sets.List(RestrictedLabelDomains))
114
118
}
119
+
115
120
returnnil
116
121
}
117
122
118
-
// IsRestrictedNodeLabel returns true if a node label should not be injected by Karpenter.
119
-
// They are either known labels that will be injected by cloud providers,
120
-
// or label domain managed by other software (e.g., kops.k8s.io managed by kOps).
121
-
funcIsRestrictedNodeLabel(keystring) bool {
123
+
// IsValidLabelToSync returns true if the label key is allowed to be synced to the Node object centrally by Karpenter.
124
+
funcIsValidToSyncCentrallyLabel(keystring) bool {
125
+
// TODO(enxebre): consider this to be configurable with runtime flag.
126
+
notValidToSyncLabel:=sets.New(
127
+
v1.LabelHostname,
128
+
v1.LabelArchStable,
129
+
v1.LabelOSStable,
130
+
v1.LabelInstanceTypeStable,
131
+
v1.LabelWindowsBuild,
132
+
)
133
+
134
+
ifnotValidToSyncLabel.Has(key) {
135
+
returnfalse
136
+
}
137
+
138
+
returntrue
139
+
}
140
+
141
+
// IsKubeletLabel returns true if the label key is one that kubelets are allowed to set on their own Node object.
142
+
// This function is similar the one used by the node restriction admission https://github.com/kubernetes/kubernetes/blob/e319c541f144e9bee6160f1dd8671638a9029f4c/staging/src/k8s.io/kubelet/pkg/apis/well_known_labels.go#L67
143
+
// but karpenter also restricts the known labels to be passed to kubelet. Only the kubeletLabelNamespaces are allowed.
0 commit comments