From 1c20cf613b6919cb088908bbe2e7267f85581625 Mon Sep 17 00:00:00 2001 From: Adi Muraru Date: Wed, 6 Oct 2021 00:01:35 +0300 Subject: [PATCH] Optionally configure envoy concurrency --- api/v1beta1/kafkacluster_types.go | 9 +++++++++ charts/kafka-operator/templates/crds.yaml | 16 ++++++++++++++++ .../crds/kafka.banzaicloud.io_kafkaclusters.yaml | 16 ++++++++++++++++ pkg/resources/envoy/deployment.go | 7 +++++++ 4 files changed, 48 insertions(+) diff --git a/api/v1beta1/kafkacluster_types.go b/api/v1beta1/kafkacluster_types.go index e67086b30..cbc94b623 100644 --- a/api/v1beta1/kafkacluster_types.go +++ b/api/v1beta1/kafkacluster_types.go @@ -238,6 +238,10 @@ type TopicConfig struct { type EnvoyConfig struct { Image string `json:"image,omitempty"` Resources *corev1.ResourceRequirements `json:"resourceRequirements,omitempty"` + // Concurrency defines the number of worker threads envoy pod should run. + // If not specified defaults to the number of hardware threads on the underlying kubernetes node. + // +kubebuilder:validation:Minimum=1 + Concurrency int32 `json:"concurrency,omitempty"` // +kubebuilder:validation:Minimum=1 Replicas int32 `json:"replicas,omitempty"` ServiceAccountName string `json:"serviceAccountName,omitempty"` @@ -715,6 +719,11 @@ func (eConfig *EnvoyConfig) GetResources() *corev1.ResourceRequirements { } } +// GetConcurrency returns envoy concurrency +func (eConfig *EnvoyConfig) GetConcurrency() int32 { + return eConfig.Concurrency +} + // GetResources returns the CC specific Kubernetes resource func (cConfig *CruiseControlConfig) GetResources() *corev1.ResourceRequirements { if cConfig.Resources != nil { diff --git a/charts/kafka-operator/templates/crds.yaml b/charts/kafka-operator/templates/crds.yaml index b9cc78d59..ef52b2d58 100644 --- a/charts/kafka-operator/templates/crds.yaml +++ b/charts/kafka-operator/templates/crds.yaml @@ -15778,6 +15778,13 @@ spec: description: Annotations defines the annotations placed on the envoy ingress controller deployment type: object + concurrency: + description: Concurrency defines the number of worker threads + envoy pod should run. If not specified defaults to the number + of hardware threads on the underlying kubernetes node. + format: int32 + minimum: 1 + type: integer disruptionBudget: description: DisruptionBudget is the pod disruption budget attached to Envoy Deployment(s) @@ -17588,6 +17595,15 @@ spec: description: Annotations defines the annotations placed on the envoy ingress controller deployment type: object + concurrency: + description: Concurrency defines the number + of worker threads envoy pod should run. + If not specified defaults to the number + of hardware threads on the underlying kubernetes + node. + format: int32 + minimum: 1 + type: integer disruptionBudget: description: DisruptionBudget is the pod disruption budget attached to Envoy Deployment(s) diff --git a/config/base/crds/kafka.banzaicloud.io_kafkaclusters.yaml b/config/base/crds/kafka.banzaicloud.io_kafkaclusters.yaml index 157407fc8..7ed6d2168 100644 --- a/config/base/crds/kafka.banzaicloud.io_kafkaclusters.yaml +++ b/config/base/crds/kafka.banzaicloud.io_kafkaclusters.yaml @@ -15777,6 +15777,13 @@ spec: description: Annotations defines the annotations placed on the envoy ingress controller deployment type: object + concurrency: + description: Concurrency defines the number of worker threads + envoy pod should run. If not specified defaults to the number + of hardware threads on the underlying kubernetes node. + format: int32 + minimum: 1 + type: integer disruptionBudget: description: DisruptionBudget is the pod disruption budget attached to Envoy Deployment(s) @@ -17587,6 +17594,15 @@ spec: description: Annotations defines the annotations placed on the envoy ingress controller deployment type: object + concurrency: + description: Concurrency defines the number + of worker threads envoy pod should run. + If not specified defaults to the number + of hardware threads on the underlying kubernetes + node. + format: int32 + minimum: 1 + type: integer disruptionBudget: description: DisruptionBudget is the pod disruption budget attached to Envoy Deployment(s) diff --git a/pkg/resources/envoy/deployment.go b/pkg/resources/envoy/deployment.go index d8dc6a01f..fea84d1d2 100644 --- a/pkg/resources/envoy/deployment.go +++ b/pkg/resources/envoy/deployment.go @@ -18,6 +18,7 @@ import ( "crypto/sha256" "encoding/hex" "fmt" + "strconv" "github.com/go-logr/logr" "k8s.io/apimachinery/pkg/runtime" @@ -65,6 +66,11 @@ func (r *Reconciler) deployment(log logr.Logger, extListener v1beta1.ExternalLis }, } + arguments := []string{"-c", "/etc/envoy/envoy.yaml"} + if ingressConfig.EnvoyConfig.GetConcurrency() > 0 { + arguments = append(arguments, "--concurrency", strconv.Itoa(int(ingressConfig.EnvoyConfig.GetConcurrency()))) + } + return &appsv1.Deployment{ ObjectMeta: templates.ObjectMetaWithAnnotations( deploymentName, @@ -92,6 +98,7 @@ func (r *Reconciler) deployment(log logr.Logger, extListener v1beta1.ExternalLis { Name: "envoy", Image: ingressConfig.EnvoyConfig.GetEnvoyImage(), + Args: arguments, Ports: append(exposedPorts, []corev1.ContainerPort{ {