feat: label nodes with the node profile they joined with
Node profiles controlled how a node joined the cluster but left no trace on the node afterwards, so a profile could not be selected against with `kubectl`, a `nodeSelector`, or a node affinity rule. Nodes joined without a profile are left unlabeled, and the server node created by `scheduler-k3s:initialize` never carries the label since it does not pass through `scheduler-k3s:cluster:add`.
This commit is contained in:
@@ -1286,6 +1286,27 @@ func resolveLetsencryptIssuer(appName string, clusterIssuerName string, appEmail
|
||||
}
|
||||
}
|
||||
|
||||
// nodeLabels returns the labels to apply to a node joining the cluster, including
|
||||
// the node profile label when the node was added with a named profile. The returned
|
||||
// map is always a fresh copy so callers cannot mutate ServerLabels or WorkerLabels.
|
||||
func nodeLabels(role string, profileName string) map[string]string {
|
||||
source := ServerLabels
|
||||
if role == "worker" {
|
||||
source = WorkerLabels
|
||||
}
|
||||
|
||||
labels := make(map[string]string, len(source)+1)
|
||||
for key, value := range source {
|
||||
labels[key] = value
|
||||
}
|
||||
|
||||
if profileName != "" {
|
||||
labels[NodeProfileLabel] = profileName
|
||||
}
|
||||
|
||||
return labels
|
||||
}
|
||||
|
||||
// InitializeInstallerArgsInput contains the inputs to initializeInstallerArgs
|
||||
type InitializeInstallerArgsInput struct {
|
||||
// IngressClass is the ingress class the cluster is initialized with
|
||||
|
||||
Reference in New Issue
Block a user