-
Notifications
You must be signed in to change notification settings - Fork 2
Add Envoy sidecar for consistent hashing algorithm #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3edec29
Add Envoy sidecar
bszaf 0a3724a
Fix path for envoy document_id extraction
bszaf dabbc76
Fix healtcheck path
bszaf 948810d
Update
bszaf 4d20e7b
Add testing for envoy
bszaf 677a5b6
Changelog and version
bszaf 4109d3e
Fix test
bszaf fd5051e
Update readme
bszaf 8401a85
Schema
lazyoldbear bf0e785
Polish
lazyoldbear File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Add Envoy sidecar
- Loading branch information
commit 3edec29025660f98082cbc3d5d10f13a6e632645
There are no files selected for viewing
This file contains hidden or 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
109 changes: 109 additions & 0 deletions
109
charts/document-engine/templates/envoy-sidecar-configmap.yaml
This file contains hidden or 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,109 @@ | ||
| {{- if .Values.envoySidecar.enabled -}} | ||
| {{- $fullName := include "document-engine.fullname" . -}} | ||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| metadata: | ||
| name: {{ $fullName }}-envoy-sidecar | ||
| labels: | ||
| {{- include "document-engine.labels" . | nindent 4 }} | ||
| data: | ||
| envoy.yaml: | | ||
| admin: | ||
| address: | ||
| socket_address: | ||
| address: 0.0.0.0 | ||
| port_value: {{ .Values.envoySidecar.adminPort }} | ||
|
|
||
| static_resources: | ||
| listeners: | ||
| - name: listener_0 | ||
| address: | ||
| socket_address: | ||
| address: 0.0.0.0 | ||
| port_value: {{ .Values.envoySidecar.port }} | ||
| filter_chains: | ||
| - filters: | ||
| - name: envoy.filters.network.http_connection_manager | ||
| typed_config: | ||
| "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager | ||
| stat_prefix: ingress_http | ||
| access_log: | ||
| - name: envoy.access_loggers.stdout | ||
| typed_config: | ||
| "@type": type.googleapis.com/envoy.extensions.access_loggers.stream.v3.StdoutAccessLog | ||
| route_config: | ||
| name: local_route | ||
| virtual_hosts: | ||
| - name: backend | ||
| domains: ["*"] | ||
| response_headers_to_add: | ||
| - header: | ||
| key: "x-hash-by" | ||
| value: "%REQ(X-Hash-By)%" | ||
| - header: | ||
| key: "x-envoy-upstream-remote-address" | ||
| value: "%UPSTREAM_REMOTE_ADDRESS%" | ||
| routes: | ||
| - match: | ||
| prefix: "/" | ||
| route: | ||
| cluster: document_engine_cluster | ||
| hash_policy: | ||
| - header: | ||
| header_name: "X-Hash-By" | ||
| http_filters: | ||
| # Extract document ID from URI and set as header | ||
| - name: envoy.filters.http.lua | ||
| typed_config: | ||
| "@type": type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua | ||
| inline_code: | | ||
| function envoy_on_request(request_handle) | ||
| local path = request_handle:headers():get(":path") | ||
| local document_id = nil | ||
|
|
||
| -- Try different URI patterns | ||
| document_id = string.match(path, "^/api/documents/([a-zA-Z0-9._~-]+)") | ||
| if not document_id then | ||
| document_id = string.match(path, "^/i/d/([a-zA-Z0-9._~-]+)") | ||
| end | ||
| if not document_id then | ||
| document_id = string.match(path, "^/documents/([a-zA-Z0-9._~-]+)") | ||
| end | ||
| if not document_id then | ||
| document_id = string.match(path, "^/dashboard/api/document/([a-zA-Z0-9._~-]+)") | ||
| end | ||
|
|
||
| -- Only set header if document_id found, otherwise use round-robin | ||
| if document_id then | ||
| request_handle:headers():add("X-Hash-By", document_id) | ||
| end | ||
| end | ||
| - name: envoy.filters.http.router | ||
| typed_config: | ||
| "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router | ||
|
|
||
| clusters: | ||
| - name: document_engine_cluster | ||
| connect_timeout: 5s | ||
| type: STRICT_DNS | ||
| dns_lookup_family: V4_ONLY | ||
| lb_policy: RING_HASH | ||
| ring_hash_lb_config: | ||
| minimum_ring_size: 1024 | ||
| load_assignment: | ||
| cluster_name: document_engine_cluster | ||
| endpoints: | ||
| - lb_endpoints: | ||
| - endpoint: | ||
| address: | ||
| socket_address: | ||
| address: {{ $fullName }}-headless.{{ .Release.Namespace }}.svc.cluster.local | ||
| port_value: {{ .Values.service.port }} | ||
| health_checks: | ||
| - timeout: 1s | ||
| interval: 10s | ||
| unhealthy_threshold: 2 | ||
| healthy_threshold: 2 | ||
| http_health_check: | ||
| path: /health | ||
| {{- end }} | ||
This file contains hidden or 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,17 @@ | ||
| {{- if .Values.envoySidecar.enabled -}} | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: {{ include "document-engine.fullname" . }}-headless | ||
| labels: | ||
| {{- include "document-engine.labels" . | nindent 4 }} | ||
| spec: | ||
| clusterIP: None | ||
| selector: | ||
| {{- include "document-engine.selectorLabels" . | nindent 4 }} | ||
| ports: | ||
| - port: {{ .Values.service.port }} | ||
| targetPort: api | ||
| protocol: TCP | ||
| name: api | ||
| {{- end }} |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.