Skip to content

Commit 45d0b90

Browse files
authored
Fix CoreDNS scheduling on Fargate failing when component label in selector (#8357)
Update cluster creation with Fargate to support adding a CoreDNS profile with the selector label `eks.amazonaws.com/component: coredns`. Closes issue #8355
1 parent f47f100 commit 45d0b90

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/aws/aws-sdk-go-v2 v1.36.3
1212
github.com/aws/aws-sdk-go-v2/config v1.29.12
1313
github.com/aws/aws-sdk-go-v2/credentials v1.17.65
14-
github.com/aws/aws-sdk-go-v2/service/autoscaling v1.52.3
14+
github.com/aws/aws-sdk-go-v2/service/autoscaling v1.52.4
1515
github.com/aws/aws-sdk-go-v2/service/cloudformation v1.59.2
1616
github.com/aws/aws-sdk-go-v2/service/cloudtrail v1.48.4
1717
github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.47.3

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 h1:bIqFDwgGXXN1Kpp99pDOdKMTTb5d
124124
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3/go.mod h1:H5O/EsxDWyU+LP/V8i5sm8cxoZgc2fdNR9bxlOFrQTo=
125125
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.33 h1:/frG8aV09yhCVSOEC2pzktflJJO48NwY3xntHBwxHiA=
126126
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.33/go.mod h1:8vwASlAcV366M+qxZnjNzCjeastk1Rt1bpSRaGZanGU=
127-
github.com/aws/aws-sdk-go-v2/service/autoscaling v1.52.3 h1:QsKdBxtC8csnKt5BbV7D1op4Nf13p2YkTJIkppaCakw=
128-
github.com/aws/aws-sdk-go-v2/service/autoscaling v1.52.3/go.mod h1:CDqMoc3KRdZJ8qziW96J35lKH01Wq3B2aihtHj2JbRs=
127+
github.com/aws/aws-sdk-go-v2/service/autoscaling v1.52.4 h1:vzLD0FyNU4uxf2QE5UDG0jSEitiJXbVEUwf2Sk3usF4=
128+
github.com/aws/aws-sdk-go-v2/service/autoscaling v1.52.4/go.mod h1:CDqMoc3KRdZJ8qziW96J35lKH01Wq3B2aihtHj2JbRs=
129129
github.com/aws/aws-sdk-go-v2/service/cloudformation v1.59.2 h1:o9cuZdZlI9VWMqsNa2mnf2IRsFAROHnaYA1BW3lHGuY=
130130
github.com/aws/aws-sdk-go-v2/service/cloudformation v1.59.2/go.mod h1:penaZKzGmqHGZId4EUCBIW/f9l4Y7hQ5NKd45yoCYuI=
131131
github.com/aws/aws-sdk-go-v2/service/cloudtrail v1.48.4 h1:pQpinmWv9jEisDR6/DccOf2cXdAf/CAwQ39nfJfJDlE=

pkg/fargate/coredns/coredns.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func IsSchedulableOnFargate(profiles []*api.FargateProfile) bool {
4343
}
4444

4545
func selectsCoreDNS(selector api.FargateProfileSelector) bool {
46-
return selector.Namespace == Namespace && len(selector.Labels) == 0
46+
return selector.Namespace == Namespace && (len(selector.Labels) == 0 || selector.Labels["eks.amazonaws.com/component"] == Name)
4747
}
4848

4949
// IsScheduledOnFargate checks if EKS' coredns is scheduled onto Fargate.

pkg/fargate/coredns/coredns_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,20 @@ var (
7373
},
7474
}
7575

76+
profileSelectingCoreDNSWithComponentLabel = []*api.FargateProfile{
77+
{
78+
Name: "selecting-coredns-with-label",
79+
Selectors: []api.FargateProfileSelector{
80+
{
81+
Namespace: "kube-system",
82+
Labels: map[string]string{
83+
"eks.amazonaws.com/component": "coredns",
84+
},
85+
},
86+
},
87+
},
88+
}
89+
7690
profileNotSelectingCoreDNSBecauseOfNamespace = []*api.FargateProfile{
7791
{
7892
Name: "not-selecting-coredns-because-of-namespace",
@@ -97,6 +111,10 @@ var _ = Describe("coredns", func() {
97111
Expect(coredns.IsSchedulableOnFargate(multipleProfilesWithOneSelectingCoreDNS)).To(BeTrue())
98112
})
99113

114+
It("should return true when a Fargate profile matches kube-system and has the CoreDNS component label", func() {
115+
Expect(coredns.IsSchedulableOnFargate(profileSelectingCoreDNSWithComponentLabel)).To(BeTrue())
116+
})
117+
100118
It("should return true when provided the default Fargate profile", func() {
101119
cfg := api.NewClusterConfig()
102120
cfg.SetDefaultFargateProfile()

0 commit comments

Comments
 (0)