Skip to content

Commit

Permalink
Merge pull request #13 from datawire/ark3/sidecar-envoy-config
Browse files Browse the repository at this point in the history
Minimize ADS-pushed changes during intercept

All the static stuff is in the bootstrap config except for the listener, which needs to be dynamic for ADS consistency. The sidecar now just updates the route configuration.
  • Loading branch information
Abhay Saxena authored Jan 9, 2019
2 parents f99335a + db710f2 commit 28bf9d9
Show file tree
Hide file tree
Showing 22 changed files with 247 additions and 484 deletions.
6 changes: 3 additions & 3 deletions intercept/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ RUN apk update && apk add git
WORKDIR /go/src/app
COPY cmd ./cmd
RUN go get -d -v ./...
RUN wget -q https://s3.amazonaws.com/datawire-static-files/ambex/0.1.0/ambex
RUN chmod 755 ambex
RUN CGO_ENABLED=0 GOOS=linux go build cmd/proxy/proxy.go
RUN CGO_ENABLED=0 GOOS=linux go build cmd/sidecar/sidecar.go

Expand All @@ -22,7 +24,5 @@ CMD ["/app/run.sh"]
FROM envoyproxy/envoy:28d5f4118d60f828b1453cd8ad25033f2c8e38ab as telepresence-sidecar
WORKDIR /application
COPY sidecar_image /application/
RUN wget -q https://s3.amazonaws.com/datawire-static-files/ambex/0.1.0/ambex
RUN chmod 755 ambex
COPY --from=builder /go/src/app/sidecar /application/
COPY --from=builder /go/src/app/sidecar /go/src/app/ambex /application/
CMD ["/application/entrypoint.sh"]
49 changes: 12 additions & 37 deletions intercept/cmd/sidecar/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,12 @@ func processIntercepts(intercepts []InterceptInfo) {
log.Print(string(routesJSON))
log.Print("---")

contents := fmt.Sprintf(listenerTemplate, string(routesJSON))
err = ioutil.WriteFile("temp/listener.json", []byte(contents), 0644)
contents := fmt.Sprintf(routeTemplate, string(routesJSON))
err = ioutil.WriteFile("temp/route.json", []byte(contents), 0644)
if err != nil {
panic(err)
}
err = os.Rename("temp/listener.json", "data/listener.json")
err = os.Rename("temp/route.json", "data/route.json")
}

func main() {
Expand Down Expand Up @@ -270,42 +270,17 @@ func main() {

}

const listenerTemplate = `
const routeTemplate = `
{
"@type": "/envoy.api.v2.Listener",
"name": "test-listener",
"address": {
"socket_address": {
"address": "0.0.0.0",
"port_value": 9900
}
},
"filter_chains": [
"@type": "/envoy.api.v2.RouteConfiguration",
"name": "application_route",
"virtual_hosts": [
{
"filters": [
{
"name": "envoy.http_connection_manager",
"config": {
"stat_prefix": "sidecar",
"http_filters": [
{
"name": "envoy.router"
}
],
"route_config": {
"virtual_hosts": [
{
"name": "all-the-hosts",
"domains": [
"*"
],
"routes": %s
}
]
}
}
}
]
"name": "all-the-hosts",
"domains": [
"*"
],
"routes": %s
}
]
}
Expand Down
192 changes: 192 additions & 0 deletions intercept/sidecar_image/bootstrap-ads.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,195 @@ static_resources:
address: 127.0.0.1
port_value: 18000
http2_protocol_options: {}
- name: tel-proxy-9000
connect_timeout: 10s
type: STRICT_DNS
load_assignment:
cluster_name: tel-proxy-9000
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: telepresence-proxy
port_value: 9000
- name: tel-proxy-9001
connect_timeout: 10s
type: STRICT_DNS
load_assignment:
cluster_name: tel-proxy-9001
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: telepresence-proxy
port_value: 9001
- name: tel-proxy-9002
connect_timeout: 10s
type: STRICT_DNS
load_assignment:
cluster_name: tel-proxy-9002
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: telepresence-proxy
port_value: 9002
- name: tel-proxy-9003
connect_timeout: 10s
type: STRICT_DNS
load_assignment:
cluster_name: tel-proxy-9003
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: telepresence-proxy
port_value: 9003
- name: tel-proxy-9004
connect_timeout: 10s
type: STRICT_DNS
load_assignment:
cluster_name: tel-proxy-9004
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: telepresence-proxy
port_value: 9004
- name: tel-proxy-9005
connect_timeout: 10s
type: STRICT_DNS
load_assignment:
cluster_name: tel-proxy-9005
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: telepresence-proxy
port_value: 9005
- name: tel-proxy-9006
connect_timeout: 10s
type: STRICT_DNS
load_assignment:
cluster_name: tel-proxy-9006
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: telepresence-proxy
port_value: 9006
- name: tel-proxy-9007
connect_timeout: 10s
type: STRICT_DNS
load_assignment:
cluster_name: tel-proxy-9007
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: telepresence-proxy
port_value: 9007
- name: tel-proxy-9008
connect_timeout: 10s
type: STRICT_DNS
load_assignment:
cluster_name: tel-proxy-9008
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: telepresence-proxy
port_value: 9008
- name: tel-proxy-9009
connect_timeout: 10s
type: STRICT_DNS
load_assignment:
cluster_name: tel-proxy-9009
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: telepresence-proxy
port_value: 9009
- name: tel-proxy-9010
connect_timeout: 10s
type: STRICT_DNS
load_assignment:
cluster_name: tel-proxy-9010
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: telepresence-proxy
port_value: 9010
- name: tel-proxy-9011
connect_timeout: 10s
type: STRICT_DNS
load_assignment:
cluster_name: tel-proxy-9011
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: telepresence-proxy
port_value: 9011
- name: tel-proxy-9012
connect_timeout: 10s
type: STRICT_DNS
load_assignment:
cluster_name: tel-proxy-9012
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: telepresence-proxy
port_value: 9012
- name: tel-proxy-9013
connect_timeout: 10s
type: STRICT_DNS
load_assignment:
cluster_name: tel-proxy-9013
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: telepresence-proxy
port_value: 9013
- name: tel-proxy-9014
connect_timeout: 10s
type: STRICT_DNS
load_assignment:
cluster_name: tel-proxy-9014
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: telepresence-proxy
port_value: 9014
- name: tel-proxy-9015
connect_timeout: 10s
type: STRICT_DNS
load_assignment:
cluster_name: tel-proxy-9015
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: telepresence-proxy
port_value: 9015
25 changes: 0 additions & 25 deletions intercept/sidecar_image/data/cluster-proxy-9000.json

This file was deleted.

25 changes: 0 additions & 25 deletions intercept/sidecar_image/data/cluster-proxy-9001.json

This file was deleted.

25 changes: 0 additions & 25 deletions intercept/sidecar_image/data/cluster-proxy-9002.json

This file was deleted.

25 changes: 0 additions & 25 deletions intercept/sidecar_image/data/cluster-proxy-9003.json

This file was deleted.

Loading

0 comments on commit 28bf9d9

Please sign in to comment.