Skip to content

Commit

Permalink
Ankaios initial contribution with running scenario (#11)
Browse files Browse the repository at this point in the history
* Enable initial startup without freyja

* Add graceful shutdown message

* Add new image paths for in-vehicle stack

* Remove cloud connector for first contribution

* Fix targetarch and cleanup docs

* Use ghcr chariott image in startupState

* Add architectural overview image

* Integrate release Ankaios v0.3.0

* Update to new container images

* Rename mount point for smart_trailer app

* Add additional dependency for freyja

* Adding correct dependencies

* Upgrade to ankaios v0.3.1 and update readme

---------

Co-authored-by: Lauren Datz <[email protected]>
  • Loading branch information
inf17101 and ladatz authored Jun 27, 2024
1 parent 80f9a2e commit 36fb06c
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 167 deletions.
6 changes: 3 additions & 3 deletions eclipse-ankaios/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/eclipse-ankaios/app-ankaios-dev:0.2.0
FROM ghcr.io/eclipse-ankaios/app-ankaios-dev:0.3.1
ARG TARGETARCH

RUN apt-get update && apt-get -y install \
Expand All @@ -10,11 +10,11 @@ RUN apt-get update && apt-get -y install \
# && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y \
# Cleanup
&& rm -rf /var/lib/apt/lists/* \
&& curl -sL https://github.com/mikefarah/yq/releases/latest/download/yq_linux_${TARGETARCH} -o /usr/bin/yq \
&& curl -sL https://github.com/mikefarah/yq/releases/download/v4.42.1/yq_linux_${TARGETARCH} -o /usr/bin/yq \
&& chmod +x /usr/bin/yq

# Trust all repositories in this container
RUN git config --global --add safe.directory '*' \
&& echo "if [ -f /etc/bash_completion ] && ! shopt -oq posix; then\n . /etc/bash_completion \nfi" >> /root/.bashrc \
&& echo 'export PATH=$PATH:/workspaces/app/scripts:/workspaces/app/in-vehicle-stack/scenarios/smart_trailer_use_case/scripts' >> /root/.bashrc
&& echo 'export PATH=$PATH:/workspaces/software-orchestration/scripts' >> /root/.bashrc

11 changes: 7 additions & 4 deletions eclipse-ankaios/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
{
"name": "Ankaios Software Orchestration Blueprint dev container",
"build": {
"dockerfile": "Dockerfile"
"dockerfile": "Dockerfile",
//"args": {
// "TARGETARCH": "" // comment out and set your targetarch if no buildx is available
//}
},
"mounts": [
"source=${localWorkspaceFolder}/../scenarios/smart_trailer/scripts,target=/workspaces/blueprint/smart_trailer/scripts,type=bind"
"source=${localWorkspaceFolder}/../scenarios/smart_trailer/scripts/start_trailer_applications_ankaios.sh,target=/usr/local/bin/start_trailer_applications.sh,type=bind"
],
"runArgs": [
"--privileged"
Expand All @@ -28,6 +31,6 @@
]
}
},
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/blueprint/,type=bind",
"workspaceFolder": "/workspaces/blueprint/"
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/software-orchestration/,type=bind",
"workspaceFolder": "/workspaces/software-orchestration/"
}
141 changes: 70 additions & 71 deletions eclipse-ankaios/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@
**Architectural Overview**


![Smart trailer blueprint](../docs/diagrams/ankaios.png)
![Smart trailer blueprint](doc/ankaios.png)

The container is designed to have an immediately running environment. Once triggered, all workloads are initially started and sample data is exchanged between them.

## Links

- [Ankaios docs](https://eclipse-ankaios.github.io/ankaios/0.2/)
- [Ankaios quickstart](https://eclipse-ankaios.github.io/ankaios/0.2/usage/quickstart/)
- [Ankaios docs](https://eclipse-ankaios.github.io/ankaios/0.3/)
- [Ankaios quickstart](https://eclipse-ankaios.github.io/ankaios/0.3/usage/quickstart/)
- [Podman](https://docs.podman.io/en/v4.6.1/)
- [What are devcontainers?](https://containers.dev/)

## Prerequisites

- Docker [Installation instructions](https://docs.docker.com/get-docker/)

## Development environment
## Devcontainer environment

The following is provided inside the devcontainer:

- Ankaios executables (`ank-server`, `ank-agent` and `ank`)

- Podman 4.6.2

- Pre-configured Ankaios startup config [startupState.yaml](./config/startupState.yaml)
- Pre-configured Ankaios manifest [startupState.yaml](./config/startupState.yaml)

- Automation scripts for starting and stopping all workloads of the challenge:
- Automation scripts for starting and stopping all workloads of the scenario:
- run_blueprint.sh
- shutdown_blueprint.sh

Expand All @@ -41,19 +41,9 @@ The following is provided inside the devcontainer:

All services are running in the host network meaning those can be accessed by `localhost:<port>`. We recommend that you set the network mode to host for all your developed workloads as well.

## Ankaios Control Interface dependencies
### Run devcontainer with VSCode

The devcontainer includes also dependencies for developing applications using the [Ankaios Control Interface](https://eclipse-ankaios.github.io/ankaios/0.2/reference/control-interface/):

- protobuf compiler
- grpcurl
- Ankaios protobuf file (under `/usr/local/lib/ankaios/ankaios.proto`)

Those dependencies are needed for use-cases in which your app needs to use the [Ankaios Control Interface](https://eclipse-ankaios.github.io/ankaios/0.2/reference/control-interface/) to be able to communicate with the Ankaios cluster via the API. An example use-case would be to write a workload that shall request Ankaios to dynamically start another workload. You can find example workload applications written in various programming languages inside the Eclipse Ankaios repository [here](https://github.com/eclipse-ankaios/ankaios/tree/v0.2.0/examples).

## Run devcontainer with VSCode

### Prerequisites
#### Prerequisites
- [Remote Development](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) extension installed in VSCode

Open the subfolder containing this README file in VSCode:
Expand All @@ -62,92 +52,82 @@ Open the subfolder containing this README file in VSCode:
code .
```

__Note:__ If you have not installed and enabled [docker buildx](https://github.com/docker/buildx) you need to specify the `TARGETARCH` manually by providing it as build argument inside the `.devcontainer/devcontainer.json`, e.g.: --build-arg TARGETARCH=amd64.

VSCode detects automatically that a `.devcontainer` folder exists inside this subfolder.
Please confirm the dialog to reopen VSCode inside the devcontainer.
Afterwards, open a new terminal inside the devcontainer in VSCode.

## Run devcontainer without VSCode
### Run devcontainer without VSCode

Navigate to the subfolder containing this README file and run the following command to build the devcontainer image:

```shell
docker build -t custom-ankaios-dev:0.1 --target dev -f .devcontainer/Dockerfile .
docker build -t ankaios-orchestration:0.1 -f .devcontainer/Dockerfile .
```

Todo! Fix mountpoints, when new folder structure of Microsoft is available..
__Note:__ If you have not installed and enabled [docker buildx](https://github.com/docker/buildx) you need to specify the `TARGETARCH` manually by providing it as build argument, e.g.: --build-arg TARGETARCH=amd64.

Start the devcontainer with the required mount points:
Start the devcontainer with the required mount points by replacing the file paths in the run command below with the full absolute file paths on your local machine:

```shell
docker run -it --privileged --name custom_ankaios_dev -v <absolute/path/to>/blueprint/eclipse-ankaios:/workspaces/app -v <absolute/path/to>/blueprint/in-vehicle-stack:/workspaces/app/in-vehicle-stack -p 25551:25551 --workdir /workspaces/app custom-ankaios-dev:0.1 /bin/bash
docker run -it --privileged -p 25551:25551 --name ankaios_orchestration --workdir /workspaces/software-orchestration -v /<absolute-path-to>/software-orchestration/eclipse-ankaios:/workspaces/software-orchestration -v /<absolute-path-to>/software-orchestration/scenarios/smart_trailer/scripts/start_trailer_applications_ankaios.sh:/usr/local/bin/start_trailer_applications.sh ankaios-orchestration:0.1
```

## Startup check before development
## Run the smart trailer scenario

Before starting active development we recommend you start once Ankaios with the current startup config [startupState.yaml](./config/startupState.yaml) and sample applications.
Start the smart trailer scenario by executing the following steps:

1. Log in into the Microsoft container registry
```shell
podman login sdvblueprint.azurecr.io
```

2. Start Ankaios with all workloads inside the startup config:
1. Start Ankaios with all workloads inside the [startupState.yaml](./config/startupState.yaml):
```shell
run_blueprint.sh
```

3. Next, use the Ankaios CLI to verify that all initial workloads are up and running:
2. Next, open a new terminal window and use the Ankaios CLI to verify that all initial workloads are up and running:

```shell
ank get workloads
```

4. Verify that all initial workloads inside the startup config have execution state "Running".
3. Verify that all initial workloads inside the manifest have execution state "Running".

The output looks similar to the following:
```shell
WORKLOAD NAME AGENT RUNTIME EXECUTION STATE
digital_twin_cloud_sync agent_A podman Running
digital_twin_vehicle agent_A podman Running
dynamic_topic_management agent_A podman Running
mqtt_broker agent_A podman Running
service_discovery agent_A podman Running
WORKLOAD NAME AGENT RUNTIME EXECUTION STATE ADDITIONAL INFO
digital_twin_cloud_sync agent_A podman Running(Ok)
digital_twin_vehicle agent_A podman Running(Ok)
dynamic_topic_management agent_A podman Running(Ok)
mqtt_broker agent_A podman Running(Ok)
service_discovery agent_A podman Running(Ok)
```

5. Only for the **Smart Trailer scenario**, do the following extra steps:
- Inside the devcontainer, run the script `start_trailer_applications_ankaios.sh`:
```shell
start_trailer_applications_ankaios.sh
```
- In another terminal window inside the devcontainer, add the following workload by using the Ankaios CLI to simulate the Smart Trailer connected signal:
```shell
ank run workload trailer_connected_provider --runtime podman --config $'image: sdvblueprint.azurecr.io/sdvblueprint/in-vehicle-stack/trailer_connected_provider:0.1.0\ncommandOptions: ["--network", "host", "--name", "trailer_connected_provider"]' --agent agent_A
```
- Verify the output of the terminal window of the `start_trailer_applications_ankaios.sh` script. The output should look like the following:
```shell
Trailer is connected! Starting workloads to manage it
Called Ankaios to start the Trailer Properties Digital Twin Provider and Smart Trailer Application
Check Ankaios status with 'ank get workloads'
```
- Check the execution states of the newly added workloads by using the Ankaios CLI.
```shell
ank get workloads
```
- Run `podman logs -f smart_trailer_application` to check the sample data output of the Smart Trailer App. Feel free to check the logs of the other workloads too.

6. Stop Ankaios and clean up all workloads by running:

4. Run the script `start_trailer_applications.sh` inside `/usr/local/bin/` by typing:
```shell
shutdown_blueprint.sh
start_trailer_applications.sh
```

## Customizing Devcontainer
5. Use the `ank get workloads` command again to verify that the new smart trailer applications are running:
- `trailer_properties_provider`, providing the smart trailer's dummy weight property
- `smart_trailer_application`, the smart trailer application reading the smart trailer's dummy weight property

You can customize the devcontainer depending on your preferred programming language, tools and frameworks.
6. Verify the logs of the smart trailer app and the smart trailer provider using the trailer's weight property:

To customize the devcontainer add your specific dev dependencies to `.devcontainer/Dockerfile` (starting from line 7).
Logs of the `trailer_properties_provider`:
```shell
podman logs -f trailer_properties_provider
```

Rebuild the container image.
Logs of the `smart_trailer_application`:
```shell
podman logs -f smart_trailer_application
```

7. Verify the logs of the `local-cloud-sync` workload emitting the trailer weight to the cloud (currently to the mock cloud adapter):
```shell
podman logs -f local-cloud-sync
```

8. Stop Ankaios and clean up all workloads by pressing `Ctrl+C` inside the terminal window of `run_blueprint.sh`.

## Workload development

Expand All @@ -156,10 +136,9 @@ After customizing the devcontainer, start the development of your workload apps.
- Write your code
- Write a [Dockerfile](https://docs.docker.com/engine/reference/builder/) for each workload
- Build a container image for each workload with [podman build](https://docs.podman.io/en/v4.6.1/markdown/podman-build.1.html)
- For the Smart Trailer scenario, replace the image URIs within the script [start_trailer_applications_ankaios.sh](../in-vehicle-stack/scenarios/smart_trailer_use_case/scripts/start_trailer_applications_ankaios.sh)
- If required, extend the Ankaios startup config [startupState.yaml](./config/startupState.yaml) by adding config parts for your workloads
- If required, extend the Ankaios manifest [startupState.yaml](./config/startupState.yaml) by adding config parts for your workloads

Start and stop all workloads according to the section [Startup check before development](#startup-check-before-development).
Start and stop all workloads according with using the `run_blueprint.sh` script similiar to the section [Run the smart trailer scenario](#run-the-smart-trailer-scenario).
Use the Ankaios ClI to check the workload states. For more details display the help of Ankaios CLI by running:
```shell
ank --help
Expand All @@ -172,7 +151,27 @@ podman ps -a
podman logs -f <container_name|container_id>
```

## Ankaios logs
### Customizing Devcontainer

You can customize the devcontainer depending on your preferred programming language, tools and frameworks.

To customize the devcontainer add your specific dev dependencies to `.devcontainer/Dockerfile` (starting from line 7).

Rebuild the container image.

### Ankaios Control Interface dependencies

The devcontainer includes also dependencies for developing applications using the [Ankaios Control Interface](https://eclipse-ankaios.github.io/ankaios/0.3/reference/control-interface/):

- protobuf compiler
- grpcurl
- Ankaios protobuf file (under `/usr/local/lib/ankaios/ankaios.proto`)

Those dependencies are needed for use-cases in which your app needs to use the [Ankaios Control Interface](https://eclipse-ankaios.github.io/ankaios/0.3/reference/control-interface/) to be able to communicate with the Ankaios cluster via the API. An example use-case would be to write a workload that shall request Ankaios to dynamically start another workload. You can find example workload applications written in various programming languages inside the Eclipse Ankaios repository [here](https://github.com/eclipse-ankaios/ankaios/tree/v0.3.1/examples).

## Debugging

### Ankaios logs

There are log files for debugging purposes of Ankaios server and agent.

Expand Down
14 changes: 0 additions & 14 deletions eclipse-ankaios/config/default.yaml

This file was deleted.

40 changes: 24 additions & 16 deletions eclipse-ankaios/config/startupState.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
apiVersion: v0.1
workloads:
service_discovery:
runtime: podman
Expand All @@ -6,52 +7,59 @@ workloads:
- key: project
value: chariott
runtimeConfig: |
image: sdvblueprint.azurecr.io/sdvblueprint/eclipse-chariott/service-discovery:0.1.1
image: ghcr.io/eclipse-sdv-blueprints/software-orchestration/eclipse-chariott/service-discovery:0.2.1
commandOptions: ["--network", "host", "--name", "service_discovery"]
mqtt_broker:
runtime: podman
agent: agent_A
dependencies:
service_discovery:
ADD_COND_RUNNING
tags:
- key: project
value: agemo
runtimeConfig: |
image: sdvblueprint.azurecr.io/sdvblueprint/eclipse-mosquitto/mqtt-broker:latest
image: ghcr.io/eclipse-sdv-blueprints/software-orchestration/eclipse-mosquitto/mqtt-broker-agemo-config:0.1.2
commandOptions: ["--network", "host", "--name", "mqtt-broker"]
dynamic_topic_management:
runtime: podman
agent: agent_A
dependencies:
service_discovery:
ADD_COND_RUNNING
mqtt_broker:
ADD_COND_RUNNING
tags:
- key: project
value: agemo
runtimeConfig: |
image: sdvblueprint.azurecr.io/sdvblueprint/eclipse-agemo/pub-sub-service:0.1.0
image: ghcr.io/eclipse-sdv-blueprints/software-orchestration/eclipse-agemo/pub-sub-service:0.1.2
commandOptions: ["--network", "host", "--name", "pub-sub-service"]
digital_twin_vehicle:
runtime: podman
agent: agent_A
dependencies:
service_discovery:
ADD_COND_RUNNING
dynamic_topic_management:
ADD_COND_RUNNING
tags:
- key: project
value: ibeji
runtimeConfig: |
image: sdvblueprint.azurecr.io/sdvblueprint/eclipse-ibeji/invehicle-digital-twin:0.1.0
image: ghcr.io/eclipse-sdv-blueprints/software-orchestration/eclipse-ibeji/invehicle-digital-twin:0.1.1
commandOptions: ["--network", "host", "--name", "invehicle-digital-twin"]
digital_twin_cloud_sync:
runtime: podman
agent: agent_A
dependencies:
service_discovery:
ADD_COND_RUNNING
digital_twin_vehicle:
ADD_COND_RUNNING
tags:
- key: project
value: freyja
runtimeConfig: |
image: sdvblueprint.azurecr.io/sdvblueprint/eclipse-freyja/local-with-ibeji:0.1.0
image: ghcr.io/eclipse-sdv-blueprints/software-orchestration/eclipse-freyja/local-with-ibeji:0.1.0
commandOptions: ["--network", "host", "--name", "local-cloud-sync"]
cloud_connector:
runtime: podman
agent: agent_A
restart: true
updateStrategy: AT_MOST_ONCE
accessRights:
allow: []
deny: []
runtimeConfig: |
image: sdvblueprint.azurecr.io/sdvblueprint/eclipse-freyja/azure-cloud-connector:0.1.0
commandOptions: ["--network", "host", "--name", "cloud-connector", "--mount", "type=bind,src=/etc/freyja/config,dst=/mnt/config,ro=true"]
Binary file added eclipse-ankaios/doc/ankaios.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 36fb06c

Please sign in to comment.