Skip to content

Commit 184f385

Browse files
committed
Feat(performance): Accept protobuf responses from kube-api
Signed-off-by: Marino Borges <[email protected]>
1 parent e5d625f commit 184f385

File tree

4 files changed

+40
-25
lines changed

4 files changed

+40
-25
lines changed

docs/deploy/configurations.md

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ Currently, you can set only 1 namespace to watch in this flag. See [this Kuberne
111111
| webhook-cert-dir | string | /tmp/k8s-webhook-server/serving-certs | The directory that contains the server key and certificate |
112112
| webhook-cert-file | string | tls.crt | The server certificate name |
113113
| webhook-key-file | string | tls.key | The server key name |
114+
| accept-protobuf-content-type-enabled | boolean | false | Allows the controller to receive kubernetes api responses in protobuf instead of json, if possible. |
114115

115116

116117
### disable-ingress-class-annotation

helm/aws-load-balancer-controller/templates/deployment.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ spec:
149149
{{- if kindIs "bool" .Values.enableBackendSecurityGroup }}
150150
- --enable-backend-security-group={{ .Values.enableBackendSecurityGroup }}
151151
{{- end }}
152+
{{- if kindIs "bool" .Values.enableAcceptProtobufContentType }}
153+
- --accept-protobuf-content-type-enabled={{ .Values.enableAcceptProtobufContentType }}
154+
{{- end }}
152155
{{- if .Values.backendSecurityGroup }}
153156
- --backend-security-group={{ .Values.backendSecurityGroup }}
154157
{{- end }}

helm/aws-load-balancer-controller/values.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,9 @@ enableEndpointSlices:
336336
# enableBackendSecurityGroup enables shared security group for backend traffic (default true)
337337
enableBackendSecurityGroup:
338338

339+
# enableAcceptProtobufContentType allows the controller to receive kubernetes api responses in protobuf instead of json, if possible (default false)
340+
enableAcceptProtobufContentType:
341+
339342
# backendSecurityGroup specifies backend security group id (default controller auto create backend security group)
340343
backendSecurityGroup:
341344

pkg/config/runtime_config.go

+33-25
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,20 @@ import (
1818
)
1919

2020
const (
21-
flagMetricsBindAddr = "metrics-bind-addr"
22-
flagHealthProbeBindAddr = "health-probe-bind-addr"
23-
flagWebhookBindPort = "webhook-bind-port"
24-
flagEnableLeaderElection = "enable-leader-election"
25-
flagLeaderElectionID = "leader-election-id"
26-
flagLeaderElectionNamespace = "leader-election-namespace"
27-
flagWatchNamespace = "watch-namespace"
28-
flagSyncPeriod = "sync-period"
29-
flagKubeconfig = "kubeconfig"
30-
flagWebhookCertDir = "webhook-cert-dir"
31-
flagWebhookCertName = "webhook-cert-file"
32-
flagWebhookKeyName = "webhook-key-file"
21+
flagMetricsBindAddr = "metrics-bind-addr"
22+
flagHealthProbeBindAddr = "health-probe-bind-addr"
23+
flagWebhookBindPort = "webhook-bind-port"
24+
flagEnableLeaderElection = "enable-leader-election"
25+
flagLeaderElectionID = "leader-election-id"
26+
flagLeaderElectionNamespace = "leader-election-namespace"
27+
flagWatchNamespace = "watch-namespace"
28+
flagSyncPeriod = "sync-period"
29+
flagKubeconfig = "kubeconfig"
30+
flagWebhookCertDir = "webhook-cert-dir"
31+
flagWebhookCertName = "webhook-cert-file"
32+
flagWebhookKeyName = "webhook-key-file"
33+
flagApiServerClientTimeout = "kubernetes-apiserver-client-timeout"
34+
flagAcceptProtobufContentType = "accept-protobuf-content-type-enabled"
3335

3436
defaultKubeconfig = ""
3537
defaultLeaderElectionID = "aws-load-balancer-controller-leader"
@@ -52,19 +54,20 @@ const (
5254

5355
// RuntimeConfig stores the configuration for the controller-runtime
5456
type RuntimeConfig struct {
55-
APIServer string
56-
KubeConfig string
57-
WebhookBindPort int
58-
MetricsBindAddress string
59-
HealthProbeBindAddress string
60-
EnableLeaderElection bool
61-
LeaderElectionID string
62-
LeaderElectionNamespace string
63-
WatchNamespace string
64-
SyncPeriod time.Duration
65-
WebhookCertDir string
66-
WebhookCertName string
67-
WebhookKeyName string
57+
APIServer string
58+
KubeConfig string
59+
WebhookBindPort int
60+
MetricsBindAddress string
61+
HealthProbeBindAddress string
62+
EnableLeaderElection bool
63+
LeaderElectionID string
64+
LeaderElectionNamespace string
65+
WatchNamespace string
66+
SyncPeriod time.Duration
67+
WebhookCertDir string
68+
WebhookCertName string
69+
WebhookKeyName string
70+
AcceptProtobufContentType bool
6871
}
6972

7073
// BindFlags binds the command line flags to the fields in the config object
@@ -91,6 +94,8 @@ func (c *RuntimeConfig) BindFlags(fs *pflag.FlagSet) {
9194
fs.StringVar(&c.WebhookCertDir, flagWebhookCertDir, defaultWebhookCertDir, "WebhookCertDir is the directory that contains the webhook server key and certificate.")
9295
fs.StringVar(&c.WebhookCertName, flagWebhookCertName, defaultWebhookCertName, "WebhookCertName is the webhook server certificate name.")
9396
fs.StringVar(&c.WebhookKeyName, flagWebhookKeyName, defaultWebhookKeyName, "WebhookKeyName is the webhook server key name.")
97+
fs.BoolVar(&c.AcceptProtobufContentType, flagAcceptProtobufContentType, false,
98+
"Allows the controller to receive kubernetes api responses in protobuf instead of json, if possible. This may improve performance in serialization but is experimental.")
9499

95100
}
96101

@@ -110,6 +115,9 @@ func BuildRestConfig(rtCfg RuntimeConfig) (*rest.Config, error) {
110115

111116
restCFG.QPS = defaultQPS
112117
restCFG.Burst = defaultBurst
118+
if rtCfg.AcceptProtobufContentType {
119+
restCFG.AcceptContentTypes = runtime.ContentTypeProtobuf + "," + runtime.ContentTypeJSON
120+
}
113121
return restCFG, nil
114122
}
115123

0 commit comments

Comments
 (0)