Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable metadata service to track the events from a subset of namespaces #1368

Merged
merged 10 commits into from
Jul 14, 2023
Prev Previous commit
Next Next commit
Create controller with namespaces
Signed-off-by: Ata Fatahi <afatahibaarzi@linkedin.com>
Signed-off-by: Ata Fatahi <immrata@gmail.com>
  • Loading branch information
MrAta committed Jul 14, 2023
commit eadf257167e7f72a35884dfa1e4615f4d1a11a07
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type watcher interface {
}

// NewController creates a new Controller.
func NewController(updateCh chan *K8sResourceMessage) (*Controller, error) {
func NewController(namespaces []string, updateCh chan *K8sResourceMessage) (*Controller, error) {
// There is a specific config for services running in the cluster.
kubeConfig, err := rest.InClusterConfig()
if err != nil {
Expand All @@ -72,13 +72,13 @@ func NewControllerWithClientSet(updateCh chan *K8sResourceMessage, clientset kub
// for example, nodes and namespaces must be synced before pods, since nodes/namespaces
// contain pods.
watchers := []watcher{
nodeWatcher("nodes", updateCh, clientset),
namespaceWatcher("namespaces", updateCh, clientset),
podWatcher("pods", updateCh, clientset),
endpointsWatcher("endpoints", updateCh, clientset),
serviceWatcher("services", updateCh, clientset),
replicaSetWatcher("replicasets", updateCh, clientset),
deploymentWatcher("deployments", updateCh, clientset),
nodeWatcher("nodes", namespaces, updateCh, clientset),
namespaceWatcher("namespaces", namespaces, updateCh, clientset),
podWatcher("pods", namespaces, updateCh, clientset),
endpointsWatcher("endpoints", namespaces, updateCh, clientset),
serviceWatcher("services", namespaces, updateCh, clientset),
replicaSetWatcher("replicasets", namespaces, updateCh, clientset),
deploymentWatcher("deployments", namespaces, updateCh, clientset),
}

mc := &Controller{quitCh: quitCh, updateCh: updateCh, watchers: watchers}
Expand Down
4 changes: 3 additions & 1 deletion src/vizier/services/metadata/metadata_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"go.etcd.io/etcd/client/pkg/v3/transport"
clientv3 "go.etcd.io/etcd/client/v3"
"google.golang.org/grpc"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"

version "px.dev/pixie/src/shared/goversion"
"px.dev/pixie/src/shared/services"
Expand Down Expand Up @@ -158,6 +159,7 @@ func etcdTLSConfig() (*tls.Config, error) {
}

func main() {
namespaces := []string{v1.NamespaceAll}
services.SetupService("metadata", 50400)
services.SetupSSLClientFlags()
services.PostFlagSetupAndParse()
Expand Down Expand Up @@ -235,7 +237,7 @@ func main() {
updateCh := make(chan *k8smeta.K8sResourceMessage)
mdh := k8smeta.NewHandler(updateCh, k8sMds, k8sMds, nc)

k8sMc, err := k8smeta.NewController(updateCh)
k8sMc, err := k8smeta.NewController(namespaces, updateCh)
defer k8sMc.Stop()

ads := agent.NewDatastore(dataStore, 24*time.Hour)
Expand Down