Skip to content

Commit

Permalink
feat(proxy): introduce Concurrency under EnvoyProxy resource (#1719)
Browse files Browse the repository at this point in the history
* feat(proxy): introduce concurrency field

Signed-off-by: Ardika Bagus <me@ardikabs.com>

* chore(proxy): fix wording

Signed-off-by: Ardika Bagus <me@ardikabs.com>

---------

Signed-off-by: Ardika Bagus <me@ardikabs.com>
  • Loading branch information
ardikabs committed Aug 3, 2023
1 parent 94c588a commit f8cf3e7
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/config/v1alpha1/envoyproxy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ type EnvoyProxySpec struct {
//
// +optional
Bootstrap *string `json:"bootstrap,omitempty"`

// Concurrency defines the number of worker threads to run. If unset, it defaults to
// the number of cpuset threads on the platform.
//
// +optional
Concurrency *int32 `json:"concurrency,omitempty"`
}

type ProxyTelemetry struct {
Expand Down
5 changes: 5 additions & 0 deletions api/config/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ spec:
You can edit this configuration, and rerun `egctl x translate` to
ensure there are no validation errors.
type: string
concurrency:
description: Concurrency defines the number of worker threads to run.
If unset, it defaults to the number of cpuset threads on the platform.
format: int32
type: integer
logging:
default:
level:
Expand Down
1 change: 1 addition & 0 deletions docs/latest/api/config_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ _Appears in:_
| `logging` _[ProxyLogging](#proxylogging)_ | Logging defines logging parameters for managed proxies. |
| `telemetry` _[ProxyTelemetry](#proxytelemetry)_ | Telemetry defines telemetry parameters for managed proxies. |
| `bootstrap` _string_ | Bootstrap defines the Envoy Bootstrap as a YAML string. Visit https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/bootstrap/v3/bootstrap.proto#envoy-v3-api-msg-config-bootstrap-v3-bootstrap to learn more about the syntax. If set, this is the Bootstrap configuration used for the managed Envoy Proxy fleet instead of the default Bootstrap configuration set by Envoy Gateway. Some fields within the Bootstrap that are required to communicate with the xDS Server (Envoy Gateway) and receive xDS resources from it are not configurable and will result in the `EnvoyProxy` resource being rejected. Backward compatibility across minor versions is not guaranteed. We strongly recommend using `egctl x translate` to generate a `EnvoyProxy` resource with the `Bootstrap` field set to the default Bootstrap configuration used. You can edit this configuration, and rerun `egctl x translate` to ensure there are no validation errors. |
| `concurrency` _integer_ | Concurrency defines the number of worker threads to run. If unset, it defaults to the number of cpuset threads on the platform. |



Expand Down
6 changes: 6 additions & 0 deletions internal/infrastructure/kubernetes/proxy/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ func expectedProxyContainers(infra *ir.ProxyInfra, deploymentConfig *egcfgv1a1.K
fmt.Sprintf("--log-level %s", logLevel),
"--cpuset-threads",
}

if infra.Config != nil &&
infra.Config.Spec.Concurrency != nil {
args = append(args, fmt.Sprintf("--concurrency %d", *infra.Config.Spec.Concurrency))
}

if componentLogLevel := componentLogLevelArgs(proxyLogging.Level); componentLogLevel != "" {
args = append(args, fmt.Sprintf("--component-log-level %s", componentLogLevel))
}
Expand Down
12 changes: 12 additions & 0 deletions internal/infrastructure/kubernetes/proxy/resource_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func TestDeployment(t *testing.T) {
proxyLogging map[egcfgv1a1.LogComponent]egcfgv1a1.LogLevel
bootstrap *string
telemetry *egcfgv1a1.ProxyTelemetry
concurrency *int32
}{
{
caseName: "default",
Expand Down Expand Up @@ -262,6 +263,13 @@ func TestDeployment(t *testing.T) {
},
},
},
{
caseName: "with-concurrency",
infra: newTestInfra(),
deploy: nil,
concurrency: pointer.Int32(4),
bootstrap: pointer.String(`test bootstrap config`),
},
}
for _, tc := range cases {
t.Run(tc.caseName, func(t *testing.T) {
Expand All @@ -284,6 +292,10 @@ func TestDeployment(t *testing.T) {
}
}

if tc.concurrency != nil {
tc.infra.Proxy.Config.Spec.Concurrency = tc.concurrency
}

r := NewResourceRender(cfg.Namespace, tc.infra.GetProxyInfra())
dp, err := r.Deployment()
require.NoError(t, err)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/name: envoy
app.kubernetes.io/component: proxy
app.kubernetes.io/managed-by: envoy-gateway
gateway.envoyproxy.io/owning-gateway-name: default
gateway.envoyproxy.io/owning-gateway-namespace: default
name: envoy-default-64656661
namespace: envoy-gateway-system
spec:
replicas: 1
strategy:
type: RollingUpdate
selector:
matchLabels:
app.kubernetes.io/name: envoy
app.kubernetes.io/component: proxy
app.kubernetes.io/managed-by: envoy-gateway
gateway.envoyproxy.io/owning-gateway-name: default
gateway.envoyproxy.io/owning-gateway-namespace: default
template:
metadata:
labels:
app.kubernetes.io/name: envoy
app.kubernetes.io/component: proxy
app.kubernetes.io/managed-by: envoy-gateway
gateway.envoyproxy.io/owning-gateway-name: default
gateway.envoyproxy.io/owning-gateway-namespace: default
spec:
automountServiceAccountToken: false
containers:
- args:
- --service-cluster default
- --service-node $(ENVOY_POD_NAME)
- --config-yaml test bootstrap config
- --log-level warn
- --cpuset-threads
- --concurrency 4
command:
- envoy
env:
- name: ENVOY_GATEWAY_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: ENVOY_POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
image: envoyproxy/envoy-dev:latest
imagePullPolicy: IfNotPresent
name: envoy
ports:
- containerPort: 8080
name: EnvoyHTTPPort
protocol: TCP
- containerPort: 8443
name: EnvoyHTTPSPort
protocol: TCP
resources:
requests:
cpu: 100m
memory: 512Mi
readinessProbe:
httpGet:
path: /ready
port: 19001
scheme: HTTP
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /certs
name: certs
readOnly: true
- mountPath: /sds
name: sds
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
serviceAccountName: envoy-default-64656661
terminationGracePeriodSeconds: 300
volumes:
- name: certs
secret:
secretName: envoy
defaultMode: 420
- configMap:
defaultMode: 420
items:
- key: xds-trusted-ca.json
path: xds-trusted-ca.json
- key: xds-certificate.json
path: xds-certificate.json
name: envoy-default-64656661
optional: false
name: sds
revisionHistoryLimit: 10
progressDeadlineSeconds: 600

0 comments on commit f8cf3e7

Please sign in to comment.