Created
August 18, 2020 21:54
-
-
Save leosunmo/1a2f61e41515c8f9dc597e362030546a to your computer and use it in GitHub Desktop.
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
version: "3.8" | |
services: | |
front-envoy: | |
build: | |
context: . | |
dockerfile: envoy.Dockerfile | |
args: | |
ENVOY_NAME: front-envoy | |
volumes: | |
- ./front-envoy.yaml:/etc/front-envoy.yaml | |
networks: | |
envoynet: | |
aliases: | |
- front-envoy | |
expose: | |
- "80" | |
ports: | |
- "8080:80" | |
shadow-envoy: | |
build: | |
context: . | |
dockerfile: envoy.Dockerfile | |
args: | |
ENVOY_NAME: shadow-envoy | |
volumes: | |
- ./shadow-envoy.yaml:/etc/shadow-envoy.yaml | |
networks: | |
envoynet: | |
aliases: | |
- shadow-envoy | |
expose: | |
- "80" | |
ports: | |
- "8081:80" | |
staging-envoy: | |
build: | |
context: . | |
dockerfile: envoy.Dockerfile | |
args: | |
ENVOY_NAME: staging-envoy | |
volumes: | |
- ./staging-envoy.yaml:/etc/staging-envoy.yaml | |
networks: | |
envoynet: | |
aliases: | |
- staging-envoy | |
expose: | |
- "80" | |
ports: | |
- "8082:80" | |
echo-v1: | |
build: | |
context: ./echo-service | |
dockerfile: echo.Dockerfile | |
environment: | |
- VERSION=1 | |
networks: | |
envoynet: | |
aliases: | |
- echo-v1 | |
expose: | |
- "7000" | |
ports: | |
- "7001:7000" | |
echo-v2: | |
build: | |
context: ./echo-service | |
dockerfile: echo.Dockerfile | |
environment: | |
- VERSION=2 | |
networks: | |
envoynet: | |
aliases: | |
- echo-v2 | |
expose: | |
- "7000" | |
ports: | |
- "7002:7000" | |
echo-v3: | |
build: | |
context: ./echo-service | |
dockerfile: echo.Dockerfile | |
environment: | |
- VERSION=3 | |
networks: | |
envoynet: | |
aliases: | |
- echo-v3 | |
expose: | |
- "7000" | |
ports: | |
- "7003:7000" | |
networks: | |
envoynet: {} |
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
FROM golang:1.15.0 AS build | |
ADD . /src | |
RUN cd /src && CGO_ENABLED=0 \ | |
GOOS=linux \ | |
GOARCH=amd64 \ | |
go build -o echo | |
FROM alpine:3.11 | |
WORKDIR /app | |
COPY --from=build /src/echo /app/ | |
ENTRYPOINT /app/echo |
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
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
"net/http/httputil" | |
"os" | |
) | |
var hostname string | |
var version string | |
func main() { | |
var err error | |
hostname, err = os.Hostname() | |
version = os.Getenv("VERSION") | |
http.HandleFunc("/", echoHandler) | |
log.Println("Listening on :7000") | |
err = http.ListenAndServe(":7000", nil) | |
if err != nil { | |
log.Fatalf("Failed to listen and serve on port 7000, %s", err.Error()) | |
} | |
} | |
func echoHandler(w http.ResponseWriter, r *http.Request) { | |
requestDump, err := httputil.DumpRequest(r, true) | |
if err != nil { | |
fmt.Println(err) | |
} | |
fmt.Println(string(requestDump)) | |
_, err = w.Write([]byte(fmt.Sprintf("[%s] Version: v%s\n%s\n", hostname, version, requestDump))) | |
if err != nil { | |
log.Printf("Failed to write response, %s", err.Error()) | |
} | |
} |
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
FROM envoyproxy/envoy:v1.14.4 | |
RUN apt update && apt install -y curl | |
ARG ENVOY_NAME | |
ENV ENVOY_NAME ${ENVOY_NAME} | |
CMD /usr/local/bin/envoy -c /etc/${ENVOY_NAME}.yaml -l debug --service-cluster ${ENVOY_NAME} |
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
static_resources: | |
listeners: | |
- address: | |
socket_address: | |
address: 0.0.0.0 | |
port_value: 80 | |
filter_chains: | |
- filters: | |
- name: envoy.http_connection_manager | |
typed_config: | |
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager | |
codec_type: auto | |
stat_prefix: ingress_http | |
route_config: | |
name: local_route | |
virtual_hosts: | |
- name: echo-services | |
domains: | |
- "echo.org.com" | |
routes: | |
- match: | |
prefix: "/v1/echo" | |
route: | |
cluster: echoV1 | |
request_mirror_policies: | |
cluster: shadow-envoy | |
runtime_fraction: { default_value: { numerator: 100 } } | |
request_headers_to_add: | |
- header: | |
key: "X-SHADOW-HOST" | |
value: "echo.stg.org.com" | |
append: false | |
- match: | |
prefix: "/v2/echo" | |
route: | |
cluster: echoV2 | |
http_filters: | |
- name: envoy.router | |
typed_config: {} | |
access_log: | |
- name: envoy.access_loggers.file | |
typed_config: | |
"@type": type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog | |
path: "/dev/stdout" | |
clusters: | |
- name: echoV1 | |
connect_timeout: 0.25s | |
type: strict_dns | |
lb_policy: round_robin | |
load_assignment: | |
cluster_name: echoV1 | |
endpoints: | |
- lb_endpoints: | |
- endpoint: | |
address: | |
socket_address: | |
address: echo-v1 | |
port_value: 7000 | |
- name: echoV2 | |
connect_timeout: 0.25s | |
type: strict_dns | |
lb_policy: round_robin | |
load_assignment: | |
cluster_name: echoV2 | |
endpoints: | |
- lb_endpoints: | |
- endpoint: | |
address: | |
socket_address: | |
address: echo-v2 | |
port_value: 7000 | |
- name: shadow-envoy | |
connect_timeout: 0.25s | |
type: strict_dns | |
lb_policy: round_robin | |
http2_protocol_options: {} | |
load_assignment: | |
cluster_name: shadow-envoy | |
endpoints: | |
- lb_endpoints: | |
- endpoint: | |
address: | |
socket_address: | |
address: shadow-envoy | |
port_value: 80 | |
admin: | |
access_log_path: "/dev/null" | |
address: | |
socket_address: | |
address: 0.0.0.0 | |
port_value: 8001 |
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
static_resources: | |
listeners: | |
- address: | |
socket_address: | |
address: 0.0.0.0 | |
port_value: 80 | |
filter_chains: | |
- filters: | |
- name: envoy.http_connection_manager | |
typed_config: | |
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager | |
codec_type: auto | |
stat_prefix: ingress_http | |
route_config: | |
name: local_route | |
virtual_hosts: | |
- name: forward-staging | |
domains: | |
- "*" | |
routes: | |
- match: | |
prefix: "/" | |
route: | |
cluster: staging-envoy | |
host_rewrite_header: X-SHADOW-HOST | |
response_headers_to_remove: | |
- X-SHADOW-HOST | |
http_filters: | |
- name: envoy.router | |
typed_config: {} | |
access_log: | |
- name: envoy.access_loggers.file | |
typed_config: | |
"@type": type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog | |
path: "/dev/stdout" | |
clusters: | |
- name: staging-envoy | |
connect_timeout: 0.25s | |
type: strict_dns | |
lb_policy: round_robin | |
http2_protocol_options: {} | |
load_assignment: | |
cluster_name: staging-envoy | |
endpoints: | |
- lb_endpoints: | |
- endpoint: | |
address: | |
socket_address: | |
address: staging-envoy | |
port_value: 80 | |
admin: | |
access_log_path: "/dev/null" | |
address: | |
socket_address: | |
address: 0.0.0.0 | |
port_value: 8001 |
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
static_resources: | |
listeners: | |
- address: | |
socket_address: | |
address: 0.0.0.0 | |
port_value: 80 | |
filter_chains: | |
- filters: | |
- name: envoy.http_connection_manager | |
typed_config: | |
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager | |
codec_type: auto | |
stat_prefix: ingress_http | |
route_config: | |
name: local_route | |
virtual_hosts: | |
- name: echo-services | |
domains: | |
- "echo.stg.org.com" | |
routes: | |
- match: | |
prefix: "/" | |
route: | |
cluster: testing-echoV3 | |
http_filters: | |
- name: envoy.router | |
typed_config: {} | |
access_log: | |
- name: envoy.access_loggers.file | |
typed_config: | |
"@type": type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog | |
path: "/dev/stdout" | |
clusters: | |
- name: testing-echoV3 | |
connect_timeout: 0.25s | |
type: strict_dns | |
lb_policy: round_robin | |
load_assignment: | |
cluster_name: testing-echoV3 | |
endpoints: | |
- lb_endpoints: | |
- endpoint: | |
address: | |
socket_address: | |
address: echo-v3 | |
port_value: 7000 | |
admin: | |
access_log_path: "/dev/null" | |
address: | |
socket_address: | |
address: 0.0.0.0 | |
port_value: 8001 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment