This project provides a Traffic Control Management System built using Java, Quarkus, and Kubernetes. It includes APIs for managing traffic lights, retrieving their statuses, and simulating real-world traffic light systems.
This part provides step-by-step instructions for setting up a clean Kind cluster, configuring Keycloak, deploying Quarkus microservices, and testing endpoints.
Before starting, ensure you have the following installed:
- Java (version 11 or higher)
- Maven (version 3.6.3 or higher)
- Docker (latest stable version)
- Kind (Kubernetes in Docker)
- Kubectl (command-line tool for Kubernetes)
- Helm
-
Clone the repository:
git clone <repository-url> cd SoSecAutSys
-
Delete any existing Kind cluster:
kind delete cluster -n ivssas-sandbox
-
Navigate to the Kind setup directory and start the cluster:
cd kind ./start-cluster -
Wait for the script to complete successfully. If the script fails, restart it without deleting the cluster to create only the uncreated instances.
-
Verify the Keycloak pods are in a running state:
kubectl get pods -A
- Login to Keycloak under "localhost" in your browser (default credentials:
Username: admin,Password: changeme). - Click on the top-left dropdown menu and select "Create Realm."
- Browse for the
./keycloak/quarkus.jsonfile and import it to create the realm.
-
Build and deploy the Quarkus microservices:
./mvnw clean package -Dquarkus.kubernetes.deploy=true
-
Alternatively, deploy while skipping tests:
./mvnw clean package -DskipTests -Dquarkus.kubernetes.deploy=true
-
Ensure all microservice pods are running:
kubectl get pods -A
Output should be looking like this:
NAMESPACE NAME READY STATUS RESTARTS AGE
cert-manager cert-manager-77c5f7bf75-z4pxs 1/1 Running 0 23m
cert-manager cert-manager-cainjector-669d85f6cf-fnb6j 1/1 Running 0 23m
cert-manager cert-manager-webhook-585b8b6bfc-g48jb 1/1 Running 0 23m
cert-manager trust-manager-64945d7598-fqhjv 1/1 Running 0 22m
ingress-nginx ingress-nginx-controller-58f597f7dd-79c56 1/1 Running 0 20m
keycloak keycloak-0 1/1 Running 0 20m
keycloak keycloak-postgresql-0 1/1 Running 0 20m
kube-system coredns-7c65d6cfc9-4zgvs 1/1 Running 0 23m
kube-system coredns-7c65d6cfc9-qq587 1/1 Running 0 23m
kube-system etcd-ivssas-sandbox-control-plane 1/1 Running 0 23m
kube-system kindnet-l45tz 1/1 Running 0 23m
kube-system kube-apiserver-ivssas-sandbox-control-plane 1/1 Running 0 23m
kube-system kube-controller-manager-ivssas-sandbox-control-plane 1/1 Running 0 23m
kube-system kube-proxy-wlzdx 1/1 Running 0 23m
kube-system kube-scheduler-ivssas-sandbox-control-plane 1/1 Running 0 23m
kyverno-system kyverno-admission-controller-757bb5cfd-xb9tf 1/1 Running 0 22m
kyverno-system kyverno-background-controller-84dc569d49-5c7z9 1/1 Running 0 22m
kyverno-system kyverno-cleanup-admission-reports-28958910-q9qcf 0/1 Completed 0 9m51s
kyverno-system kyverno-cleanup-cluster-admission-reports-28958910-s8znb 0/1 Completed 0 9m51s
kyverno-system kyverno-cleanup-controller-5f8d965c6b-92h4x 1/1 Running 0 22m
kyverno-system kyverno-reports-controller-546d4bd5-qlqjf 1/1 Running 0 22m
local-path-storage local-path-provisioner-57c5987fd4-7jkrb 1/1 Running 0 23m
traffic-control cli-55c8dfbf94-hv5ll 1/1 Running 0 6m13s
traffic-control intersection-65dfd67446-tk755 1/1 Running 0 6m23s
traffic-control tmc-69959c9447-lq6bf 1/1 Running 0 6m34s
-
Get your localhost ip address and look for
inetip address:ip a
-
Map the
.testdomains to your localhost address:echo -e "172.28.183.106 tmc.test\n172.28.183.106 intersection.test\n172.28.183.106 cli.test" | sudo tee -a /etc/hosts
-
Replace
172.28.183.106with your actual localhost address.
-
Open the
application.propertiesfile:./cli/src/main/resources/application.properties
-
Modify the user settings starting from line 82 by commenting/uncommenting the desired
username. The password remains unchanged.
-
TMC microservice
curl -k https://tmc.test/tmc-api/test
-
Intersection Microservice
curl http://intersection.test/intersection-api/message
-
CLI Microservice
curl -k https://cli.test/cli-api/test curl -k -X POST https://cli.test/cli-api/create/40.652345/-124.280345/0/90/PEDESTRIAN
- Execute the main method in the
TMCCLIclass:See below for an overview of the API and keycloak-roles../cli/src/main/java/de/tub/aot/TMCCLI.java
Congrats, your done!
Default Role: tmc-operator (has all rights)
tmc(tmc microservice)intersection(intersection microservice)
tmc-admintmc-operatoremergency-vehiclemayor-vehicleautonomous-vehicleregular-vehicle
Base URL: https://tmc.test/tmc-api/
Create a new traffic light at a specified location and heading.
- URL:
/tmc-api/create/{lat_deg}/{lon_deg}/{altitudeAboveNN_m}/{heading}/{type} - Method:
POST - Roles Allowed:
tmc-operator - Parameters:
lat_deg(PathParam): Latitude in degrees.lon_deg(PathParam): Longitude in degrees.altitudeAboveNN_m(PathParam): Altitude above sea level in meters.heading(PathParam): Direction the traffic light is facing, in degrees.type(PathParam): Type of the traffic light (VEHICLEorPEDESTRIAN).
Retrieve the status of a specific traffic light.
- URL:
/tmc-api/{trafficLightId}/status - Method:
GET - Roles Allowed:
tmc-operator,tmc-admin,emergency-vehicle,mayor-vehicle,autonomous-vehicle - Parameters:
trafficLightId(PathParam): Unique identifier of the traffic light.
Retrieve the status of all traffic lights.
- URL:
/tmc-api/trafficLights/status - Method:
GET - Roles Allowed:
tmc-operator,tmc-admin,emergency-vehicle,mayor-vehicle,autonomous-vehicle
Request green for a traffic light.
- URL:
/tmc-api/requestGreen/{trafficLightId} - Method:
PUT - Roles Allowed:
tmc-operator,emergency-vehicle,mayor-vehicle
Remove a traffic light by its unique ID.
- URL:
/tmc-api/remove/{trafficLightId} - Method:
DELETE - Roles Allowed:
tmc-operator - Parameters:
trafficLightId(PathParam): Unique identifier of the traffic light.
Set the color of a specific traffic light.
- URL:
/tmc-api/set/{id}/{color} - Method:
PUT - Roles Allowed:
tmc-operator - Parameters:
id(PathParam): Unique identifier of the traffic light.color(PathParam):- For vehicle lights:
green,yellow,red,yellow_flashing,red_yellow - For pedestrian lights:
green,red.
- For vehicle lights:
Disable (turn off) a specific traffic light.
- URL:
/tmc-api/disable/{id} - Method:
PUT - Roles Allowed:
tmc-operator - Parameters:
id(PathParam): Unique identifier of the traffic light.
Enable (turn on) a specific traffic light with an initial color.
- URL:
/tmc-api/enable/{id}/{color} - Method:
PUT - Roles Allowed:
tmc-operator - Parameters:
id(PathParam): Unique identifier of the traffic light.color(PathParam): Initial color after enabling.- For vehicle lights:
green,yellow,yellow_flashing,red_yellow - For pedestrian lights:
green,red.
- For vehicle lights:
Link two traffic lights to coordinate their behavior.
- URL:
/tmc-api/link/{id1}/{id2} - Method:
PUT - Roles Allowed:
tmc-operator - Parameters:
id1(PathParam): Unique identifier of the first traffic light.id2(PathParam): Unique identifier of the second traffic light.
curl -k -X POST http://cli.test/cli-api/create/40.652345/-124.280345/0/90/pedestrian# needs to be valid UUID
curl -k http://cli.test/cli-api/c8a0b04d-f94d-491e-ab0d-e2457188f153/statuscurl -k http://cli.test/cli-api/trafficLights/statuscurl -k -X PUT http://cli.test/cli-api/requestGreen/4957d6e1-deb0-3265-ae9d-63687a96b941curl -k -X DELETE http://cli.test/cli-api/remove/4957d6e1-deb0-3265-ae9d-63687a96b941curl -k -X PUT https://cli.test/cli-api/set/c8a0b04d-f94d-491e-ab0d-e2457188f153/greencurl -k -X PUT https://cli.test/cli-api/disable/c8a0b04d-f94d-491e-ab0d-e2457188f153curl -k -X PUT https://cli.test/cli-api/enable/c8a0b04d-f94d-491e-ab0d-e2457188f153/greencurl -k -X PUT https://cli.test/cli-api/link/c8a0b04d-f94d-491e-ab0d-e2457188f153/4957d6e1-deb0-3265-ae9d-63687a96b941