Skip to content

Commit 9bf3384

Browse files
authored
Merge pull request #3838 from Skarlso/add_ccm_to_route_tables
Add CCM tag to routing tables
2 parents ecbd943 + e44a1e6 commit 9bf3384

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

pkg/cloud/services/network/routetables.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,15 @@ func (s *Service) getRouteTableTagParams(id string, public bool, zone string) in
364364
name.WriteString("-")
365365
name.WriteString(zone)
366366

367+
additionalTags := s.scope.AdditionalTags()
368+
additionalTags[infrav1.ClusterAWSCloudProviderTagKey(s.scope.KubernetesClusterName())] = string(infrav1.ResourceLifecycleOwned)
369+
367370
return infrav1.BuildParams{
368371
ClusterName: s.scope.Name(),
369372
ResourceID: id,
370373
Lifecycle: infrav1.ResourceLifecycleOwned,
371374
Name: aws.String(name.String()),
372375
Role: aws.String(infrav1.CommonRoleTagValue),
373-
Additional: s.scope.AdditionalTags(),
376+
Additional: additionalTags,
374377
}
375378
}

pkg/cloud/services/network/routetables_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,10 @@ func TestReconcileRouteTables(t *testing.T) {
355355
},
356356
},
357357
Tags: []*ec2.Tag{
358+
{
359+
Key: aws.String("kubernetes.io/cluster/test-cluster"),
360+
Value: aws.String("owned"),
361+
},
358362
{
359363
Key: aws.String("sigs.k8s.io/cluster-api-provider-aws/v2/role"),
360364
Value: aws.String("common"),
@@ -383,6 +387,10 @@ func TestReconcileRouteTables(t *testing.T) {
383387
},
384388
},
385389
Tags: []*ec2.Tag{
390+
{
391+
Key: aws.String("kubernetes.io/cluster/test-cluster"),
392+
Value: aws.String("owned"),
393+
},
386394
{
387395
Key: aws.String("sigs.k8s.io/cluster-api-provider-aws/v2/role"),
388396
Value: aws.String("common"),
@@ -456,6 +464,10 @@ func TestReconcileRouteTables(t *testing.T) {
456464
},
457465
},
458466
Tags: []*ec2.Tag{
467+
{
468+
Key: aws.String("kubernetes.io/cluster/test-cluster"),
469+
Value: aws.String("owned"),
470+
},
459471
{
460472
Key: aws.String("sigs.k8s.io/cluster-api-provider-aws/v2/role"),
461473
Value: aws.String("common"),
@@ -484,6 +496,10 @@ func TestReconcileRouteTables(t *testing.T) {
484496
},
485497
},
486498
Tags: []*ec2.Tag{
499+
{
500+
Key: aws.String("kubernetes.io/cluster/test-cluster"),
501+
Value: aws.String("owned"),
502+
},
487503
{
488504
Key: aws.String("sigs.k8s.io/cluster-api-provider-aws/v2/role"),
489505
Value: aws.String("common"),
@@ -578,6 +594,10 @@ func TestDeleteRouteTables(t *testing.T) {
578594
},
579595
},
580596
Tags: []*ec2.Tag{
597+
{
598+
Key: aws.String("kubernetes.io/cluster/test-cluster"),
599+
Value: aws.String("owned"),
600+
},
581601
{
582602
Key: aws.String("sigs.k8s.io/cluster-api-provider-aws/v2/role"),
583603
Value: aws.String("common"),

pkg/cloud/services/network/subnets.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ func (s *Service) getSubnetTagParams(unmanagedVPC bool, id string, public bool,
503503
}
504504

505505
// Add tag needed for Service type=LoadBalancer
506-
additionalTags[infrav1.NameKubernetesAWSCloudProviderPrefix+s.scope.KubernetesClusterName()] = string(infrav1.ResourceLifecycleShared)
506+
additionalTags[infrav1.ClusterAWSCloudProviderTagKey(s.scope.KubernetesClusterName())] = string(infrav1.ResourceLifecycleShared)
507507

508508
if !unmanagedVPC {
509509
for k, v := range manualTags {

0 commit comments

Comments
 (0)