mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-17 20:00:07 +00:00
Tweak the informer for Services
It no longer filters out Services with the v1.IsHeadlessService label as that is left for EndpointSlices
This commit is contained in:
@@ -572,13 +572,16 @@ func (s *ProxyServer) Run(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
labelSelector := labels.NewSelector()
|
||||
labelSelector = labelSelector.Add(*noProxyName, *noHeadlessEndpoints)
|
||||
labelSelectorNoProxyName := labels.NewSelector().Add(*noProxyName)
|
||||
labelSelectorNoHeadlessEndpoints := labels.NewSelector().Add(*noHeadlessEndpoints)
|
||||
|
||||
// Make informers that filter out objects that want a non-default service proxy.
|
||||
informerFactory := informers.NewSharedInformerFactoryWithOptions(s.Client, s.Config.ConfigSyncPeriod.Duration,
|
||||
// Make informer that contains no filters
|
||||
informerFactory := informers.NewSharedInformerFactoryWithOptions(s.Client, s.Config.ConfigSyncPeriod.Duration)
|
||||
|
||||
// Make informers that filter out objects that do not contain a service.kubernetes.io/headless label
|
||||
endpointSliceInformerFactory := informers.NewSharedInformerFactoryWithOptions(s.Client, s.Config.ConfigSyncPeriod.Duration,
|
||||
informers.WithTweakListOptions(func(options *metav1.ListOptions) {
|
||||
options.LabelSelector = labelSelector.String()
|
||||
options.LabelSelector = labelSelectorNoHeadlessEndpoints.String()
|
||||
}))
|
||||
|
||||
// Create configs (i.e. Watches for Services, EndpointSlices and ServiceCIDRs)
|
||||
@@ -588,14 +591,14 @@ func (s *ProxyServer) Run(ctx context.Context) error {
|
||||
// don't watch headless services for kube-proxy, they are proxied by DNS.
|
||||
serviceInformerFactory := informers.NewSharedInformerFactoryWithOptions(s.Client, s.Config.ConfigSyncPeriod.Duration,
|
||||
informers.WithTweakListOptions(func(options *metav1.ListOptions) {
|
||||
options.LabelSelector = labelSelector.String()
|
||||
options.LabelSelector = labelSelectorNoProxyName.String()
|
||||
options.FieldSelector = fields.OneTermNotEqualSelector("spec.clusterIP", v1.ClusterIPNone).String()
|
||||
}))
|
||||
serviceConfig := config.NewServiceConfig(ctx, serviceInformerFactory.Core().V1().Services(), s.Config.ConfigSyncPeriod.Duration)
|
||||
serviceConfig.RegisterEventHandler(s.Proxier)
|
||||
go serviceConfig.Run(ctx.Done())
|
||||
|
||||
endpointSliceConfig := config.NewEndpointSliceConfig(ctx, informerFactory.Discovery().V1().EndpointSlices(), s.Config.ConfigSyncPeriod.Duration)
|
||||
endpointSliceConfig := config.NewEndpointSliceConfig(ctx, endpointSliceInformerFactory.Discovery().V1().EndpointSlices(), s.Config.ConfigSyncPeriod.Duration)
|
||||
endpointSliceConfig.RegisterEventHandler(s.Proxier)
|
||||
go endpointSliceConfig.Run(ctx.Done())
|
||||
|
||||
@@ -607,6 +610,7 @@ func (s *ProxyServer) Run(ctx context.Context) error {
|
||||
// This has to start after the calls to NewServiceConfig because that
|
||||
// function must configure its shared informer event handlers first.
|
||||
informerFactory.Start(wait.NeverStop)
|
||||
endpointSliceInformerFactory.Start(wait.NeverStop)
|
||||
serviceInformerFactory.Start(wait.NeverStop)
|
||||
|
||||
// hollow-proxy doesn't need node config, and we don't create nodeManager for hollow-proxy.
|
||||
|
||||
Reference in New Issue
Block a user