From d6530559cda2cf4e17180e3576abe900bb6bf8bb Mon Sep 17 00:00:00 2001 From: Antoni Zawodny Date: Mon, 9 Sep 2024 16:29:36 +0200 Subject: [PATCH] Use protobuf encoding for core K8s APIs in netd --- pkg/metrics/collector/netlink_metrics.go | 2 ++ pkg/metrics/collector/pod_ip_metrics.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/pkg/metrics/collector/netlink_metrics.go b/pkg/metrics/collector/netlink_metrics.go index 13237440..853b6e83 100644 --- a/pkg/metrics/collector/netlink_metrics.go +++ b/pkg/metrics/collector/netlink_metrics.go @@ -30,6 +30,7 @@ import ( "golang.org/x/sys/unix" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/fields" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" "k8s.io/client-go/tools/cache" @@ -128,6 +129,7 @@ func createPodWatch() error { if err != nil { return err } + config.ContentType = runtime.ContentTypeProtobuf // creates the clientset clientset, err := kubernetes.NewForConfig(config) if err != nil { diff --git a/pkg/metrics/collector/pod_ip_metrics.go b/pkg/metrics/collector/pod_ip_metrics.go index a336ebe3..89a373b7 100644 --- a/pkg/metrics/collector/pod_ip_metrics.go +++ b/pkg/metrics/collector/pod_ip_metrics.go @@ -27,6 +27,7 @@ import ( "time" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" @@ -162,6 +163,7 @@ func NewPodIPMetricsCollector() (Collector, error) { if err != nil { return nil, fmt.Errorf("error creating in-cluster config: %v", err) } + config.ContentType = runtime.ContentTypeProtobuf clientset, err := kubernetes.NewForConfig(config) if err != nil {