Skip to content

Commit

Permalink
Optionally configure envoy concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
amuraru committed Oct 7, 2021
1 parent 7d46251 commit 1c20cf6
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
9 changes: 9 additions & 0 deletions api/v1beta1/kafkacluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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 {
Expand Down
16 changes: 16 additions & 0 deletions charts/kafka-operator/templates/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions config/base/crds/kafka.banzaicloud.io_kafkaclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions pkg/resources/envoy/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"crypto/sha256"
"encoding/hex"
"fmt"
"strconv"

"github.com/go-logr/logr"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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{
{
Expand Down

0 comments on commit 1c20cf6

Please sign in to comment.