Skip to content
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

feat: ES-44 add Ansible Model of otel-shop #4

Merged
merged 1 commit into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ansible/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### ANSIBLE
To execute the ansible files from run in this directory (ansible):
```shell
sudo ansible-playbook -i hosts.yaml main.yaml
```
4 changes: 4 additions & 0 deletions ansible/hosts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
all:
hosts:
localhost:
ansible_connection: local
142 changes: 142 additions & 0 deletions ansible/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
---
- name: Deploy OpenTelemetry Demo
hosts: all
become: true
vars:
demo_version: "1.10.0"
network_name: "opentelemetry-demo"
state: "started"
restart_policy: "unless-stopped"
log_driver: "json-file"
log_options_max_size: "5m"
log_options_max_file: "2"
flagd_host: "flagd"
flagd_port: "8013"
otel_collector_host: "otelcol"
otel_collector_port_grpc: "4317"
otel_collector_port_http: "4318"
envoy_port: "8080"
pre_tasks:
#- name: Ensure Docker is installed
# apt:
# name: docker.io
# state: present
# become: true

- name: Ensure default network is created
docker_network:
name: opentelemetry-demo
driver: bridge

roles:
- role: accountingservice
become: true
- role: adservice
become: true
- role: cartservice
become: true
- role: checkoutservice
become: true
- role: currencyservice
become: true
- role: emailservice
become: true
- role: frauddetectionservice
become: true
- role: flagd
become: true
- role: frontend
become: true
- role: frontendproxy
become: true
- role: grafana
become: true
- role: imageprovider
become: true
- role: jaeger
become: true
- role: kafka
become: true
- role: loadgenerator
become: true
- role: mongo
become: true
- role: opensearch
become: true
- role: otelcol
become: true
- role: paymentservice
become: true
- role: productcatalogservice
become: true
- role: prometheus
become: true
- role: quoteservice
become: true
- role: recommendationservice
become: true
- role: shippingservice
become: true
- role: valkeycart
become: true

post_tasks:
- name: Ensure services are started
community.general.launchd:
name: "{{ item }}"
state: "{{ state }}"
loop:
- accountingservice
- adservice
- cartservice
- checkoutservice
- emailservice
- flagd
- frauddetectionserice
- frontend
- frontendproxy
- grafana
- imageprovider
- jaeger
- kafka
- loadgenerator
- mongo
- opensearch
- otelcol
- paymentservice
- productcatalogservice
- prometheus
- quoteservice
- recommendationservice
- shippingservice
- valkeycart

- name: Ensure services are enabled to start at boot
community.general.launchd:
name: "{{ item }}"
enabled: yes
loop:
- accountingservice
- adservice
- cartservice
- checkoutservice
- emailservice
- flagd
- frauddetectionserice
- frontend
- frontendproxy
- grafana
- imageprovider
- jaeger
- kafka
- loadgenerator
- mongo
- opensearch
- otelcol
- paymentservice
- productcatalogservice
- prometheus
- quoteservice
- recommendationservice
- shippingservice
- valkeycart
5 changes: 5 additions & 0 deletions ansible/roles/accountingservice/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
service_name: "accountingservice"
image_name: "ghcr.io/open-telemetry/demo:1.10.0-accountingservice"
otlp_metrics_temporality_preference : "cumulative"
memory_limit: "50M"
kafkaservice_addr: "kafka:9092"
4 changes: 4 additions & 0 deletions ansible/roles/accountingservice/meta/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
dependencies:
- role: kafka
- role: otelcol
27 changes: 27 additions & 0 deletions ansible/roles/accountingservice/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
- name: Pull the latest Docker image
docker_image:
name: "{{ image_name }}:{{ demo_version }}-{{ service_name }}"
source: pull

- name: Deploy Service
docker_container:
name: "{{ service_name }}"
image: "{{ image_name }}"
env:
OTEL_EXPORTER_OTLP_ENDPOINT: "http://{{ otel_collector_host }}:{{ otel_collector_port_http }}"
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: "{{ otlp_metrics_temporality_preference }}"
OTEL_RESOURCE_ATTRIBUTES: "service.name={{ service_name }},service.namespace=opentelemetry-demo,service.version={{ demo_version }}"
OTEL_SERVICE_NAME: "{{ service_name }}"
KAFKA_SERVICE_ADDR: "{{ kafkaservice_addr }}"
restart_policy: "{{ restart_policy }}"
memory: "{{ memory_limit }}"
state: "{{ state }}"
network_mode: "{{ network_name }}"
networks:
- name: "{{ network_name }}"
log_driver: "{{ log_driver }}"
log_options:
max-size: "{{ log_options_max_size }}"
max-file: "{{ log_options_max_file }}"
tag: "{{ service_name }}"
6 changes: 6 additions & 0 deletions ansible/roles/adservice/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
service_name: "adservice"
image_name: "ghcr.io/open-telemetry/demo:1.10.0-adservice"
ports: "9555"
otlp_metrics_temporality_preference : "cumulative"
memory_limit: "300M"
logs_exporter: "otlp"
4 changes: 4 additions & 0 deletions ansible/roles/adservice/meta/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
dependencies:
- role: otelcol
- role: flagd
31 changes: 31 additions & 0 deletions ansible/roles/adservice/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
- name: Pull the latest Docker image
docker_image:
name: "{{ image_name }}:{{ demo_version }}-{{ service_name }}"
source: pull

- name: Deploy Service
docker_container:
name: "{{ service_name }}"
image: "{{ image_name }}"
env:
OTEL_EXPORTER_OTLP_ENDPOINT: "http://{{ otel_collector_host }}:{{ otel_collector_port_http }}"
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: "{{ otlp_metrics_temporality_preference }}"
OTEL_RESOURCE_ATTRIBUTES: "service.name={{ service_name }},service.namespace=opentelemetry-demo,service.version={{ demo_version }}"
OTEL_SERVICE_NAME: "{{ service_name }}"
OTEL_LOGS_EXPORTER: "{{ logs_exporter }}"
AD_SERVICE_PORT: "{{ ports }}"
FLAGD_HOST: "{{ flagd_host }}"
FLAGD_PORT: "{{ flagd_port }}"
restart_policy: "{{ restart_policy }}"
memory: "{{ memory_limit }}"
state: "{{ state }}"
ports: "{{ ports }}"
network_mode: "{{ network_name }}"
networks:
- name: "{{ network_name }}"
log_driver: "{{ log_driver }}"
log_options:
max-size: "{{ log_options_max_size }}"
max-file: "{{ log_options_max_file }}"
tag: "{{ service_name }}"
6 changes: 6 additions & 0 deletions ansible/roles/cartservice/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
service_name: "cartservice"
image_name: "ghcr.io/open-telemetry/demo:1.10.0-cartservice"
ports: "7070"
memory_limit: "160M"
valkey_addr: "valkeycart:6379"
aspnetcore_urls: "http://*:7070"
5 changes: 5 additions & 0 deletions ansible/roles/cartservice/meta/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
dependencies:
- role: otelcol
- role: flagd
- role: valkeycart
32 changes: 32 additions & 0 deletions ansible/roles/cartservice/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
- name: Pull the latest Docker image
docker_image:
name: "{{ image_name }}:{{ demo_version }}-{{ service_name }}"
source: pull

