diff --git a/pkg/apis/provisioning/v1alpha5/requirements.go b/pkg/apis/provisioning/v1alpha5/requirements.go index e0c384c121e4..064eb09994df 100644 --- a/pkg/apis/provisioning/v1alpha5/requirements.go +++ b/pkg/apis/provisioning/v1alpha5/requirements.go @@ -52,6 +52,7 @@ var ( // WellKnownLabels supported by karpenter WellKnownLabels = sets.NewString( v1.LabelTopologyZone, + v1.LabelTopologyRegion, v1.LabelInstanceTypeStable, v1.LabelArchStable, v1.LabelOSStable, @@ -63,10 +64,11 @@ var ( // however, Provisioner labels are still restricted to WellKnownLabels. // Additional labels may be injected by cloud providers. NormalizedLabels = map[string]string{ - v1.LabelFailureDomainBetaZone: v1.LabelTopologyZone, - "beta.kubernetes.io/arch": v1.LabelArchStable, - "beta.kubernetes.io/os": v1.LabelOSStable, - v1.LabelInstanceType: v1.LabelInstanceTypeStable, + v1.LabelFailureDomainBetaZone: v1.LabelTopologyZone, + v1.LabelFailureDomainBetaRegion: v1.LabelTopologyRegion, + "beta.kubernetes.io/arch": v1.LabelArchStable, + "beta.kubernetes.io/os": v1.LabelOSStable, + v1.LabelInstanceType: v1.LabelInstanceTypeStable, } ) @@ -77,6 +79,10 @@ func (r Requirements) Zones() sets.String { return r.Requirement(v1.LabelTopologyZone) } +func (r Requirements) Regions() sets.String { + return r.Requirement(v1.LabelTopologyRegion) +} + func (r Requirements) InstanceTypes() sets.String { return r.Requirement(v1.LabelInstanceTypeStable) } diff --git a/pkg/cloudprovider/aws/instance.go b/pkg/cloudprovider/aws/instance.go index bd2f3202cd31..b6d115ef6847 100644 --- a/pkg/cloudprovider/aws/instance.go +++ b/pkg/cloudprovider/aws/instance.go @@ -249,17 +249,19 @@ func (p *InstanceProvider) instanceToNode(ctx context.Context, instance *ec2.Ins if injection.GetOptions(ctx).GetAWSNodeNameConvention() == options.ResourceName { nodeName = aws.StringValue(instance.InstanceId) } + zone := aws.StringValue(instance.Placement.AvailabilityZone) return &v1.Node{ ObjectMeta: metav1.ObjectMeta{ Name: nodeName, Labels: map[string]string{ - v1.LabelTopologyZone: aws.StringValue(instance.Placement.AvailabilityZone), + v1.LabelTopologyZone: zone, + v1.LabelTopologyRegion: zone[:len(zone)-1], v1.LabelInstanceTypeStable: aws.StringValue(instance.InstanceType), v1alpha5.LabelCapacityType: getCapacityType(instance), }, }, Spec: v1.NodeSpec{ - ProviderID: fmt.Sprintf("aws:///%s/%s", aws.StringValue(instance.Placement.AvailabilityZone), aws.StringValue(instance.InstanceId)), + ProviderID: fmt.Sprintf("aws:///%s/%s", zone, aws.StringValue(instance.InstanceId)), }, Status: v1.NodeStatus{ Allocatable: v1.ResourceList{ diff --git a/pkg/cloudprovider/aws/instancetypes.go b/pkg/cloudprovider/aws/instancetypes.go index 8de27a15da5b..05a0c534f359 100644 --- a/pkg/cloudprovider/aws/instancetypes.go +++ b/pkg/cloudprovider/aws/instancetypes.go @@ -17,9 +17,10 @@ package aws import ( "context" "fmt" + "time" + "github.com/aws/karpenter/pkg/utils/injection" "knative.dev/pkg/ptr" - "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2"