Last active
December 13, 2018 18:39
-
-
Save k/6b7635f7698e8c6c4a9daa960a96cde9 to your computer and use it in GitHub Desktop.
Envoy config for routing consistently to a StatefulSet
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
files: | |
envoy.yaml: |- | |
## refs: | |
## - https://www.envoyproxy.io/docs/envoy/latest/start/start#quick-start-to-run-simple-example | |
## - https://raw.githubusercontent.com/envoyproxy/envoy/master/configs/google_com_proxy.v2.yaml | |
admin: | |
access_log_path: /dev/stdout | |
address: | |
socket_address: | |
address: 0.0.0.0 | |
port_value: 9901 | |
static_resources: | |
listeners: | |
- name: listener_0 | |
address: | |
socket_address: | |
address: 0.0.0.0 | |
port_value: 80 | |
filter_chains: | |
- filters: | |
- name: envoy.http_connection_manager | |
config: | |
access_log: | |
- name: envoy.file_access_log | |
config: | |
path: /dev/stdout | |
stat_prefix: go-riot-envoy-http | |
route_config: | |
name: local_route | |
virtual_hosts: | |
- name: local_service | |
domains: ["*"] | |
routes: | |
- match: | |
prefix: "/" | |
route: | |
cluster: go_riot | |
http_filters: | |
- name: envoy.lua | |
config: | |
inlineCode: | | |
function envoy_on_request(request_handle) | |
local uid = request_handle:headers():get("x-user-id") | |
local ordinal = tostring(tonumber(uid) % 3) | |
request_handle:headers():replace(":authority", "backend-go-riot-" .. ordinal) | |
end | |
function envoy_on_response(response_handle) | |
body_size = response_handle:body():length() | |
response_handle:headers():add("response-body-size", tostring(body_size)) | |
end | |
- name: envoy.router | |
clusters: | |
- name: go_riot | |
connect_timeout: 2s | |
type: strict_dns | |
dns_lookup_family: AUTO | |
lb_policy: ROUND_ROBIN | |
hosts: | |
- socket_address: | |
address: backend-go-riot-0 | |
port_value: 8887 | |
- socket_address: | |
address: backend-go-riot-1 | |
port_value: 8887 | |
- socket_address: | |
address: backend-go-riot-2 | |
port_value: 8887 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a StatefuleSet running with hostnames:
backend-go-riot-0
backend-go-riot-1
backend-go-riot-2
I am able to successfully hit the pods in the stateful set with:
kubectl port-forward pod/backend-go-riot-0 8887
curl localhost:8887
-> returns a 404 as expectedHowever, the proxy does not seem to be able to understand that the pods are available and can be routed to.