forked from signalfx/tracing-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Get host ip from EC2 service * ECommerce App Mesh demo * Add lead-in for App Mesh * Add App Mesh to main list * Add link to App Mesh product page and example * Add refreshdb resources
- Loading branch information
Showing
30 changed files
with
2,627 additions
and
16 deletions.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
|
||
export POD_HOST_IP=${POD_HOST_IP:-$(curl http://169.254.169.254/latest/meta-data/local-ipv4)} | ||
|
||
python -m ${APP}.${APP} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# E-Commerce on AWS App Mesh | ||
|
||
App Mesh is a new service mesh offering from AWS. They provide a managed control | ||
plane so that users are only required to deploy a simple data plane with Envoy. | ||
A brief introduction to the core ideas can be read in their [documentation](https://docs.aws.amazon.com/app-mesh/latest/userguide/what-is-app-mesh.html). | ||
|
||
The deployment scaffolding of this example has been adopted, in large part, from | ||
the [AWS App Mesh Examples](https://github.com/aws/aws-app-mesh-examples). | ||
|
||
Build the application images used for this example by following the instructions at [../app-src](../app-src). | ||
|
||
## Setup | ||
|
||
Set the following environment variables to configure the infrastructure deployment: | ||
|
||
``` | ||
AWS_PROFILE | ||
AWS_REGION | ||
AWS_DEFAULT_REGION | ||
ENVIRONMENT_NAME | ||
MESH_NAME | ||
KEY_PAIR_NAME | ||
ENVOY_IMAGE | ||
CLUSTER_SIZE | ||
SERVICES_DOMAIN | ||
DOCKER_REPO | ||
``` | ||
|
||
Deploy the example VPC and ECS cluster, and App Mesh: | ||
|
||
```bash | ||
infra/vpc.sh | ||
infra/ecs-cluster.sh | ||
infra/appmesh-mesh.sh | ||
``` | ||
|
||
Set an environment variable, `SIGNALFX_ENDPOINT_URL` for the trace endpoint. If sending directly to a Gateway, it would look similar to this: | ||
|
||
```bash | ||
export SIGNALFX_ENDPOINT_URL=http://gateway.servicesdomain:8080 | ||
``` | ||
|
||
If sending to an Agent running on the task host instead, substitute the hostname | ||
with the literal, `POD_HOST_IP`. | ||
|
||
```bash | ||
export SIGNALFX_ENDPOINT_URL=http://POD_HOST_IP:9080 | ||
``` | ||
|
||
This will make Envoy and the apps send traces to the host at port `9080`. | ||
|
||
Deploy the App Mesh virtual nodes, routers, routes, and services with the provided | ||
Cloudformation template. This template has an included virtual node and virtual | ||
service to handle egress to the SignalFx Gateway, if sending directly to that. | ||
Set two environment variables, `GATEWAY_URL` and `GATEWAY_PORT`, `GatewayVirtualService` | ||
and `GatewayVirtualNode` to match the actual Gateway deployment. | ||
|
||
```bash | ||
export GATEWAY_URL=gateway.${SERVICES_DOMAIN} | ||
export GATEWAY_PORT=8080 | ||
./ecommerce-mesh-resources.sh | ||
``` | ||
|
||
Build the config image and push it to the docker repository. The startup script | ||
will read the value of `SIGNALFX_ENDPOINT_URL` and populate the Envoy | ||
configuration accordingly. | ||
|
||
```bash | ||
cd config-image | ||
./build.sh | ||
``` | ||
|
||
## Running the example | ||
|
||
Deploy and start the app using the adapted deployment script: | ||
|
||
```bash | ||
./ecs/ecommerce-app.sh | ||
``` | ||
|
||
By default, all routing is done through `catalog-v1`. To modify this and enable | ||
`catalog-v2`, edit the `CatalogRoute` in `ecommerce-mesh-resources.yaml` and | ||
uncommment the second weighted target. Various weights can be assigned to each | ||
node. | ||
|
||
Apply the modified route with `ecommerce-mesh-resources.sh`. |
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,18 @@ | ||
FROM alpine | ||
|
||
ARG ENDPOINT_URL | ||
ENV ENDPOINT=$ENDPOINT_URL | ||
|
||
RUN apk add --update \ | ||
curl \ | ||
&& rm -rf /var/cache/apk/* | ||
|
||
ADD tracing_envoy.yaml /envoy_config/tracing.yaml | ||
ADD startup.sh /startup.sh | ||
|
||
RUN chmod +x /startup.sh | ||
|
||
VOLUME /envoy_config | ||
|
||
CMD /startup.sh $ENDPOINT | ||
# ENTRYPOINT [ "/bin/sh", "-c", "sed", "-i", "'s/@@HOST_IP@@/$(curl http://169.254.169.254/latest/meta-data/local-ipv4)/g'", "/tmp/envoy.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,5 @@ | ||
#!/bin/bash | ||
|
||
docker build ./ -t ecommerce-envoy-config:latest --build-arg ENDPOINT_URL=${SIGNALFX_ENDPOINT_URL} | ||
docker tag ecommerce-envoy-config:latest ${DOCKER_REPO}:config | ||
docker push ${DOCKER_REPO}: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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/sh | ||
|
||
set -ex | ||
|
||
export HOST_IP=$(curl http://169.254.169.254/latest/meta-data/local-ipv4) | ||
|
||
echo $HOST_IP | ||
echo $1 | ||
|
||
endpoint_url=$(echo $1 | sed ' s/\/\///g; s/POD_HOST_IP/'"${HOST_IP}"'/g' | awk '{split($0,a,":"); print a[2]}') | ||
endpoint_port=$(echo $1 | awk '{split($0,a,":"); print a[3]}') | ||
|
||
sed -i 's/SIGNALFX_ENDPOINT_URL/'"${endpoint_url}"'/g; s/SIGNALFX_ENDPOINT_PORT/'"${endpoint_port}"'/g' /envoy_config/tracing.yaml | ||
|
||
cat /envoy_config/tracing.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,17 @@ | ||
static_resources: | ||
clusters: | ||
- name: zipkin | ||
connect_timeout: 2s | ||
type: LOGICAL_DNS | ||
lb_policy: ROUND_ROBIN | ||
hosts: | ||
- socket_address: | ||
address: SIGNALFX_ENDPOINT_URL | ||
port_value: SIGNALFX_ENDPOINT_PORT | ||
|
||
tracing: | ||
http: | ||
name: envoy.zipkin | ||
config: | ||
collector_cluster: zipkin | ||
collector_endpoint: "/v1/trace" |
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,17 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" | ||
|
||
aws --profile "${AWS_PROFILE}" --region "${AWS_DEFAULT_REGION}" \ | ||
cloudformation deploy \ | ||
--stack-name "${ENVIRONMENT_NAME}-mesh-resources" \ | ||
--capabilities CAPABILITY_IAM \ | ||
--template-file "${DIR}/ecommerce-mesh-resources.yaml" \ | ||
--parameter-overrides \ | ||
EnvironmentName="${ENVIRONMENT_NAME}" \ | ||
ServicesDomain="${SERVICES_DOMAIN}" \ | ||
AppMeshName="${MESH_NAME}" \ | ||
GatewayURL="${GATEWAY_URL}" \ | ||
GatewayPort="${GATEWAY_PORT}" \ |
Oops, something went wrong.