This is the "latest" release of Envoy Gateway, which contains the most recent commits from the main branch.
This release might not be stable.
Please refer to the /docs documentation for the most current information.
Dedicated Rate Limit Service
15 minute read
By default, global rate limiting uses a single rate limit service (RLS) and Redis, configured once in
the EnvoyGateway rateLimit setting and shared by every Gateway the control plane manages. They all share its
capacity, its failures, and its timeout and failClosed behavior.
A dedicated rate limit service is an RLS that Envoy Gateway deploys for a single Gateway, with its own Redis
connection and its own timeout, failClosed, telemetry and connection settings. Use it when:
- one team’s traffic must not be able to overload or break rate limiting for other teams;
- Gateways need different
timeoutorfailClosedbehavior, or different Redis backends; - you want global rate limiting for some Gateways without running a shared RLS at all.
Envoy Gateway deploys and configures the RLS; you provide Redis. Several RLS may use the same Redis, so capacity and failure isolation also depend on the Redis backends you supply. Each dedicated RLS accepts calls only from its own Gateway’s proxies, authenticated with a per-Gateway client certificate.
Dedicated RLS has the following limitations:
- It is set on the
EnvoyProxyreferenced by a Gateway’sspec.infrastructure.parametersRef.rateLimiton a GatewayClassEnvoyProxyis ignored and is never inherited throughmergeType. - Merged Gateways (
mergeGateways) keep using the shared RLS. - Only the built-in Kubernetes provider is supported.
- Redis is the only supported backend.
Tracking issue: #10520.
Prerequisites
Install Envoy Gateway
Follow the steps below to install Envoy Gateway and the example manifest. Before proceeding, you should be able to query the example backend using HTTP.
Expand for instructions
Install the Gateway API CRDs and Envoy Gateway using Helm:
Gateway API CRD compatibilityThis command installs Gateway API CRDs. If your Kubernetes provider already manages compatible Gateway API CRDs for the cluster, use the provider-managed Gateway API CRD install steps instead.
helm install eg oci://docker.io/envoyproxy/gateway-helm --version v0.0.0-latest -n envoy-gateway-system --create-namespaceInstall the GatewayClass, Gateway, HTTPRoute and example app:
kubectl apply -f https://github.com/envoyproxy/gateway/releases/download/latest/quickstart.yaml -n defaultVerify Connectivity:
Get the External IP of the Gateway:
export GATEWAY_HOST=$(kubectl get gateway/eg -o jsonpath='{.status.addresses[0].value}')Curl the example app through Envoy proxy:
curl --verbose --header "Host: www.example.com" http://$GATEWAY_HOST/getThe above command should succeed with status code 200.
Get the name of the Envoy service created the by the example Gateway:
export ENVOY_SERVICE=$(kubectl get svc -n envoy-gateway-system --selector=gateway.envoyproxy.io/owning-gateway-namespace=default,gateway.envoyproxy.io/owning-gateway-name=eg -o jsonpath='{.items[0].metadata.name}')Get the deployment of the Envoy service created the by the example Gateway:
export ENVOY_DEPLOYMENT=$(kubectl get deploy -n envoy-gateway-system --selector=gateway.envoyproxy.io/owning-gateway-namespace=default,gateway.envoyproxy.io/owning-gateway-name=eg -o jsonpath='{.items[0].metadata.name}')Port forward to the Envoy service:
kubectl -n envoy-gateway-system port-forward service/${ENVOY_SERVICE} 8888:80 &Curl the example app through Envoy proxy:
curl --verbose --header "Host: www.example.com" http://localhost:8888/getThe above command should succeed with status code 200.
Install Redis
Install a Redis instance that the dedicated RLS can reach, for example by following the Global Rate Limit task.
Enable dedicated rate limit services
Dedicated RLS is disabled by default. Enabling it lets anyone who can author a Gateway’s EnvoyProxy create an RLS
workload and configure it through rateLimit.deployment, rateLimit.hpa and rateLimit.pdb, with the same reach as the
proxy workload settings in that EnvoyProxy. Review Tenant isolation before enabling it.
Two settings are needed:
dedicatedRateLimit.rbac.enabledin the Helm chart grants the controller write access to Secrets where dedicated RLS run, and read access toReferenceGrantresources in the controller namespace. Envoy Gateway does not change its own RBAC.extensionApis.enableDedicatedRateLimitin the EnvoyGateway configuration turns the feature on. It can be changed without a Helm upgrade, so it is independent of the Helm value.
Set the Helm value before, or together with, the setting:
helm upgrade eg oci://docker.io/envoyproxy/gateway-helm \
--set dedicatedRateLimit.rbac.enabled=true \
--set config.envoyGateway.extensionApis.enableDedicatedRateLimit=true \
--reuse-values \
-n envoy-gateway-system
Or with a values.yaml file:
dedicatedRateLimit:
rbac:
enabled: true
config:
envoyGateway:
extensionApis:
enableDedicatedRateLimit: true
After updating the
ConfigMap, you will need to wait the configuration kicks in.
You can force the configuration to be reloaded by restarting theenvoy-gatewaydeployment.kubectl rollout restart deployment envoy-gateway -n envoy-gateway-system
If you manage RBAC yourself (rbac.create=false), grant the same permissions before enabling the feature. After turning
it on, confirm the controller’s permissions. With a default Helm installation:
SA=system:serviceaccount:envoy-gateway-system:envoy-gateway
# Default mode: the controller namespace. Gateway namespace mode: each Gateway namespace.
kubectl auth can-i create secrets --as=$SA -n <namespace>
kubectl auth can-i delete secrets --as=$SA -n <namespace>
kubectl auth can-i list referencegrants.gateway.networking.k8s.io --as=$SA -n envoy-gateway-system
Missing permissions are logged as a warning at startup and reported on each affected Gateway as RateLimitReady=False
with reason ProvisioningFailed.
While enableDedicatedRateLimit is false, rateLimit and the RLS workload fields on an EnvoyProxy are ignored with a
warning on the EnvoyProxy status. The Gateway stays accepted and keeps using the shared RLS, or its global rate limit
policies are rejected if no shared RLS is configured.
Configure a dedicated rate limit service
Store the Redis URL in a Secret in the Gateway’s namespace:
kubectl create namespace team-a
kubectl create secret generic team-a-redis -n team-a \
--from-literal=url=redis.redis-system.svc.cluster.local:6379
Add rateLimit to the Gateway’s EnvoyProxy. It takes the same settings as EnvoyGateway.rateLimit: backend
(required), timeout (default 20ms), failClosed (default false), telemetry and serviceSettings. The provider
block is optional and customizes the RLS workload; omit it to use built-in defaults.
cat <<EOF | kubectl apply -f -
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyProxy
metadata:
name: team-a
namespace: team-a
spec:
rateLimit:
backend:
type: Redis
redis:
urlRef:
secretKeyRef:
name: team-a-redis
key: url
timeout: 50ms
failClosed: true
deployment:
replicas: 3
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: team-a
namespace: team-a
spec:
gatewayClassName: eg
infrastructure:
parametersRef:
group: gateway.envoyproxy.io
kind: EnvoyProxy
name: team-a
listeners:
- name: http
protocol: HTTP
port: 80
EOF
Save and apply the following resources to your cluster:
---
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyProxy
metadata:
name: team-a
namespace: team-a
spec:
rateLimit:
backend:
type: Redis
redis:
urlRef:
secretKeyRef:
name: team-a-redis
key: url
timeout: 50ms
failClosed: true
deployment:
replicas: 3
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: team-a
namespace: team-a
spec:
gatewayClassName: eg
infrastructure:
parametersRef:
group: gateway.envoyproxy.io
kind: EnvoyProxy
name: team-a
listeners:
- name: http
protocol: HTTP
port: 80
Rate limit rules are configured with BackendTrafficPolicy exactly as in the Global Rate Limit task. Routes on this Gateway are rate limited by its dedicated RLS.
Each Gateway gets its own RLS, even when several Gateways reference the same EnvoyProxy. Resource names are generated;
rateLimit.deployment.name, rateLimit.hpa.name and rateLimit.pdb.name are ignored with a warning.
Check that the RLS is ready:
kubectl get gateway team-a -n team-a \
-o jsonpath='{.status.conditions[?(@.type=="RateLimitReady")]}'
kubectl get deployments,services -n <rls-namespace> \
-l gateway.envoyproxy.io/owning-gateway-namespace=team-a,gateway.envoyproxy.io/owning-gateway-name=team-a
Where dedicated rate limit services run
A dedicated RLS runs next to its Gateway’s proxies (see Gateway Namespace Mode). The shared RLS stays in the controller namespace in both modes.
| Deployment mode | Proxies run in | Dedicated RLS runs in |
|---|---|---|
Default (ControllerNamespace) | The controller namespace | The controller namespace |
GatewayNamespace | The Gateway’s namespace | The Gateway’s namespace |
All resources of a dedicated RLS (Deployment, Service, HPA, PDB, ServiceAccount, ConfigMap and Secrets) are created in that namespace and count against its quota. They carry these labels:
| Label | Value |
|---|---|
app.kubernetes.io/name | The generated RLS name, starting with envoy-ratelimit-gw- |
app.kubernetes.io/component | ratelimit |
app.kubernetes.io/managed-by | envoy-gateway |
gateway.envoyproxy.io/ratelimit-scope | gateway |
gateway.envoyproxy.io/owning-gateway-namespace | The Gateway’s namespace |
gateway.envoyproxy.io/owning-gateway-name | The Gateway’s name |
flowchart LR
subgraph nsa["Namespace team-a"]
A["Gateway A proxies"]
RA["Dedicated RLS A"]
end
subgraph nsc["Namespace team-c"]
C["Gateway C proxies<br/>(no rateLimit)"]
end
subgraph cp["Controller namespace"]
EG["Envoy Gateway"]
RS["Shared RLS"]
end
RedisA[("Redis A")]
RedisS[("Shared Redis")]
A --> RA --> RedisA
C --> RS --> RedisS
EG -. rules .-> RA
EG -. rules .-> RSThe diagram shows Gateway namespace mode. In the default mode, the proxies and every RLS run in the controller namespace.
Image and pull secrets
A dedicated RLS takes its container image, imagePullSecrets and imagePullPolicy from the shared RLS settings in
EnvoyGateway.provider.kubernetes.rateLimitDeployment, for example the Helm values global.imageRegistry,
global.images.ratelimit and global.imagePullSecrets, even when no shared RLS is configured. No other shared RLS
setting is inherited.
Pull secrets are referenced by name in the namespace where the RLS runs. In Gateway namespace mode, Envoy Gateway does not copy them: create them in every Gateway namespace that uses a dedicated RLS, as you already must for proxies pulling from a private registry.
Shared rules
Rules with shared: true share one bucket only among the policy’s targets that use the same RLS. Each dedicated
RLS keeps its own bucket, and the shared RLS keeps one bucket for all targets on it. For example, a shared 100 rps rule
targeting Gateway A (dedicated RLS), Gateway B (dedicated RLS) and Gateways C and D (shared RLS) allows up to 100 rps on
A, 100 rps on B, and 100 rps across C and D together. This holds even when the RLS use the same Redis database: each
dedicated RLS prefixes its Redis keys with <gateway-namespace>/<gateway-name>:.
When a shared rule’s targets use more than one RLS, the BackendTrafficPolicy reports the condition
SharedRateLimitCrossScope=True with reason MultipleRLSScopes, listing the RLS involved. The policy stays accepted.
To enforce one bucket across Gateways, keep those Gateways on the shared RLS.
If you set a custom CACHE_KEY_PREFIX on the shared RLS, it must not have the <namespace>/<name>: form, or shared
and dedicated counters in the same Redis database can merge.
Redis credentials
backend.redis.urlRef.secretKeyRef and backend.redis.tls.certificateRef must refer to Secrets in the EnvoyProxy’s
namespace, in both deployment modes. A ReferenceGrant does not lift this restriction. To share one Redis client
certificate between Gateways, replicate it into each Gateway namespace, for example with an external secrets tool.
Exception in the default mode: tls.certificateRef may also refer to a Secret in the controller namespace, where
the RLS runs, so admins can keep Redis client certificates out of tenant namespaces. This requires a ReferenceGrant
in the controller namespace that allows the EnvoyProxy’s namespace to reference that Secret:
apiVersion: gateway.networking.k8s.io/v1beta1
kind: ReferenceGrant
metadata:
name: team-a-redis-client-cert
namespace: envoy-gateway-system
spec:
from:
- group: gateway.envoyproxy.io
kind: EnvoyProxy
namespace: team-a
to:
- group: ""
kind: Secret
name: team-a-redis-client-cert
Secrets that Envoy Gateway owns or requires, such as envoy-rate-limit-ca, the control plane certificates and the
Secrets of any RLS, are never accepted, even with a grant. The exception does not apply to urlRef, or in Gateway
namespace mode.
In the default mode, Envoy Gateway copies Secrets from the EnvoyProxy’s namespace into a Secret it owns in the
controller namespace. Any change to a referenced Secret rolls the RLS Deployment so that new pods load the new
credentials.
Deleting a Secret or revoking a ReferenceGrant reports InvalidCredentials, but is not a reliable way to cut off
Redis access: running pods keep their credentials. To stop an RLS from using credentials, revoke them at Redis by
changing the password or ACL, or revoking the client certificate.
Status
Each Gateway with a dedicated RLS reports the RateLimitReady condition. RateLimitReady=True with reason Ready means
that credentials resolved, certificates are current, and the RLS Deployment has rolled out with at least one ready
endpoint. It does not confirm that the RLS has loaded its rules or can reach Redis; verify enforcement separately.
| Status | Reason | Meaning |
|---|---|---|
True | Ready | The RLS infrastructure is ready. |
Unknown | PendingObservation | The controller has not yet observed the RLS state, for example right after a restart. |
False | InvalidCredentials | A Redis Secret reference is missing, has invalid keys, is outside the namespace rules, or lacks a ReferenceGrant. |
False | CertificateUnavailable | The envoy-rate-limit-ca Secret is missing, invalid or expired, or an issued certificate is invalid or expired. |
False | ProvisioningFailed | Creating or updating a resource failed, including because the controller lacks Secret or ReferenceGrant permissions. |
False | RolloutFailed | The RLS Deployment exceeded its progress deadline. |
False | Provisioning | The RLS resources have not been observed yet. |
False | RollingOut | The RLS Deployment rollout has not completed. |
False | NoReadyEndpoints | The RLS Service has no ready endpoint from the current rollout. |
When several failures apply, the first matching False reason in the table is reported. Credential and certificate
failures never move a Gateway to another RLS; calls that cannot be served follow failClosed.
Certificates
Dedicated RLS use a separate certificate authority stored in the envoy-rate-limit-ca Secret in the controller
namespace. The certgen job creates it if it does not exist, also when upgrading, without touching existing certificates.
The controller uses it to issue each RLS’s serving and configuration client certificates, stored in a Secret next to the
RLS, and each Gateway’s proxy client certificate, delivered to its proxies over xDS. Certificates are valid for five
years, capped at the CA’s expiry, and are not renewed automatically: monitor their expiry.
If you supply your own control plane certificates (see Custom Certificates), also create the RLS CA before enabling dedicated RLS. The Secret must:
- be named
envoy-rate-limit-cain the controller namespace, with typekubernetes.io/tls; - hold a PEM-encoded, self-signed CA certificate in
tls.crt, with CA basic constraints and the certificate-signing key usage, and its PEM-encoded private key intls.key. Intermediate CA chains are not supported.
For example, with cert-manager and the selfsigned-issuer from Custom Certificates:
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: envoy-rate-limit-ca
namespace: envoy-gateway-system
spec:
isCA: true
commonName: envoy-rate-limit-ca
secretName: envoy-rate-limit-ca
duration: 43800h
privateKey:
algorithm: RSA
size: 2048
issuerRef:
name: selfsigned-issuer
kind: Issuer
Envoy Gateway picks up a created or replaced RLS CA without a restart.
Tenant isolation
Enabling dedicated RLS is an administrator decision to delegate RLS workloads to EnvoyProxy authors. Envoy Gateway
does not validate workload overrides or harden tenant namespaces, and neither enabling the feature nor
RateLimitReady=True guarantees tenant isolation. Restrict who can author EnvoyProxy resources, or restrict their
workload fields with admission policy (for example Kyverno, OPA Gatekeeper or ValidatingAdmissionPolicy); one policy
covers both proxy and RLS fields.
Caller isolation between dedicated RLS relies on the envoy-rate-limit-ca private key: anyone who can read that Secret
can impersonate any Gateway to any dedicated RLS. In every mode, limit who can read Secrets in the controller namespace.
Gateway namespace mode. The RLS runs in the Gateway’s namespace, so the namespace’s ResourceQuota, LimitRange and NetworkPolicies apply to it, and nothing new is placed in the controller namespace. Anyone who can read Secrets in a Gateway namespace can read the RLS Secrets of every Gateway there; if Gateways of different owners share a namespace, restrict Secret reads there.
Default mode. There is no namespace boundary between tenants, for proxies or for RLS. Operators running multiple tenants in this mode should:
- keep workload overrides, which can mount Secrets in the controller namespace, away from tenant authors;
- plan capacity and quota for the controller namespace, where each dedicated RLS adds a Deployment;
- restrict egress from proxy and RLS pods with NetworkPolicy if tenants must not reach internal services.
Gateway owners choose the Redis URL and the tracing endpoint that the RLS connects to. To restrict that egress, select dedicated RLS pods with the labels above, for example:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: team-a-ratelimit-egress
namespace: team-a
spec:
podSelector:
matchLabels:
app.kubernetes.io/component: ratelimit
gateway.envoyproxy.io/ratelimit-scope: gateway
gateway.envoyproxy.io/owning-gateway-name: team-a
policyTypes:
- Egress
egress:
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: redis-system
ports:
- protocol: TCP
port: 6379
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: envoy-gateway-system
ports:
- protocol: TCP
port: 18001
- ports:
- protocol: UDP
port: 53
- protocol: TCP
port: 53
The RLS needs to reach Redis, the Envoy Gateway configuration server on port 18001, DNS, and any configured telemetry
endpoint.
Changing the configuration
Moving a Gateway between the shared RLS and a dedicated one, by adding or removing rateLimit or by toggling
enableDedicatedRateLimit, is a planned maintenance operation:
- Calls to an RLS that is unavailable follow
failClosed. - A proxy may briefly keep calling the previous RLS after its rules have moved. That RLS allows unknown domains, so
requests can bypass limits even with
failClosed: true. - Counters move to a different Redis keyspace and may start from zero, or reuse earlier counters in that keyspace.
If you need continuous enforcement, stop or externally gate traffic to the Gateway during the change, and verify the
proxy configuration and actual rate limiting before restoring it. RateLimitReady=True alone is not sufficient.
Updating Redis settings or credentials of an existing dedicated RLS rolls its Deployment in place.
Turning off enableDedicatedRateLimit
Turning off enableDedicatedRateLimit affects every Gateway with a dedicated RLS at once:
- Proxies move to the shared RLS without coordination. Until they have, rate limits may not be enforced, or requests may
be denied with
failClosed: true. - Without a shared RLS (
EnvoyGateway.rateLimit), the global rate limit policies of those Gateways are rejected and their routes serve without global rate limiting. - Each Gateway takes the shared RLS’s
timeout,failClosedand other settings. A Gateway configured to fail closed can start failing open. - All of that traffic moves to the shared RLS and its Redis, and
shared: truebuckets that were separate per RLS merge. - Dedicated RLS resources are not removed and must be cleaned up manually.
- It is not an emergency switch: it does not revoke Redis credentials.
To retire dedicated RLS safely, for each affected Gateway one at a time:
- Externally gate traffic to the Gateway during planned maintenance.
- Remove
rateLimitfrom itsEnvoyProxy. Envoy Gateway removes the dedicated RLS. - Verify that every proxy that will serve traffic has the intended configuration and that the intended rate limits are enforced, then restore traffic. Keep proxies whose configuration cannot be verified out of service.
Turn the setting off only once no Gateway uses a dedicated RLS. Afterwards, check for leftover dedicated RLS in the namespaces this installation manages:
kubectl get deployments -n <namespace> -l gateway.envoyproxy.io/ratelimit-scope=gateway
Then decide whether to keep dedicatedRateLimit.rbac.enabled. Keep it if the feature may be turned on again; otherwise
set it to false to return the controller to its previous privileges. Removing dedicated RLS does not need it.
Clean-up
Envoy Gateway removes a dedicated RLS when it observes its Gateway being deleted or no longer setting rateLimit.
Resources are left behind when:
enableDedicatedRateLimitis turned off;- a Gateway drops
rateLimit, or, in the default mode, is deleted, while Envoy Gateway is stopped; - the deployment mode is switched, which provisions the RLS in the new namespace and leaves the old one.
For each such Gateway, verify that its proxies no longer use the old RLS and that the resources belong to this installation, then delete them. Deleting the Deployment also removes its Secrets:
kubectl delete deployment,service,hpa,pdb,serviceaccount,configmap -n <old-rls-namespace> \
-l 'gateway.envoyproxy.io/ratelimit-scope=gateway,gateway.envoyproxy.io/owning-gateway-namespace=<gateway-namespace>,gateway.envoyproxy.io/owning-gateway-name=<gateway-name>'
Always specify the old RLS namespace and both Gateway labels, and do not use -A. After a deployment mode change, only
the placement outside the Gateway’s current RLS namespace is stale; Gateways in the controller namespace keep their RLS
in either mode, so do not delete theirs. Multiple Envoy Gateway installations managing Gateways in the same namespace are
not supported with dedicated RLS.
To remove the resources created in this task:
kubectl delete gateway/team-a envoyproxy/team-a secret/team-a-redis -n team-a
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.