Skip to content

Commit

Permalink
Remove multiproject sharedcontext. It was a super structure which did…
Browse files Browse the repository at this point in the history
…nt have specific purpose
  • Loading branch information
panslava committed Jan 16, 2025
1 parent 7e2667c commit 3a88791
Showing 1 changed file with 41 additions and 21 deletions.
62 changes: 41 additions & 21 deletions pkg/multiproject/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@ package start

import (
"context"
"encoding/json"
"os"

"k8s.io/apimachinery/pkg/types"
informers "k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/ingress-gce/cmd/glbc/app"
ingresscontext "k8s.io/ingress-gce/pkg/context"
"k8s.io/ingress-gce/pkg/flags"
_ "k8s.io/ingress-gce/pkg/klog"
pccontroller "k8s.io/ingress-gce/pkg/multiproject/controller"
"k8s.io/ingress-gce/pkg/multiproject/manager"
"k8s.io/ingress-gce/pkg/multiproject/sharedcontext"
"k8s.io/ingress-gce/pkg/neg/syncers/labels"
providerconfigclient "k8s.io/ingress-gce/pkg/providerconfig/client/clientset/versioned"
providerconfiginformers "k8s.io/ingress-gce/pkg/providerconfig/client/informers/externalversions"
svcnegclient "k8s.io/ingress-gce/pkg/svcneg/client/clientset/versioned"
"k8s.io/ingress-gce/pkg/utils/namer"
"k8s.io/klog/v2"
Expand All @@ -23,36 +31,48 @@ func Start(
svcNegClient svcnegclient.Interface,
kubeSystemUID types.UID,
eventRecorderKubeClient kubernetes.Interface,
namer *namer.Namer,
rootNamer *namer.Namer,
stopCh <-chan struct{},
) {
providerConfigClient, err := providerconfigclient.NewForConfig(kubeConfig)
if err != nil {
klog.Fatalf("Failed to create ProviderConfig client: %v", err)
}
sharedContext := sharedcontext.NewSharedContext(

lpConfig := labels.PodLabelPropagationConfig{}
if flags.F.EnableNEGLabelPropagation {
lpConfigEnvVar := os.Getenv("LABEL_PROPAGATION_CONFIG")
if err := json.Unmarshal([]byte(lpConfigEnvVar), &lpConfig); err != nil {
logger.Error(err, "Failed to retrieve pod label propagation config")
}
}

ctxConfig := ingresscontext.ControllerContextConfig{
ResyncPeriod: flags.F.ResyncPeriod,
}

defaultGCEConfig, err := app.GCEConfString(logger)
if err != nil {
klog.Fatalf("Error getting default cluster GCE config: %v", err)
}

informersFactory := informers.NewSharedInformerFactoryWithOptions(kubeClient, ctxConfig.ResyncPeriod)

providerConfigInformer := providerconfiginformers.NewSharedInformerFactory(providerConfigClient, ctxConfig.ResyncPeriod).Flags().V1().ProviderConfigs().Informer()

manager := manager.NewProviderConfigControllerManager(
kubeClient,
svcNegClient,
informersFactory,
providerConfigClient,
kubeSystemUID,
svcNegClient,
eventRecorderKubeClient,
namer,
rootLogger,
kubeSystemUID,
rootNamer,
namer.NewL4Namer(string(kubeSystemUID), rootNamer),
lpConfig,
defaultGCEConfig,
stopCh,
)
manager := manager.NewProviderConfigControllerManager(
kubeClient,
sharedContext.InformersFactory,
sharedContext.ProviderConfigClient,
sharedContext.SvcNegClient,
sharedContext.EventRecorderClient,
sharedContext.KubeSystemUID,
sharedContext.ClusterNamer,
sharedContext.L4Namer,
sharedContext.LpConfig,
sharedContext.DefaultCloudConfig,
sharedContext.GlobalStopCh,
rootLogger,
logger,
)

pcController := pccontroller.NewProviderConfigController(manager, providerConfigInformer, stopCh, logger)
Expand Down

0 comments on commit 3a88791

Please sign in to comment.