use xmidt-agent instead of simulator for docker compose

This commit is contained in:
mpicci200_comcast
2024-11-04 18:12:23 -05:00
parent 69e4525dc4
commit 992ec5276e
9 changed files with 26989 additions and 0 deletions

View File

@@ -0,0 +1,175 @@
# Deploying XMiDT
## Docker/awscli
In order to deploy into Docker, make sure [Docker is installed](https://docs.docker.com/install/). Additionally for goaws, make sure that awscli is intalled.
#### Deploy
_**Note**_: While Tr1d1um is not part of XMiDT(it is WebPA), it is recommended to be
brought up for current ease of use. Future releases will deprecate Tr1d1um.
1. Clone this repository
2. Run `deploy/docker-compose-new/deploy.sh`
This will build `goaws` locally. It will then run `docker-compose up` which uses images of `talaria`, `scytale`, `petasos`, `caduceus`, `xmidt-agent` (device simulator) and `tr1d1um` from dockerhub.
To pull specific versions of the images, just set the `<SERVICE>_VERSION` env variables when running the shell script.
```
TALARIA_VERSION=x.x.x deploy/docker-compose/deploy.sh
```
If you only want to bring up, for example, the scytale and talaria, run:
```bash
deploy/docker-compose/deploy.sh scytale talaria
```
_**Note**_: Bringing up a subset of services can cause problems.
This can be done with any combination of services.
3. To bring the containers down:
```bash
docker-compose -f docker-compose.yml down
```
### INFO
The docker-compose file provides 1 full datacenter with one talaria in a "backup"
datacenter. Since this is pure docker, not swarm or kubernetes, it's easiest to
deal with just one datacenter. Since all ports are exposed, the names might seem a little weird.
#### Connection
##### Inside Docker
If the Parodus instance is inside of docker, life is easy! Just connect to the cluster with `petasos:6400`.
##### Outside Docker
if the Parodus instance is outside of docker and the ports are exposed correctly, life
will be hard since you will need to handle the redirect.
You can initially connect to 'localhost:6400' but on the redirect change `talaria-1:6210` to `localhost:6210`
or you can just connect to a talaria `localhost:6200`
Once connected you should see it connected via [metrics](http://localhost:9090/graph?g0.range_input=1h&g0.expr=xmidt_talaria_device_count&g0.tab=0)
### Interact with the machines
Checkout that petasos is working:
```
curl -i -H "X-Webpa-Device-Name: mac:112233445566" "http://localhost:6400"
```
Should give you the following:
```
HTTP/1.1 307 Temporary Redirect
Content-Type: text/html; charset=utf-8
Location: http://talaria-0:6200
X-Petasos-Build: development
X-Petasos-Flavor: development
X-Petasos-Region: local
X-Petasos-Server: localhost
X-Petasos-Start-Time: 04 Jun 19 02:12 UTC
Date: Tue, 04 Jun 2019 02:16:58 GMT
Content-Length: 57
<a href="http://talaria-0:6200">Temporary Redirect</a>.
```
Checkout that tr1d1um is able to talk with scytale & talaria:
```
curl -i -H "Authorization: Basic dXNlcjpwYXNz" "http://localhost:6100/api/v2/device/mac:112233445577/config?names=Foo"
```
Should give you:
```
HTTP/1.1 404 Not Found
X-Scytale-Build: development
X-Scytale-Flavor: development
X-Scytale-Region: local
X-Scytale-Server: localhost
X-Scytale-Start-Time: 04 Jun 19 02:12 UTC
X-Talaria-Build: development
X-Talaria-Flavor: development
X-Talaria-Region: local
X-Talaria-Server: localhost
X-Talaria-Start-Time: 04 Jun 19 02:12 UTC
X-Tr1d1um-Build: development
X-Tr1d1um-Flavor: development
X-Tr1d1um-Region: local
X-Tr1d1um-Server: localhost
X-Tr1d1um-Start-Time: 04 Jun 19 02:11 UTC
X-Webpa-Transaction-Id: LQxoB5sUSGWPNgAzxRIXLA
X-Xmidt-Message-Error: The device does not exist
X-Xmidt-Span: "http://petasos:6400/api/v2/device/send","2019-06-04T02:27:26Z","2.185274ms"
Date: Tue, 04 Jun 2019 02:27:26 GMT
Content-Length: 87
Content-Type: text/plain; charset=utf-8
{"code": 404, "message": "Could not process device request: The device does not exist"}
```
Check out that your simulator is connected:
```
curl -i -H "Authorization: Basic dXNlcjpwYXNz" "http://localhost:6100/api/v2/device/mac:112233445566/stat"
```
Should give you something similar to:
```
HTTP/1.1 200 OK
Content-Type: application/json
X-Scytale-Build: development
X-Scytale-Flavor: development
X-Scytale-Region: local
X-Scytale-Server: localhost
X-Scytale-Start-Time: 10 Jun 19 06:36 UTC
X-Talaria-Build: development
X-Talaria-Flavor: development
X-Talaria-Region: local
X-Talaria-Server: localhost
X-Talaria-Start-Time: 10 Jun 19 06:36 UTC
X-Tr1d1um-Build: development
X-Tr1d1um-Flavor: development
X-Tr1d1um-Region: local
X-Tr1d1um-Server: localhost
X-Tr1d1um-Start-Time: 10 Jun 19 06:36 UTC
X-Webpa-Transaction-Id: CIyqnI23RjWhyC_vNO7hbA
X-Xmidt-Span: "http://petasos:6400/api/v2/device/mac:112233445566/stat","2019-06-10T06:38:13Z","2.947332ms"
Date: Mon, 10 Jun 2019 06:38:13 GMT
Content-Length: 231
{"id": "mac:112233445566", "pending": 0, "statistics": {"bytesSent": 0, "messagesSent": 0, "bytesReceived": 0, "messagesReceived": 0, "duplications": 0, "connectedAt": "2019-06-10T06:37:02.915435853Z", "upTime": "1m10.110197482s"}}
```
Read a single parameter:
```
curl -i -H "Authorization: Basic dXNlcjpwYXNz" "http://localhost:6100/api/v2/device/mac:112233445566/config?names=Device.DeviceInfo.X_CISCO_COM_BootloaderVersion" -H "X-Xmidt-Partner-ID: comcast,nbc,sky"
```
Results in:
```
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
X-Scytale-Build: development
X-Scytale-Flavor: development
X-Scytale-Region: local
X-Scytale-Server: localhost
X-Scytale-Start-Time: 10 Jun 19 06:36 UTC
X-Talaria-Build: development
X-Talaria-Flavor: development
X-Talaria-Region: local
X-Talaria-Server: localhost
X-Talaria-Start-Time: 10 Jun 19 06:36 UTC
X-Tr1d1um-Build: development
X-Tr1d1um-Flavor: development
X-Tr1d1um-Region: local
X-Tr1d1um-Server: localhost
X-Tr1d1um-Start-Time: 10 Jun 19 06:36 UTC
X-Webpa-Transaction-Id: cDYIIKLgoDtrt3XrVfUKkg
X-Xmidt-Span: "http://petasos:6400/api/v2/device/send","2019-06-10T06:45:04Z","15.869854ms"
Date: Mon, 10 Jun 2019 06:45:04 GMT
Content-Length: 163
{"parameters":[{"name":"Device.DeviceInfo.X_CISCO_COM_BootloaderVersion","value":"4.2.0.45","dataType":0,"parameterCount":1,"message":"Success"}],"statusCode":200}
```

View File

@@ -0,0 +1,10 @@
echo "Stopping services & removing containers..."
CADUCEUS_VERSION=${CADUCEUS_VERSION:-latest-amd64} \
ARGUS_VERSION=${ARGUS_VERSION:-latest-amd64} \
TR1D1UM_VERSION=${TR1D1UM_VERSION:-latest-amd64} \
SCYTALE_VERSION=${SCYTALE_VERSION:-latest} \
PETASOS_VERSION=${PETASOS_VERSION:-latest} \
TALARIA_VERSION=${TALARIA_VERSION:-latest} \
THEMIS_VERSION=${THEMIS_VERSION:-latest} \
SIMULATOR_VERSION=${SIMULATOR_VERSION:-latest-amd64} \
docker compose down --remove-orphans

View File

@@ -0,0 +1,53 @@
#!/bin/bash
DIR=$( cd "$(dirname "$0")" || exit; pwd -P )
ROOT_DIR=$DIR/../../
pushd "$ROOT_DIR" || exit
echo "Building Simulator..."
if [[ "$(docker images -q xmidt/simulator:latest 2> /dev/null)" == "" ]]; then
docker build -t xmidt/simulator:latest $ROOT_DIR/simulator
fi
popd
echo "Running services..."
CONSUL_VERSION=${CONSUL_VERSION:-1.12.6} \
CADUCEUS_VERSION=${CADUCEUS_VERSION:-latest-amd64} \
ARGUS_VERSION=${ARGUS_VERSION:-latest-amd64} \
TR1D1UM_VERSION=${TR1D1UM_VERSION:-latest-amd64} \
SCYTALE_VERSION=${SCYTALE_VERSION:-latest-amd64} \
PETASOS_VERSION=${PETASOS_VERSION:-latest} \
TALARIA_VERSION=${TALARIA_VERSION:-latest} \
THEMIS_VERSION=${THEMIS_VERSION:-latest} \
SIMULATOR_VERSION=${SIMULATOR_VERSION:-latest-amd64} \
docker compose -f $ROOT_DIR/deploy/docker-compose-new/docker-compose.yml up -d $@
if [[ $? -ne 0 ]]; then
exit 1
fi
sleep 10
AWS_ACCESS_KEY_ID=accessKey AWS_SECRET_ACCESS_KEY=secretKey aws dynamodb --endpoint-url http://localhost:8000 describe-table --table-name gifnoc --region us-east-2 --output text > /dev/null 2> /dev/null
if [[ $? -ne 0 ]]; then
AWS_ACCESS_KEY_ID=accessKey AWS_SECRET_ACCESS_KEY=secretKey aws dynamodb --endpoint-url http://localhost:8000 create-table \
--table-name gifnoc \
--attribute-definitions \
AttributeName=bucket,AttributeType=S \
AttributeName=expires,AttributeType=N \
AttributeName=id,AttributeType=S \
--key-schema \
AttributeName=bucket,KeyType=HASH \
AttributeName=id,KeyType=RANGE \
--global-secondary-indexes \
"[{\"IndexName\": \"Expires-index\",\"KeySchema\":[{\"AttributeName\":\"bucket\",\"KeyType\":\"HASH\"}, {\"AttributeName\":\"expires\",\"KeyType\":\"RANGE\"}], \
\"ProvisionedThroughput\": {\"ReadCapacityUnits\": 10, \"WriteCapacityUnits\": 5 },\"Projection\":{\"ProjectionType\":\"ALL\"}}]" \
--provisioned-throughput \
ReadCapacityUnits=10,WriteCapacityUnits=5 \
--stream-specification StreamEnabled=true,StreamViewType=NEW_AND_OLD_IMAGES \
--region us-east-2 \
--output text
AWS_ACCESS_KEY_ID=accessKey AWS_SECRET_ACCESS_KEY=secretKey aws dynamodb \
--endpoint-url http://localhost:8000 --region us-east-2 update-time-to-live \
--table-name gifnoc --time-to-live-specification "Enabled=true, AttributeName=expires" \
--output text
fi

View File

@@ -0,0 +1,15 @@
{
"datacenter": "dc0",
"node_name": "ConsulServer0",
"log_level": "INFO",
"telemetry": {
"disable_hostname": true,
"statsite_address": "127.0.0.1:8700",
"prometheus_retention_time" : "1h",
"prefix_filter": [
"+consul.raft.apply",
"-consul.http",
"+consul.catalog.service"
]
}
}

View File

@@ -0,0 +1,18 @@
{
"datacenter": "dc1",
"node_name": "ConsulServer1",
"retry_join_wan":[
"consul0"
],
"log_level": "INFO",
"telemetry": {
"disable_hostname": true,
"statsite_address": "127.0.0.1:8700",
"prometheus_retention_time" : "1h",
"prefix_filter": [
"+consul.raft.apply",
"-consul.http",
"+consul.catalog.service"
]
}
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,90 @@
---
# my global config
global:
scrape_interval: 2s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 2s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
external_labels:
monitor: 'codelab-monitor'
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
# rule_files:
# - "first.rules"
# - "second.rules"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['prometheus:9090']
- job_name: 'docker'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['docker.for.mac.host.internal:9323']
- job_name: 'caduceus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['caduceus:6003']
- job_name: 'petasos'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['petasos:6403']
- job_name: 'scytale'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['scytale:6303']
- job_name: 'talaria'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['talaria-0:6204', 'talaria-1:6204', 'talaria-2:6204']
- job_name: 'tr1d1um'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['tr1d1um:6101']
- job_name: 'argus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['argus:6601']
- job_name: 'themis'
static_configs:
- targets: ['themis:6503']
- job_name: 'consul'
metrics_path: "/v1/agent/metrics"
params:
format: ["prometheus"]
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['consul0:8500','consul1:8500']

View File

@@ -0,0 +1,33 @@
# SPDX-FileCopyrightText: 2023 Comcast Cable Communications Management, LLC
# SPDX-License-Identifier: Apache-2.0
websocket:
url_path: api/v2/device
back_up_url: http://petasos:6400
xmidt_credentials:
url: http://themis:6501/issue
file_name: xmidt_agent_creds.txt
file_permissions: 0777
identity:
device_id: mac:112233445566
serial_number: 1800deadbeef
hardware_model: fooModel
hardware_manufacturer: barManufacturer
firmware_version: v0.0.1
partner_id: foobar
xmidt_service:
backoff:
max_delay: 600s
min_delay: 7s
url: http://petasos:6400
operational_state:
last_reboot_reason: sleepy
boot_time: "2024-02-28T01:04:27Z"
storage:
temporary: ~/local-rdk-testing/temporary
durable: ~/local-rdk-testing/durable
mock_tr_181:
enabled: true
file_path: /mock_tr181.json
lib_parodus:
parodus_service_url: "tcp://127.0.0.1:6666"

View File

@@ -0,0 +1,196 @@
---
networks:
xmidt: ~
services:
argus:
container_name: argus
depends_on:
- dynamodb
environment:
- "AWS_ENDPOINT=http://dynamodb:8000"
- "TRACING_PROVIDER_NAME=zipkin"
- "TRACING_PROVIDER_ENDPOINT=http://zipkin:9411/api/v2/spans"
- "ACCESS_LEVEL_CAPABILITY=x1:issuer:test:.*:all"
image: "ghcr.io/xmidt-org/argus:${ARGUS_VERSION}"
networks:
- xmidt
ports:
- "6600-6603:6600-6603"
caduceus:
container_name: caduceus
depends_on:
- argus
environment:
- "CONSUL_HOST=consul0:8500"
- "ARGUS_HOST=http://argus:6600"
image: "ghcr.io/xmidt-org/caduceus:${CADUCEUS_VERSION}"
networks:
- xmidt
ports:
- "6000-6003:6000-6003"
consul0:
command: "agent -server -bootstrap-expect 1 -ui -client 0.0.0.0 -config-file consul.json"
container_name: consul0
hostname: consul0
image: "hashicorp/consul:${CONSUL_VERSION}"
networks:
- xmidt
ports:
- "8400:8400"
- "8500:8500"
- "8600:8600/tcp"
- "8600:8600/udp"
volumes:
- "./docFiles/consul-0.json:/consul.json:z"
consul1:
command: "agent -server -bootstrap-expect 1 -ui -client 0.0.0.0 -config-file consul.json"
container_name: consul1
depends_on:
- consul0
hostname: consul1
image: "hashicorp/consul:${CONSUL_VERSION}"
networks:
- xmidt
ports:
- "8401:8400"
- "8501:8500"
- "8601:8600/tcp"
- "8601:8600/udp"
volumes:
- "./docFiles/consul-1.json:/consul.json:z"
dynamodb:
container_name: dynamo-xmidt
hostname: dynamodb
image: amazon/dynamodb-local
networks:
- xmidt
ports:
- "9000:9000"
petasos:
container_name: petasos
depends_on:
- consul0
environment:
- "CONSUL_HOST=consul0:8500"
image: "ghcr.io/xmidt-org/petasos:${PETASOS_VERSION}"
networks:
- xmidt
ports:
- "6400-6403:6400-6403"
prometheus:
command: "--log.level=debug --config.file=/prometheus-data/prometheus.yml"
container_name: prometheus-xmidt
depends_on:
- consul0
- consul1
image: prom/prometheus
networks:
- xmidt
ports:
- "9090:9090"
volumes:
- "./docFiles/prometheus.yml:/prometheus-data/prometheus.yml:z"
scytale:
container_name: scytale
depends_on:
- petasos
- argus
environment:
- "CONSUL_HOST=consul0:8500"
- "ARGUS_HOST=http://argus:6600"
- TRACING_PROVIDER_NAME=zipkin
- "TRACING_PROVIDER_ENDPOINT=http://zipkin:9411/api/v2/spans"
image: "ghcr.io/xmidt-org/scytale:${SCYTALE_VERSION}"
networks:
- xmidt
ports:
- "6300-6303:6300-6303"
simulator:
container_name: xmidt-agent
depends_on:
- talaria-0
- talaria-1
- talaria-2
- petasos
- themis
image: "ghcr.io/xmidt-org/xmidt-agent:${SIMULATOR_VERSION}"
networks:
- xmidt
volumes:
- "./docFiles/mock_tr181.json:/mock_tr181.json"
- "./docFiles/xmidt-agent.yaml:/etc/xmidt-agent/xmidt-agent.yaml"
talaria-0:
container_name: talaria
depends_on:
- consul0
- themis
environment:
- "CONSUL_HOST=consul0:8500"
- TRACING_PROVIDER_NAME=zipkin
- "TRACING_PROVIDER_ENDPOINT=http://zipkin:9411/api/v2/spans"
image: "ghcr.io/xmidt-org/talaria:${TALARIA_VERSION}"
networks:
- xmidt
ports:
- "6200-6204:6200-6204"
talaria-1:
container_name: talaria1
depends_on:
- consul0
- themis
environment:
- "CONSUL_HOST=consul0:8500"
- TRACING_PROVIDER_NAME=zipkin
- "TRACING_PROVIDER_ENDPOINT=http://zipkin:9411/api/v2/spans"
image: "ghcr.io/xmidt-org/talaria:${TALARIA_VERSION}"
networks:
- xmidt
ports:
- "6210-6214:6200-6204"
talaria-2:
container_name: talaria2
depends_on:
- consul0
- themis
environment:
- "CONSUL_HOST=consul1:8500"
- TRACING_PROVIDER_NAME=zipkin
- "TRACING_PROVIDER_ENDPOINT=http://zipkin:9411/api/v2/spans"
image: "ghcr.io/xmidt-org/talaria:${TALARIA_VERSION}"
networks:
- xmidt
ports:
- "6220-6224:6200-6204"
themis:
container_name: themis
environment:
- "CONSUL_HOST=consul0:8500"
- TRACING_PROVIDER_NAME=zipkin
- "TRACING_PROVIDER_ENDPOINT=http://zipkin:9411/api/v2/spans"
image: "ghcr.io/xmidt-org/themis:${THEMIS_VERSION}"
networks:
- xmidt
ports:
- "6500-6504:6500-6504"
tr1d1um:
container_name: tr1d1um
depends_on:
- argus
- scytale
environment:
- "CONSUL_HOST=consul0:8500"
- "ARGUS_HOST=http://argus:6600"
- TRACING_PROVIDER_NAME=zipkin
- "TRACING_PROVIDER_ENDPOINT=http://zipkin:9411/api/v2/spans"
image: "ghcr.io/xmidt-org/tr1d1um:${TR1D1UM_VERSION}"
networks:
- xmidt
ports:
- "6100-6103:6100-6103"
zipkin:
image: openzipkin/zipkin
networks:
- xmidt
ports:
- "9411:9411"
version: "3.8"