Skip to content

Commit c3a74a4

Browse files
committed
Use protobuf encoding for core K8s APIs in ingress-nginx
1 parent 57b4a14 commit c3a74a4

File tree

6 files changed

+317
-2
lines changed

6 files changed

+317
-2
lines changed

cmd/nginx/main.go

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/prometheus/client_golang/prometheus/collectors"
3030
"k8s.io/apimachinery/pkg/api/errors"
3131
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
32+
kuberuntime "k8s.io/apimachinery/pkg/runtime"
3233
"k8s.io/apimachinery/pkg/util/wait"
3334
discovery "k8s.io/apimachinery/pkg/version"
3435
"k8s.io/client-go/kubernetes"
@@ -202,6 +203,8 @@ func createApiserverClient(apiserverHost, rootCAFile, kubeConfig string) (*kuber
202203
cfg.TLSClientConfig = tlsClientConfig
203204
}
204205

206+
cfg.ContentType = kuberuntime.ContentTypeProtobuf
207+
205208
klog.InfoS("Creating API client", "host", cfg.Host)
206209

207210
client, err := kubernetes.NewForConfig(cfg)

cmd/plugin/request/request.go

+7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
discoveryv1 "k8s.io/api/discovery/v1"
2626
networking "k8s.io/api/networking/v1"
2727
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
28+
"k8s.io/apimachinery/pkg/runtime"
2829
"k8s.io/cli-runtime/pkg/genericclioptions"
2930
appsv1client "k8s.io/client-go/kubernetes/typed/apps/v1"
3031
corev1 "k8s.io/client-go/kubernetes/typed/core/v1"
@@ -97,6 +98,7 @@ func GetDeployments(flags *genericclioptions.ConfigFlags, namespace string) ([]a
9798
if err != nil {
9899
return make([]appsv1.Deployment, 0), err
99100
}
101+
rawConfig.ContentType = runtime.ContentTypeProtobuf
100102

101103
api, err := appsv1client.NewForConfig(rawConfig)
102104
if err != nil {
@@ -117,6 +119,7 @@ func GetIngressDefinitions(flags *genericclioptions.ConfigFlags, namespace strin
117119
if err != nil {
118120
return make([]networking.Ingress, 0), err
119121
}
122+
rawConfig.ContentType = runtime.ContentTypeProtobuf
120123

121124
api, err := typednetworking.NewForConfig(rawConfig)
122125
if err != nil {
@@ -193,6 +196,7 @@ func getEndpointSlices(flags *genericclioptions.ConfigFlags, namespace string) (
193196
if err != nil {
194197
return nil, err
195198
}
199+
rawConfig.ContentType = runtime.ContentTypeProtobuf
196200

197201
api, err := discoveryv1client.NewForConfig(rawConfig)
198202
if err != nil {
@@ -259,6 +263,7 @@ func getPods(flags *genericclioptions.ConfigFlags) ([]apiv1.Pod, error) {
259263
if err != nil {
260264
return make([]apiv1.Pod, 0), err
261265
}
266+
rawConfig.ContentType = runtime.ContentTypeProtobuf
262267

263268
api, err := corev1.NewForConfig(rawConfig)
264269
if err != nil {
@@ -280,6 +285,7 @@ func getLabeledPods(flags *genericclioptions.ConfigFlags, label string) ([]apiv1
280285
if err != nil {
281286
return make([]apiv1.Pod, 0), err
282287
}
288+
rawConfig.ContentType = runtime.ContentTypeProtobuf
283289

284290
api, err := corev1.NewForConfig(rawConfig)
285291
if err != nil {
@@ -319,6 +325,7 @@ func getServices(flags *genericclioptions.ConfigFlags) ([]apiv1.Service, error)
319325
if err != nil {
320326
return make([]apiv1.Service, 0), err
321327
}
328+
rawConfig.ContentType = runtime.ContentTypeProtobuf
322329

323330
api, err := corev1.NewForConfig(rawConfig)
324331
if err != nil {

0 commit comments

Comments
 (0)