Skip to content

Commit

Permalink
Merge pull request #10619 from NickSchleicher/azureNodeLabelTags
Browse files Browse the repository at this point in the history
Use correct tag when creating node labels from azure cloud tags
  • Loading branch information
k8s-ci-robot committed Feb 16, 2021
2 parents 446e635 + 617869e commit 2db0b18
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions pkg/nodeidentity/azure/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//pkg/nodeidentity:go_default_library",
"//upup/pkg/fi:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2020-06-01/compute:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/azure/auth:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
Expand Down
8 changes: 5 additions & 3 deletions pkg/nodeidentity/azure/identify.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ import (
expirationcache "k8s.io/client-go/tools/cache"
"k8s.io/klog/v2"
"k8s.io/kops/pkg/nodeidentity"
"k8s.io/kops/upup/pkg/fi"
)

const (
// InstanceGroupNameTag is the key of the tag used to identify an
// instance group that VM ScaleSet belongs.
InstanceGroupNameTag = "kops.k8s.io_instancegroup"

// ClusterNodeTemplateLabel is the prefix used on node labels when copying to cloud tags.
ClusterNodeTemplateLabel = "k8s.io_cluster_node-template_label_"
// cacheTTL is the expiration time of nodeidentity.Info cache.
cacheTTL = 60 * time.Minute
)
Expand Down Expand Up @@ -107,8 +109,8 @@ func (i *nodeIdentifier) IdentifyNode(ctx context.Context, node *corev1.Node) (*
}

for k, v := range vmss.Tags {
if strings.HasPrefix(k, InstanceGroupNameTag) {
info.Labels[strings.TrimPrefix(k, InstanceGroupNameTag)] = *v
if strings.HasPrefix(k, ClusterNodeTemplateLabel) {
info.Labels[strings.TrimPrefix(k, ClusterNodeTemplateLabel)] = fi.StringValue(v)
}
}

Expand Down

0 comments on commit 2db0b18

Please sign in to comment.