-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5500afb
commit 39c57e9
Showing
6 changed files
with
202 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
build/charts/yorkie-cluster/templates/ratelimit-config.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: ratelimit-config | ||
namespace: {{ .Values.yorkie.namespace }} | ||
data: | ||
config.yaml: | | ||
domain: {{ .Values.ratelimit.domain }} | ||
descriptors: | ||
- key: PATH | ||
rate_limit: | ||
unit: {{ .Values.ratelimit.unit }} | ||
requests_per_unit: {{ .Values.ratelimit.requestsPerUnit }} |
63 changes: 63 additions & 0 deletions
63
build/charts/yorkie-cluster/templates/ratelimit-envoy-filter.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
apiVersion: networking.istio.io/v1alpha3 | ||
kind: EnvoyFilter | ||
metadata: | ||
name: filter-ratelimit | ||
namespace: istio-system | ||
spec: | ||
workloadSelector: | ||
labels: | ||
istio: ingressgateway | ||
configPatches: | ||
- applyTo: HTTP_FILTER | ||
match: | ||
context: GATEWAY | ||
listener: | ||
filterChain: | ||
filter: | ||
name: "envoy.filters.network.http_connection_manager" | ||
subFilter: | ||
name: "envoy.filters.http.router" | ||
patch: | ||
operation: INSERT_BEFORE | ||
value: | ||
name: envoy.filters.http.ratelimit | ||
typed_config: | ||
"@type": type.googleapis.com/envoy.extensions.filters.http.ratelimit.v3.RateLimit | ||
# Match it to the ratelimit service config | ||
domain: {{ .Values.ratelimit.domain }} | ||
failure_mode_deny: true | ||
timeout: 10s | ||
rate_limit_service: | ||
grpc_service: | ||
envoy_grpc: | ||
cluster_name: outbound|8081||ratelimit.yorkie.svc.cluster.local | ||
authority: ratelimit.yorkie.svc.cluster.local | ||
transport_api_version: V3 | ||
--- | ||
apiVersion: networking.istio.io/v1alpha3 | ||
kind: EnvoyFilter | ||
metadata: | ||
name: filter-ratelimit-svc | ||
namespace: istio-system | ||
spec: | ||
workloadSelector: | ||
labels: | ||
istio: ingressgateway | ||
configPatches: | ||
- applyTo: VIRTUAL_HOST | ||
match: | ||
context: GATEWAY | ||
routeConfiguration: | ||
vhost: | ||
name: "" | ||
route: | ||
action: ANY | ||
patch: | ||
operation: MERGE | ||
# Applies the rate limit rules. | ||
value: | ||
rate_limits: | ||
- actions: | ||
- request_headers: | ||
header_name: ":path" | ||
descriptor_key: "PATH" |
117 changes: 117 additions & 0 deletions
117
build/charts/yorkie-cluster/templates/ratelimit-service.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: redis | ||
namespace: {{ .Values.yorkie.namespace }} | ||
labels: | ||
app: redis | ||
spec: | ||
ports: | ||
- name: redis | ||
port: 6379 | ||
selector: | ||
app: redis | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: redis | ||
namespace: {{ .Values.yorkie.namespace }} | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: redis | ||
template: | ||
metadata: | ||
labels: | ||
app: redis | ||
spec: | ||
containers: | ||
- image: redis:alpine | ||
imagePullPolicy: Always | ||
name: redis | ||
ports: | ||
- name: redis | ||
containerPort: 6379 | ||
restartPolicy: Always | ||
serviceAccountName: "" | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ .Values.ratelimit.name }} | ||
namespace: {{ .Values.yorkie.namespace }} | ||
labels: | ||
app: {{ .Values.ratelimit.name }} | ||
spec: | ||
ports: | ||
- name: http-port | ||
port: 8080 | ||
targetPort: 8080 | ||
protocol: TCP | ||
- name: grpc-port | ||
port: 8081 | ||
targetPort: 8081 | ||
protocol: TCP | ||
- name: http-debug | ||
port: 6070 | ||
targetPort: 6070 | ||
protocol: TCP | ||
selector: | ||
app: ratelimit | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ .Values.ratelimit.name }} | ||
namespace: {{ .Values.yorkie.namespace }} | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: {{ .Values.ratelimit.name }} | ||
strategy: | ||
type: Recreate | ||
template: | ||
metadata: | ||
labels: | ||
app: ratelimit | ||
spec: | ||
containers: | ||
- image: envoyproxy/ratelimit:9d8d70a8 # 2022/08/16 | ||
imagePullPolicy: Always | ||
name: ratelimit | ||
command: ["/bin/ratelimit"] | ||
env: | ||
- name: LOG_LEVEL | ||
value: debug | ||
- name: REDIS_SOCKET_TYPE | ||
value: tcp | ||
- name: REDIS_URL | ||
value: redis:6379 | ||
- name: USE_STATSD | ||
value: "false" | ||
- name: RUNTIME_ROOT | ||
value: /data | ||
- name: RUNTIME_SUBDIRECTORY | ||
value: ratelimit | ||
- name: RUNTIME_WATCH_ROOT | ||
value: "false" | ||
- name: RUNTIME_IGNOREDOTFILES | ||
value: "true" | ||
- name: HOST | ||
value: "::" | ||
- name: GRPC_HOST | ||
value: "::" | ||
ports: | ||
- containerPort: 8080 | ||
- containerPort: 8081 | ||
- containerPort: 6070 | ||
volumeMounts: | ||
- name: config-volume | ||
mountPath: /data/ratelimit/config | ||
volumes: | ||
- name: config-volume | ||
configMap: | ||
name: ratelimit-config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters