Skip to content

Commit 5e27024

Browse files
authored
Merge pull request #4237 from zhzhuang-zju/configmap
Restrict “configmap/extension-apiserver-authentication” object from being distributed to member clusters
2 parents 3dac48b + 3de4fe1 commit 5e27024

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

pkg/detector/detector.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,16 +233,15 @@ func (d *ResourceDetector) Reconcile(key util.QueueKey) error {
233233
return d.propagateResource(object, clusterWideKey)
234234
}
235235

236-
// EventFilter tells if an object should be take care of.
236+
// EventFilter tells if an object should be taken care of.
237237
//
238-
// All objects under Kubernetes reserved namespace should be ignored:
239-
// - kube-*
240238
// All objects under Karmada reserved namespace should be ignored:
241239
// - karmada-system
242240
// - karmada-cluster
243241
// - karmada-es-*
244242
//
245-
// If '--skipped-propagating-namespaces' is specified, all APIs in the skipped-propagating-namespaces will be ignored.
243+
// If '--skipped-propagating-namespaces'(defaults to kube-.*) is specified,
244+
// all resources in the skipped-propagating-namespaces will be ignored.
246245
func (d *ResourceDetector) EventFilter(obj interface{}) bool {
247246
key, err := ClusterWideKeyFunc(obj)
248247
if err != nil {
@@ -279,6 +278,14 @@ func (d *ResourceDetector) EventFilter(obj interface{}) bool {
279278
}
280279
}
281280

281+
// Prevent configmap/extension-apiserver-authentication from propagating as it is generated
282+
// and managed by kube-apiserver.
283+
// Refer to https://github.com/karmada-io/karmada/issues/4228 for more details.
284+
if clusterWideKey.Namespace == "kube-system" && clusterWideKey.Kind == "ConfigMap" &&
285+
clusterWideKey.Name == "extension-apiserver-authentication" {
286+
return false
287+
}
288+
282289
return true
283290
}
284291

pkg/detector/detector_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,20 @@ func BenchmarkEventFilterMultiSkipNameSpaces(b *testing.B) {
125125
})
126126
}
127127
}
128+
129+
func BenchmarkEventFilterExtensionApiserverAuthentication(b *testing.B) {
130+
dt := &ResourceDetector{}
131+
dt.SkippedPropagatingNamespaces = append(dt.SkippedPropagatingNamespaces, regexp.MustCompile("^kube-.*$"))
132+
for i := 0; i < b.N; i++ {
133+
dt.EventFilter(&unstructured.Unstructured{
134+
Object: map[string]interface{}{
135+
"apiVersion": "v1",
136+
"kind": "ConfigMap",
137+
"metadata": map[string]interface{}{
138+
"name": "extension-apiserver-authentication",
139+
"namespace": "kube-system",
140+
},
141+
},
142+
})
143+
}
144+
}

0 commit comments

Comments
 (0)