Skip to content

Feat(performance): Accept protobuf responses from kube-apiserver #3749

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/deploy/configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ Currently, you can set only 1 namespace to watch in this flag. See [this Kuberne
| webhook-cert-dir | string | /tmp/k8s-webhook-server/serving-certs | The directory that contains the server key and certificate |
| webhook-cert-file | string | tls.crt | The server certificate name |
| webhook-key-file | string | tls.key | The server key name |
| accept-protobuf-content-type-enabled | boolean | false | Allows the controller to receive kubernetes api responses in protobuf instead of json, if possible. |


### disable-ingress-class-annotation
Expand Down
3 changes: 3 additions & 0 deletions helm/aws-load-balancer-controller/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ spec:
{{- if kindIs "bool" .Values.enableBackendSecurityGroup }}
- --enable-backend-security-group={{ .Values.enableBackendSecurityGroup }}
{{- end }}
{{- if kindIs "bool" .Values.enableAcceptProtobufContentType }}
- --accept-protobuf-content-type-enabled={{ .Values.enableAcceptProtobufContentType }}
{{- end }}
{{- if .Values.backendSecurityGroup }}
- --backend-security-group={{ .Values.backendSecurityGroup }}
{{- end }}
Expand Down
3 changes: 3 additions & 0 deletions helm/aws-load-balancer-controller/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ enableEndpointSlices:
# enableBackendSecurityGroup enables shared security group for backend traffic (default true)
enableBackendSecurityGroup:

# enableAcceptProtobufContentType allows the controller to receive kubernetes api responses in protobuf instead of json, if possible (default false)
enableAcceptProtobufContentType:

# backendSecurityGroup specifies backend security group id (default controller auto create backend security group)
backendSecurityGroup:

Expand Down
58 changes: 33 additions & 25 deletions pkg/config/runtime_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@ import (
)

const (
flagMetricsBindAddr = "metrics-bind-addr"
flagHealthProbeBindAddr = "health-probe-bind-addr"
flagWebhookBindPort = "webhook-bind-port"
flagEnableLeaderElection = "enable-leader-election"
flagLeaderElectionID = "leader-election-id"
flagLeaderElectionNamespace = "leader-election-namespace"
flagWatchNamespace = "watch-namespace"
flagSyncPeriod = "sync-period"
flagKubeconfig = "kubeconfig"
flagWebhookCertDir = "webhook-cert-dir"
flagWebhookCertName = "webhook-cert-file"
flagWebhookKeyName = "webhook-key-file"
flagMetricsBindAddr = "metrics-bind-addr"
flagHealthProbeBindAddr = "health-probe-bind-addr"
flagWebhookBindPort = "webhook-bind-port"
flagEnableLeaderElection = "enable-leader-election"
flagLeaderElectionID = "leader-election-id"
flagLeaderElectionNamespace = "leader-election-namespace"
flagWatchNamespace = "watch-namespace"
flagSyncPeriod = "sync-period"
flagKubeconfig = "kubeconfig"
flagWebhookCertDir = "webhook-cert-dir"
flagWebhookCertName = "webhook-cert-file"
flagWebhookKeyName = "webhook-key-file"
flagApiServerClientTimeout = "kubernetes-apiserver-client-timeout"
flagAcceptProtobufContentType = "accept-protobuf-content-type-enabled"

defaultKubeconfig = ""
defaultLeaderElectionID = "aws-load-balancer-controller-leader"
Expand All @@ -52,19 +54,20 @@ const (

// RuntimeConfig stores the configuration for the controller-runtime
type RuntimeConfig struct {
APIServer string
KubeConfig string
WebhookBindPort int
MetricsBindAddress string
HealthProbeBindAddress string
EnableLeaderElection bool
LeaderElectionID string
LeaderElectionNamespace string
WatchNamespace string
SyncPeriod time.Duration
WebhookCertDir string
WebhookCertName string
WebhookKeyName string
APIServer string
KubeConfig string
WebhookBindPort int
MetricsBindAddress string
HealthProbeBindAddress string
EnableLeaderElection bool
LeaderElectionID string
LeaderElectionNamespace string
WatchNamespace string
SyncPeriod time.Duration
WebhookCertDir string
WebhookCertName string
WebhookKeyName string
AcceptProtobufContentType bool
}

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

}

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

restCFG.QPS = defaultQPS
restCFG.Burst = defaultBurst
if rtCfg.AcceptProtobufContentType {
restCFG.AcceptContentTypes = runtime.ContentTypeProtobuf + "," + runtime.ContentTypeJSON
}
return restCFG, nil
}

Expand Down