- name: Deploy Service
docker_container:
name: "{{ service_name }}"
image: "{{ image_name }}"
env:
OTEL_EXPORTER_OTLP_ENDPOINT: "http://{{ otel_collector_host }}:{{ otel_collector_port_grpc }}"
OTEL_RESOURCE_ATTRIBUTES: "service.name={{ service_name }},service.namespace=opentelemetry-demo,service.version={{ demo_version }}"
OTEL_SERVICE_NAME: "{{ service_name }}"
CART_SERVICE_PORT: "{{ ports }}"
VALKEY_ADDR: "{{ valkey_addr }}"
REDIS_ADDR: "{{ valkey_addr }}"
ASPNETCORE_URLS: "{{ aspnetcore_urls }}"
FLAGD_HOST: "{{ flagd_host }}"
FLAGD_PORT: "{{ flagd_port }}"
restart_policy: "{{ restart_policy }}"
memory: "{{ memory_limit }}"
state: "{{ state }}"
ports: "{{ ports }}"
network_mode: "{{ network_name }}"
networks:
- name: "{{ network_name }}"
log_driver: "{{ log_driver }}"
log_options:
max-size: "{{ log_options_max_size }}"
max-file: "{{ log_options_max_file }}"
tag: "{{ service_name }}"
13 changes: 13 additions & 0 deletions ansible/roles/checkoutservice/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
service_name: "checkoutservice"
image_name: "ghcr.io/open-telemetry/demo:1.10.0-checkoutservice"
ports: "5050"
otlp_metrics_temporality_preference : "cumulative"
memory_limit: "20M"
logs_exporter: "otlp"
cartservice_addr: "cartservice:7070"
currencyservice_addr: "currencyservice:7001"
emailservice_addr: "http://emailservice:6060"
paymentservice_addr: "paymentservice:50051"
productcatalogservice_addr: "productcatalogservice:3550"
shippingservice_addr: "shippingservice:50050"
kafkaservice_addr: "kafka:9092"
11 changes: 11 additions & 0 deletions ansible/roles/checkoutservice/meta/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
dependencies:
- role: cartservice
- role: currencyservice
- role: emailservice
- role: paymentservice
- role: productcatalogservice
- role: shippingservice
- role: otelcol
- role: kafka
- role: flagd
39 changes: 39 additions & 0 deletions ansible/roles/checkoutservice/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
- name: Pull the latest Docker image
docker_image:
name: "{{ image_name }}:{{ demo_version }}-{{ service_name }}"
source: pull

- name: Deploy Service
docker_container:
name: "{{ service_name }}"
image: "{{ image_name }}"
env:
OTEL_EXPORTER_OTLP_ENDPOINT: "http://{{ otel_collector_host }}:{{ otel_collector_port_grpc }}"
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: "{{ otlp_metrics_temporality_preference }}"
OTEL_RESOURCE_ATTRIBUTES: "service.name={{ service_name }},service.namespace=opentelemetry-demo,service.version={{ demo_version }}"
OTEL_SERVICE_NAME: "{{ service_name }}"
OTEL_LOGS_EXPORTER: "{{ logs_exporter }}"
CHECKOUT_SERVICE_PORT: "{{ ports }}"
FLAGD_HOST: "{{ flagd_host }}"
FLAGD_PORT: "{{ flagd_port }}"
CART_SERVICE_ADDR: "{{ cartservice_addr }}"
CURRENCY_SERVICE_ADDR: "{{ currencyservice_addr }}"
EMAIL_SERVICE_ADDR: "{{ emailservice_addr }}"
PAYMENT_SERVICE_ADDR: "{{ paymentservice_addr }}"
PRODUCT_CATALOG_SERVICE_ADDR: "{{ productcatalogservice_addr }}"
SHIPPING_SERVICE_ADDR: "{{ shippingservice_addr }}"
KAFKA_SERVICE_ADDR: "{{ kafkaservice_addr }}"

restart_policy: "{{ restart_policy }}"
memory: "{{ memory_limit }}"
state: "{{ state }}"
ports: "{{ ports }}"
network_mode: "{{ network_name }}"
networks:
- name: "{{ network_name }}"
log_driver: "{{ log_driver }}"
log_options:
max-size: "{{ log_options_max_size }}"
max-file: "{{ log_options_max_file }}"
tag: "{{ service_name }}"
7 changes: 7 additions & 0 deletions ansible/roles/currencyservice/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
service_name: "currencyservice"
image_name: "ghcr.io/open-telemetry/demo:1.10.0-currencyservice"
ports: "7001"
otlp_metrics_temporality_preference : "cumulative"
memory_limit: "20M"

logs_exporter: "otlp"
3 changes: 3 additions & 0 deletions ansible/roles/currencyservice/meta/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
dependencies:
- role: otelcol
Loading
Loading