Skip to content

Commit

Permalink
Merge pull request #2182 from linxiulei/cm
Browse files Browse the repository at this point in the history
Use field selector to get ASM configmap
  • Loading branch information
k8s-ci-robot authored Jun 29, 2023
2 parents 489e572 + 7de6256 commit 6fc964d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ limitations under the License.
package context

import (
"fmt"
"sync"
"time"

apiv1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
informers "k8s.io/client-go/informers"
Expand Down Expand Up @@ -232,7 +234,13 @@ func (ctx *ControllerContext) Init() {
if ctx.EnableASMConfigMap {
klog.Infof("ASMConfigMap is enabled")

informerFactory := informers.NewSharedInformerFactoryWithOptions(ctx.KubeClient, ctx.ResyncPeriod, informers.WithNamespace(ctx.ASMConfigMapNamespace))
informerFactory := informers.NewSharedInformerFactoryWithOptions(
ctx.KubeClient,
ctx.ResyncPeriod,
informers.WithNamespace(ctx.ASMConfigMapNamespace),
informers.WithTweakListOptions(func(listOptions *metav1.ListOptions) {
listOptions.FieldSelector = fmt.Sprintf("metadata.name=%s", ctx.ASMConfigMapName)
}))
ctx.ConfigMapInformer = informerFactory.Core().V1().ConfigMaps().Informer()
ctx.ASMConfigController = cmconfig.NewConfigMapConfigController(ctx.KubeClient, ctx.Recorder(ctx.ASMConfigMapNamespace), ctx.ASMConfigMapNamespace, ctx.ASMConfigMapName)

Expand Down

0 comments on commit 6fc964d

Please sign in to comment.