Skip to content

Commit

Permalink
fix k8s headless service miss namespace (#3407)
Browse files Browse the repository at this point in the history
* feat: add namespace for initialize the registry

* feat: add namespace for initialize the registry

* feat: add namespace for initialize the registry

* feat: add namespace for initialize the registry
  • Loading branch information
dagehuifei authored Nov 4, 2024
1 parent 79886e4 commit 3ecb1d6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions contrib/registry/kubernetes/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,11 @@ type Registry struct {
}

// NewRegistry is used to initialize the Registry
func NewRegistry(clientSet *kubernetes.Clientset) *Registry {
informerFactory := informers.NewSharedInformerFactory(clientSet, time.Minute*10)
func NewRegistry(clientSet *kubernetes.Clientset, namespace string) *Registry {
if strings.EqualFold(namespace, "") {
namespace = metav1.NamespaceAll
}
informerFactory := informers.NewSharedInformerFactoryWithOptions(clientSet, time.Minute*10, informers.WithNamespace(namespace))
podInformer := informerFactory.Core().V1().Pods().Informer()
podLister := informerFactory.Core().V1().Pods().Lister()
return &Registry{
Expand Down
2 changes: 1 addition & 1 deletion contrib/registry/kubernetes/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func TestRegistry(t *testing.T) {
t.Fatal(err)
}

r := NewRegistry(clientSet)
r := NewRegistry(clientSet, currentNamespace)
r.Start()

svrHello := &registry.ServiceInstance{
Expand Down

0 comments on commit 3ecb1d6

Please sign in to comment.