@@ -11,6 +11,7 @@ The Settings Service is a core component of the PICCOLO framework that provides
1111- ** Resource Management** : List vehicle orchestration resources (nodes, containers, SoCs, boards)
1212- ** Multiple Interfaces** : REST API interface
1313- ** ETCD Integration** : Direct integration with monitoring ETCD storage for real-time vehicle orchestration data
14+ - ** YAML Artifact Management** : Apply and withdraw YAML artifacts through API Server integration
1415
1516## Architecture
1617
@@ -19,7 +20,7 @@ The Settings Service consists of the following modules:
1920- ` settings_core ` : Service initialization and coordination
2021- ` settings_config ` : Configuration management with YAML/JSON support
2122- ` settings_history ` : Change history tracking and rollback
22- - ` settings_monitoring ` : High-level metrics data retrieval and filtering with caching
23+ - ` settings_monitoring ` : High-level metrics data retrieval and filtering with caching (returns both Metric objects with labels and raw resource objects)
2324- ` monitoring_etcd ` : Direct ETCD operations for monitoring data (` /piccolo/metrics/ ` , ` /piccolo/logs/ ` )
2425- ` monitoring_types ` : Type definitions for vehicle orchestration metrics (NodeInfo, SocInfo, BoardInfo)
2526- ` settings_storage ` : ETCD client for configuration data persistence
@@ -77,8 +78,6 @@ The Settings Service provides a comprehensive REST API:
7778** Container Management:**
7879- ` GET /api/v1/containers ` - List all containers
7980- ` GET /api/v1/containers/{id} ` - Get specific container (includes logs)
80- - ` POST /api/v1/containers ` - Create new container (enhanced with hostname labeling)
81- - ` DELETE /api/v1/containers/{id} ` - Delete container
8281
8382** SoC Management:**
8483- ` GET /api/v1/socs ` - List all SoCs
@@ -88,6 +87,12 @@ The Settings Service provides a comprehensive REST API:
8887- ` GET /api/v1/boards ` - List all boards
8988- ` GET /api/v1/boards/{name} ` - Get specific board
9089
90+ ### YAML Artifact Management
91+
92+ ** New endpoints for YAML operations:**
93+ - ` POST /api/v1/yaml ` - Apply YAML artifact (forwards to API Server)
94+ - ` DELETE /api/v1/yaml ` - Withdraw YAML artifact (forwards to API Server)
95+
9196### Metrics Management (Vehicle Orchestration)
9297
9398** Enhanced endpoints with direct ETCD access:**
@@ -205,14 +210,21 @@ curl http://localhost:8080/api/v1/metrics/containers
205210curl http://localhost:8080/api/v1/containers/vehicle-diagnostics
206211```
207212
208- ### Filter Metrics with Query Parameters
213+ ### Get Metrics with Labels (returns Metric objects)
209214
210215``` bash
211- # Get only node metrics, limit to 10 items
212- curl " http://localhost:8080/api/v1/metrics?component=node&max_items=10 "
216+ # Get all metrics with labels and filtering support
217+ curl http://localhost:8080/api/v1/metrics
213218
214- # Get all container metrics
219+ # Get only container metrics with labels
215220curl " http://localhost:8080/api/v1/metrics?component=container"
221+ ```
222+
223+ ### Filter Resources with Query Parameters
224+
225+ ``` bash
226+ # Get only node metrics, limit to 10 items
227+ curl " http://localhost:8080/api/v1/metrics/nodes?page_size=10"
216228
217229# Filter containers by name
218230curl " http://localhost:8080/api/v1/containers?filter=diagnostics"
@@ -224,6 +236,75 @@ curl "http://localhost:8080/api/v1/metrics/socs"
224236curl " http://localhost:8080/api/v1/metrics/boards"
225237```
226238
239+ ### Apply YAML Artifacts
240+
241+ ``` bash
242+ curl -X POST http://localhost:8080/api/v1/yaml \
243+ -H " Content-Type: text/plain" \
244+ -d ' apiVersion: v1
245+ kind: Scenario
246+ metadata:
247+ name: helloworld
248+ spec:
249+ condition: null
250+ action: update
251+ target: helloworld
252+ ---
253+ apiVersion: v1
254+ kind: Package
255+ metadata:
256+ label: null
257+ name: helloworld
258+ spec:
259+ pattern:
260+ - type: plain
261+ models:
262+ - name: helloworld
263+ node: lge-NUC11TNHi5
264+ resources:
265+ volume:
266+ network:
267+ ---
268+ apiVersion: v1
269+ kind: Model
270+ metadata:
271+ name: helloworld
272+ annotations:
273+ io.piccolo.annotations.package-type: helloworld
274+ io.piccolo.annotations.package-name: helloworld
275+ io.piccolo.annotations.package-network: default
276+ labels:
277+ app: helloworld
278+ spec:
279+ hostNetwork: true
280+ containers:
281+ - name: helloworld
282+ image: quay.io/podman/hello:latest
283+ terminationGracePeriodSeconds: 0
284+ restartPolicy: Always'
285+ ```
286+
287+ ### Withdraw YAML Artifacts
288+
289+ To withdraw (delete) a YAML artifact, you must also provide a ** multi-document YAML** containing all required kinds (` Scenario ` , ` Package ` , and ` Model ` ). The API Server expects the full artifact definition for proper deletion.
290+
291+ ``` bash
292+ curl -X DELETE http://localhost:8080/api/v1/yaml \
293+ -H " Content-Type: text/plain" \
294+ -d ' apiVersion: v1
295+ kind: Scenario
296+ metadata:
297+ name: helloworld
298+ spec:
299+ condition: null
300+ action: update
301+ target: helloworld'
302+ ```
303+
304+ ** Note:**
305+ - Always pass the full YAML artifact (Scenario, Package, Model) for both apply and withdraw operations.
306+ - The API Server will reject requests missing required kinds.
307+
227308### Enable Debug Logging for Troubleshooting
228309
229310``` bash
@@ -232,18 +313,13 @@ RUST_LOG=debug ./target/debug/settingsservice
232313
233314## Request/Response Schemas
234315
235- ### Container Creation Request
316+ ### YAML Artifact Request
236317
237- ``` json
238- {
239- "name" : " string (required)" ,
240- "image" : " string (required)" ,
241- "node_name" : " string (required)" ,
242- "description" : " string (optional)" ,
243- "labels" : {
244- "key" : " value"
245- }
246- }
318+ ``` bash
319+ # Content-Type: text/plain
320+ # Body: Raw YAML content
321+ POST /api/v1/yaml
322+ DELETE /api/v1/yaml
247323```
248324
249325### Pod Metrics Response (Enhanced)
@@ -270,26 +346,66 @@ RUST_LOG=debug ./target/debug/settingsservice
270346}
271347```
272348
349+ ### Metric Response (with labels)
350+
351+ ``` json
352+ {
353+ "id" : " string" ,
354+ "component" : " node|container|soc|board" ,
355+ "metric_type" : " NodeInfo|ContainerInfo|SocInfo|BoardInfo" ,
356+ "labels" : {
357+ "container_id" : " string" ,
358+ "image" : " string" ,
359+ "status" : " string" ,
360+ "hostname" : " string"
361+ },
362+ "value" : {
363+ "type" : " ContainerInfo|NodeInfo|SocInfo|BoardInfo" ,
364+ "value" : " ... resource object ..."
365+ },
366+ "timestamp" : " ISO 8601 timestamp"
367+ }
368+ ```
369+
273370### Query Parameters (Enhanced)
274371
275- ** Pod and Container queries now support:**
372+ ** All resource queries support:**
276373- ` ?page=N ` - Page number for pagination
277374- ` ?page_size=N ` - Number of items per page
278- - ` ?filter=search_term ` - Filter by container name, node_name, or hostname
375+ - ` ?filter=search_term ` - Filter by resource name/ID
376+
377+ ** Metrics queries additionally support:**
378+ - ` ?component=node|container|soc|board ` - Filter by component type
379+ - ` ?metric_type=NodeInfo|ContainerInfo|SocInfo|BoardInfo ` - Filter by metric type
380+ - ` ?filter_id=string ` - Use existing filter by ID
381+
382+ ## API Response Types
383+
384+ The Settings Service provides two types of responses for resource data:
385+
386+ 1 . ** Raw Resource Objects** (e.g., ` /api/v1/metrics/containers ` )
387+ - Returns ` ContainerInfo ` , ` NodeInfo ` , ` SocInfo ` , ` BoardInfo ` directly
388+ - Suitable for simple resource listing and details
389+
390+ 2 . ** Metric Objects with Labels** (e.g., ` /api/v1/metrics ` )
391+ - Returns ` Metric ` objects containing resource data plus metadata
392+ - Includes labels, timestamps, and filtering capabilities
393+ - Suitable for advanced monitoring and analytics
279394
280395## Vehicle Service Orchestration Integration
281396
282397The Settings Service integrates directly with the Pullpiri vehicle orchestration framework:
283398
284399- ** MonitoringServer** : Stores vehicle node, container, SoC, and board metrics in ETCD at ` /piccolo/metrics/ `
285400- ** NodeAgent** : Reports node resource utilization and container status to MonitoringServer
286- - ** APIServer** : Consumes configurations for orchestration policies and resource management
401+ - ** APIServer** : Consumes configurations for orchestration policies and resource management; receives YAML artifacts forwarded by Settings Service
287402- ** ETCD** : Central storage for both configurations (` /piccolo/settings/ ` ) and real-time metrics (` /piccolo/metrics/ ` )
288403
289404## Port Usage
290405
291406Following Pullpiri networking conventions:
292407- ** Settings Service** : ` 8080 ` (configurable within Pullpiri's 47001-47099 range)
408+ - ** API Server** : ` 47099 ` (for YAML artifact forwarding)
293409- ** ETCD** : ` 2379, 2380 ` (standard ETCD ports)
294410- ** Other Pullpiri Services** : ` 47001-47099 ` (gRPC: 47001+, REST: up to 47099)
295411
@@ -316,6 +432,7 @@ Error responses include detailed error messages:
316432- Rust 1.70+
317433- ETCD 3.5+
318434- Protocol Buffers compiler (protoc)
435+ - API Server (for YAML artifact operations)
319436
320437## License
321438
0 commit comments