diff --git a/.github/workflows/ghcr-cleanup.yml b/.github/workflows/ghcr-cleanup.yml new file mode 100644 index 0000000..c880af1 --- /dev/null +++ b/.github/workflows/ghcr-cleanup.yml @@ -0,0 +1,33 @@ +name: ghcr-cleanup + +on: + schedule: + - cron: "0 0 * * *" # every day at 00:00 + workflow_dispatch: + +permissions: + packages: write + +jobs: + helmfile: + uses: openads-project/openads-helm/.github/workflows/reusable-helmfile-cleanup.yml@main + + gui: + name: Cleanup gui + runs-on: ubuntu-latest + steps: + - name: Cleanup ${{ github.event.repository.name }}/gui + uses: dataaxiom/ghcr-cleanup-action@v1.2.2 + with: + packages: ${{ github.event.repository.name }}/gui + dry-run: false + use-regex: true + skip-regex-checks: true + older-than: 1 month + exclude-tags: '^(v[0-9]+\.[0-9]+\.[0-9]+|latest)$' # v1.2.3, latest + delete-tags: ".*" + delete-untagged: true + delete-ghost-images: true + delete-partial-images: true + delete-orphaned-images: true + validate: true diff --git a/.github/workflows/gui-image.yml b/.github/workflows/gui-image.yml index 7c39342..45e6b40 100644 --- a/.github/workflows/gui-image.yml +++ b/.github/workflows/gui-image.yml @@ -52,7 +52,6 @@ jobs: type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} type=ref,event=branch,enable=${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} type=ref,event=tag - type=sha - name: Build and push image uses: docker/build-push-action@v6 diff --git a/.github/workflows/helmfile-oci.yml b/.github/workflows/helmfile-oci.yml new file mode 100644 index 0000000..a14d397 --- /dev/null +++ b/.github/workflows/helmfile-oci.yml @@ -0,0 +1,28 @@ +name: helmfile-oci + +on: + push: + branches: + - main + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + pull_request: + branches: + - main + workflow_dispatch: + +permissions: + contents: read + packages: write + +jobs: + helmfile-oci: + uses: openads-project/openads-helm/.github/workflows/reusable-helmfile-oci.yml@main + with: + compose-file: docker-compose.yml + include-env-file-in-bundle: true + chart-map: deployment/chart-map.yaml + profiles: carla,traffic,automated-testing,no-perception,planning + output-dir: deployment/generated + helmfile-entrypoint: deployment/helmfile.yaml + bundle-dir: deployment diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..0706f8c --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,17 @@ +stages: + - build + - testing + +include: + - remote: https://raw.githubusercontent.com/openads-project/openads-helm/main/.gitlab-ci/reusable-helmfile-oci.yml + inputs: + compose-file: docker-compose.yml + include-env-file-in-bundle: true + chart-map: deployment/chart-map.yaml + profiles: carla,traffic,automated-testing,no-perception,planning + output-dir: deployment/generated + helmfile-entrypoint: deployment/helmfile.yaml + bundle-dir: deployment + - component: gitlab.ika.rwth-aachen.de/fb-fi/ops/openadscale/openadscale@main + inputs: + scenario-search-pattern: scenario.generator/**/*.xosc diff --git a/carla-simulation/carla_client/set_environment.py b/carla-simulation/carla_client/set_environment.py index 2b6d4ba..50ad61f 100644 --- a/carla-simulation/carla_client/set_environment.py +++ b/carla-simulation/carla_client/set_environment.py @@ -5,6 +5,7 @@ import argparse import logging import math +import os import signal import time @@ -46,8 +47,14 @@ def stop(_signum, _frame): def parse_args(): parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="carla-server", help="CARLA server host") - parser.add_argument("-p", "--port", default=2000, type=int, help="CARLA server port") + parser.add_argument( + "--host", default=os.environ.get("CARLA_HOST", "carla-server"), + help="CARLA server host", + ) + parser.add_argument( + "-p", "--port", default=os.environ.get("CARLA_PORT", "2000"), + type=int, help="CARLA server port", + ) parser.add_argument("--tm-port", default=8000, type=int, help="Traffic Manager port") parser.add_argument( "-n", diff --git a/carla-simulation/carla_scenario_runner/.docker-compose.oci-overrides.yml b/carla-simulation/carla_scenario_runner/.docker-compose.oci-overrides.yml index fb1ea3a..c395755 100644 --- a/carla-simulation/carla_scenario_runner/.docker-compose.oci-overrides.yml +++ b/carla-simulation/carla_scenario_runner/.docker-compose.oci-overrides.yml @@ -16,8 +16,6 @@ services: file: ../../openadstack/openadstack/utils/compose/docker-compose.template.yml service: ros2-x11-service environment: - CARLA_HOST: ${CARLA_HOST:-carla-server} - CARLA_PORT: ${CARLA_PORT:-2000} MAP: ${MAP:-} CUSTOM_OPENDRIVE: ${CUSTOM_OPENDRIVE:-} CUSTOM_LANELET: ${CUSTOM_LANELET:-} @@ -44,6 +42,9 @@ services: SCENARIOS_DIR="$$(dirname "/$${CUSTOM_OPENDRIVE#/}")" fi exec ros2 launch carla_ros_scenario_runner carla_ros_scenario_runner_with_selection.launch.py \ + use_sim_time:=$${USE_SIM_TIME} \ + host:=$${CARLA_HOST} \ + port:=$${CARLA_PORT} \ scenario_runner_path:=$${SCENARIO_RUNNER_PATH} \ scenarios_dir:=$${SCENARIOS_DIR} diff --git a/carla-simulation/carla_scenario_runner/docker-compose.yml b/carla-simulation/carla_scenario_runner/docker-compose.yml index 2096d37..a74d4e9 100644 --- a/carla-simulation/carla_scenario_runner/docker-compose.yml +++ b/carla-simulation/carla_scenario_runner/docker-compose.yml @@ -18,10 +18,8 @@ services: image: ghcr.io/openads-project/carla-scenario-runner/ros:v0.10.0-1.1.2 environment: USE_SIM_TIME: ${USE_SIM_TIME:-true} - # CARLA_HOST: carla-server - CARLA_HOST: ${CARLA_HOST:-carla-server} - # CARLA_PORT: 2000 - CARLA_PORT: ${CARLA_PORT:-2000} + CARLA_HOST: carla-server + CARLA_PORT: 2000 ROLE_NAME: ego_vehicle SCENARIO_RUNNER_PATH: /docker-ros/additional-files WAIT_FOR_EGO: true @@ -64,6 +62,9 @@ services: SCENARIOS_DIR="$$(dirname "/$${CUSTOM_OPENDRIVE#/}")" fi exec ros2 launch carla_ros_scenario_runner carla_ros_scenario_runner_with_selection.launch.py \ + use_sim_time:=$${USE_SIM_TIME} \ + host:=$${CARLA_HOST} \ + port:=$${CARLA_PORT} \ scenario_runner_path:=$${SCENARIO_RUNNER_PATH} \ scenarios_dir:=$${SCENARIOS_DIR} diff --git a/deployment/README.md b/deployment/README.md new file mode 100644 index 0000000..9be3d91 --- /dev/null +++ b/deployment/README.md @@ -0,0 +1,55 @@ +# Helmfile deployment + +This directory contains the OpenADSim-specific inputs and manual additions for the [openads-helm generator](https://github.com/openads-project/openads-helm/tree/main/utils/generate_helmfile_from_compose), which converts `docker-compose.yml` into a Helmfile setup. + +## Layout + +- `helmfile.yaml` is the entrypoint. It loads the add-ons and the generated services. +- `chart-map.yaml` contains chart references and conversion rules that cannot be derived from Compose. +- `addons/` contains manually maintained releases: a NetworkPolicy that isolates the middleware bridge per stack, deployed with the `carla` profile. +- `generated/` is the generator output. It is ignored by Git and must not be committed. + +## CI + +The [GitHub workflow](../.github/workflows/helmfile-oci.yml) and the [GitLab pipeline](../.gitlab-ci.yml) use the reusable templates from `openads-helm`. They generate `deployment/generated`, validate it with `helmfile`, and publish the `deployment` directory together with the root `.env` as OCI bundle `//helmfile`, tagged with the branch or tag name. Pull requests publish under their source branch name. + +The scheduled [cleanup workflow](../.github/workflows/ghcr-cleanup.yml) deletes bundles older than one month except `main` and `vX.Y.Z`. On GitLab, the container registry cleanup policy of the project applies the same rule. + +## Local usage + +Generate the Helmfile with a sibling checkout of `openads-helm`: + +```sh +# openadsim$ +git clone https://github.com/openads-project/openads-helm ../openads-helm +python3 ../openads-helm/utils/generate_helmfile_from_compose/scripts/generate_helmfile_from_compose.py \ + docker-compose.yml \ + --env-file .env \ + --chart-map deployment/chart-map.yaml \ + --output-dir deployment/generated +``` + +Load the runtime environment, then validate and deploy. `COMPOSE_PROFILES` selects the services as in Compose. `PROJECT_PATH` must be the absolute checkout path on the Kubernetes node, as it is used for `hostPath` volumes. + +```sh +set -a; . ./.env; set +a +export PROJECT_PATH="$(pwd)" + +helmfile --file deployment/helmfile.yaml template --concurrency 1 +helmfile --file deployment/helmfile.yaml apply +``` + +## Optional settings + +To run all services on one node of a multi-node cluster, e.g. the node with the checkout at `PROJECT_PATH`, export its hostname as `NODE`: + +```sh +kubectl get nodes -L kubernetes.io/hostname +export NODE=worker-1 +``` + +`DEPLOYMENT_PREFIX` separates several stacks in one namespace. References to other services of the stack are prefixed automatically, e.g. `CARLA_HOST: carla-server` becomes `sim1-carla-server`: + +```sh +export DEPLOYMENT_PREFIX=sim1 +``` diff --git a/deployment/addons/charts/ros-middleware-bridge-network-policy/Chart.yaml b/deployment/addons/charts/ros-middleware-bridge-network-policy/Chart.yaml new file mode 100644 index 0000000..c06dd69 --- /dev/null +++ b/deployment/addons/charts/ros-middleware-bridge-network-policy/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v2 +name: ros-middleware-bridge-network-policy +description: NetworkPolicy to isolate ros-middleware-bridges in concurrent deployments +type: application +version: 0.1.0 diff --git a/deployment/addons/charts/ros-middleware-bridge-network-policy/templates/networkpolicy.yaml b/deployment/addons/charts/ros-middleware-bridge-network-policy/templates/networkpolicy.yaml new file mode 100644 index 0000000..557cf87 --- /dev/null +++ b/deployment/addons/charts/ros-middleware-bridge-network-policy/templates/networkpolicy.yaml @@ -0,0 +1,43 @@ +{{- $prefix := .Values.namePrefix | default "" -}} +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: {{ .Release.Name }} +spec: + podSelector: + matchLabels: + app.kubernetes.io/name: {{ printf "%s-%s" $prefix .Values.middlewareBridgeName | trimPrefix "-" | quote }} + policyTypes: + - Ingress + - Egress + ingress: + - from: + - podSelector: + matchLabels: + app.kubernetes.io/name: {{ printf "%s-%s" $prefix .Values.carlaServerName | trimPrefix "-" | quote }} + egress: + - to: + - podSelector: + matchLabels: + app.kubernetes.io/name: {{ printf "%s-%s" $prefix .Values.carlaServerName | trimPrefix "-" | quote }} + - to: + - podSelector: + matchLabels: + app.kubernetes.io/name: {{ printf "%s-%s" $prefix .Values.zenohRouterName | trimPrefix "-" | quote }} + ports: + - protocol: TCP + port: {{ .Values.zenohPort }} + - protocol: UDP + port: {{ .Values.zenohPort }} + - to: + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: kube-system + podSelector: + matchLabels: + k8s-app: kube-dns + ports: + - protocol: UDP + port: 53 + - protocol: TCP + port: 53 diff --git a/deployment/addons/charts/ros-middleware-bridge-network-policy/values.yaml b/deployment/addons/charts/ros-middleware-bridge-network-policy/values.yaml new file mode 100644 index 0000000..a7fef94 --- /dev/null +++ b/deployment/addons/charts/ros-middleware-bridge-network-policy/values.yaml @@ -0,0 +1,5 @@ +namePrefix: "" +middlewareBridgeName: ros-middleware-bridge +carlaServerName: carla-server +zenohRouterName: zenoh-router +zenohPort: 7447 diff --git a/deployment/addons/helmfile.yaml b/deployment/addons/helmfile.yaml new file mode 100644 index 0000000..6b5ec1a --- /dev/null +++ b/deployment/addons/helmfile.yaml @@ -0,0 +1,12 @@ +environments: + default: + values: + - ../generated/environments/services.yaml.gotmpl +--- +releases: + # NetworkPolicy to isolate ros-middleware-bridges in concurrent deployments + - name: '{{ printf "%s-middleware-bridge-policy" (env "DEPLOYMENT_PREFIX") | trimPrefix "-" }}' + chart: charts/ros-middleware-bridge-network-policy + condition: serviceEnabled.ros-middleware-bridge.enabled + values: + - values.yaml.gotmpl diff --git a/deployment/addons/values.yaml.gotmpl b/deployment/addons/values.yaml.gotmpl new file mode 100644 index 0000000..81d376f --- /dev/null +++ b/deployment/addons/values.yaml.gotmpl @@ -0,0 +1 @@ +namePrefix: {{ env "DEPLOYMENT_PREFIX" | quote }} diff --git a/deployment/chart-map.yaml b/deployment/chart-map.yaml new file mode 100644 index 0000000..a84f753 --- /dev/null +++ b/deployment/chart-map.yaml @@ -0,0 +1,43 @@ +excluded_profiles: + - donotuse + - gui + - sumo +services: + # charts centrally maintained in https://github.com/openads-project/openads-helm/tree/main/charts + zenoh-router: + chart: oci://ghcr.io/openads-project/openads-helm/zenoh-router + version: 0.2.10 + triton-server: + chart: oci://ghcr.io/openads-project/openads-helm/triton-server + version: "26.05" + # nested charts in https://github.com/openads-project/carla-simulator/tree/main/deployment/helm + carla-server: + chart: oci://ghcr.io/openads-project/carla-simulator/helm/carla-server + version: 0.10.0-1.1.1 + carla-client: + chart: oci://ghcr.io/openads-project/carla-simulator/helm/carla-client + version: 0.10.0-1.1.1 + # nested charts in https://github.com/openads-project/carla-ros-bridge/tree/main/deployment/helm + carla-ackermann-control: + chart: oci://ghcr.io/openads-project/carla-ros-bridge/helm/carla-ackermann-control + version: 0.10.0-1.2.0-carla-ackermann-control + carla-manual-control: + chart: oci://ghcr.io/openads-project/carla-ros-bridge/helm/carla-manual-control + version: 0.10.0-1.2.0-carla-manual-control + carla-ros-bridge: + chart: oci://ghcr.io/openads-project/carla-ros-bridge/helm/carla-ros-bridge + version: 0.10.0-1.2.0-carla-ros-bridge + carla-spawn-objects: + chart: oci://ghcr.io/openads-project/carla-ros-bridge/helm/carla-spawn-objects + version: 0.10.0-1.2.0-carla-spawn-objects + # nested chart in https://github.com/openads-project/carla-scenario-runner/tree/main/deployment/helm + carla-scenario-runner-ros-automated-testing: &scenario-runner + chart: oci://ghcr.io/openads-project/carla-scenario-runner/helm/carla-scenario-runner-ros + version: 0.10.0-1.1.2 + volume_policies: + /scenarios: bind + carla-scenario-runner-ros-manual-testing: *scenario-runner + # chart derived from image, writable volume mounted from host + monitoring.rviz-carla: + volume_policies: + /docker-ros/ws/monitoring-volume: bind diff --git a/deployment/generated/.gitignore b/deployment/generated/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/deployment/generated/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/deployment/helmfile.yaml b/deployment/helmfile.yaml new file mode 100644 index 0000000..51f32da --- /dev/null +++ b/deployment/helmfile.yaml @@ -0,0 +1,3 @@ +helmfiles: + - path: addons/helmfile.yaml + - path: generated/helmfile.yaml # auto-generated by openads-helm diff --git a/openadstack/perception/point_cloud_object_detection/docker-compose.yml b/openadstack/perception/point_cloud_object_detection/docker-compose.yml index e3087ad..73b84e8 100644 --- a/openadstack/perception/point_cloud_object_detection/docker-compose.yml +++ b/openadstack/perception/point_cloud_object_detection/docker-compose.yml @@ -6,10 +6,11 @@ services: service: perception.point-cloud-object-detection profiles: - perception - depends_on: + depends_on: - triton-server environment: PARAMS: /params.yml + TRITON_SERVER_URL: triton-server:8001 volumes: - ./params.yml:/params.yml - type: image