Skip to content

Commit

Permalink
node: support ignore by terway label
Browse files Browse the repository at this point in the history
Signed-off-by: l1b0k <[email protected]>
  • Loading branch information
l1b0k committed Nov 7, 2024
1 parent 16402ec commit c30d548
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/controller/node/predict.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/predicate"

"github.com/AliyunContainerService/terway/pkg/utils"
"github.com/AliyunContainerService/terway/types"
)

type predicateForNodeEvent struct {
Expand Down Expand Up @@ -59,6 +60,10 @@ func predicateNode(o client.Object) bool {
return false
}

if types.IgnoredByTerway(node.Labels) {
return false
}

return isECSNode(node)
}

Expand Down
14 changes: 14 additions & 0 deletions pkg/controller/node/predict_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,20 @@ func Test_predicateNode(t *testing.T) {
},
want: true,
},
{
name: "normal node but has exclude rule",
args: args{
o: &corev1.Node{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"topology.kubernetes.io/region": "cn-hangzhou",
"k8s.aliyun.com/ignore-by-terway": "true",
},
},
},
},
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit c30d548

Please sign in to comment.