Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add v1.LabelInstanceTypeStable to labels when building from template #3977

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cluster-autoscaler/cloudprovider/alicloud/alicloud_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@ package alicloud
import (
"errors"
"fmt"
"gopkg.in/gcfg.v1"
"io"
"math/rand"
"time"

"gopkg.in/gcfg.v1"
apiv1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider"
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/alicloud/alibaba-cloud-sdk-go/services/ess"
klog "k8s.io/klog/v2"
kubeletapis "k8s.io/kubelet/pkg/apis"
"math/rand"
"time"
)

const (
Expand Down Expand Up @@ -241,6 +242,7 @@ func buildGenericLabels(template *sgTemplate, nodeName string) map[string]string
result[kubeletapis.LabelOS] = cloudprovider.DefaultOS

result[apiv1.LabelInstanceType] = template.InstanceType.instanceTypeID
result[apiv1.LabelInstanceTypeStable] = template.InstanceType.instanceTypeID

result[apiv1.LabelZoneRegion] = template.Region
result[apiv1.LabelZoneFailureDomain] = template.Zone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func TestBuildGenericLabels(t *testing.T) {
nodeName := "virtual-node"
labels := buildGenericLabels(template, nodeName)
assert.Equal(t, labels[apiv1.LabelInstanceType], template.InstanceType.instanceTypeID)
assert.Equal(t, labels[apiv1.LabelInstanceTypeStable], template.InstanceType.instanceTypeID)
}

func TestExtractLabelsFromAsg(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions cluster-autoscaler/cloudprovider/aws/aws_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ func buildGenericLabels(template *asgTemplate, nodeName string) map[string]strin
result[kubeletapis.LabelOS] = cloudprovider.DefaultOS

result[apiv1.LabelInstanceType] = template.InstanceType.InstanceType
result[apiv1.LabelInstanceTypeStable] = template.InstanceType.InstanceType

result[apiv1.LabelZoneRegion] = template.Region
result[apiv1.LabelZoneFailureDomain] = template.Zone
Expand Down
1 change: 1 addition & 0 deletions cluster-autoscaler/cloudprovider/aws/aws_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func TestBuildGenericLabels(t *testing.T) {
assert.Equal(t, "us-east-1", labels[apiv1.LabelZoneRegion])
assert.Equal(t, "sillyname", labels[apiv1.LabelHostname])
assert.Equal(t, "c4.large", labels[apiv1.LabelInstanceType])
assert.Equal(t, "c4.large", labels[apiv1.LabelInstanceTypeStable])
assert.Equal(t, cloudprovider.DefaultArch, labels[kubeletapis.LabelArch])
assert.Equal(t, cloudprovider.DefaultOS, labels[kubeletapis.LabelOS])
}
Expand Down
9 changes: 6 additions & 3 deletions cluster-autoscaler/cloudprovider/azure/azure_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ package azure

import (
"fmt"
"math/rand"
"regexp"
"strings"

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute"
apiv1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
Expand All @@ -27,9 +31,6 @@ import (
cloudvolume "k8s.io/cloud-provider/volume"
"k8s.io/klog/v2"
kubeletapis "k8s.io/kubelet/pkg/apis"
"math/rand"
"regexp"
"strings"
)

func buildInstanceOS(template compute.VirtualMachineScaleSet) string {
Expand All @@ -51,6 +52,8 @@ func buildGenericLabels(template compute.VirtualMachineScaleSet, nodeName string
result[apiv1.LabelOSStable] = buildInstanceOS(template)

result[apiv1.LabelInstanceType] = *template.Sku.Name
result[apiv1.LabelInstanceTypeStable] = *template.Sku.Name

result[apiv1.LabelZoneRegion] = strings.ToLower(*template.Location)

if template.Zones != nil && len(*template.Zones) > 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ func buildGenericLabels(template *asgTemplate, nodeName string) map[string]strin
result[kubeletapis.LabelOS] = cloudprovider.DefaultOS

result[apiv1.LabelInstanceType] = template.name
result[apiv1.LabelInstanceTypeStable] = template.name

result[apiv1.LabelZoneRegion] = template.region
result[apiv1.LabelZoneFailureDomain] = template.zone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ func BuildGenericLabels(nodegroup string, instanceType string) map[string]string
//result[kubeletapis.LabelArch] = "amd64"
//result[kubeletapis.LabelOS] = "linux"
result[apiv1.LabelInstanceType] = instanceType
result[apiv1.LabelInstanceTypeStable] = instanceType
//result[apiv1.LabelZoneRegion] = ""
//result[apiv1.LabelZoneFailureDomain] = "0"
//result[apiv1.LabelHostname] = ""
Expand Down