Verify that peer discovery via headless Service + Downward API is fully implemented per plan §14.5: - Helm templates: miroir-headless.yaml with clusterIP: None, miroir-deployment.yaml with POD_NAME/POD_NAMESPACE/POD_IP - Rust: peer_discovery.rs with SRV lookup, refresh loop in main.rs, miroir_peer_pod_count metric in middleware.rs - Verification: verify_p6_2_peer_discovery.sh script Acceptance tests require multi-pod Kubernetes deployment: 1. 3-pod deployment: each pod sees all 3 peer names within 30s 2. Scale 3→5: new peers discovered within refresh_interval_s × 2 3. Pod eviction: crashed pod drops from peer set within 30s 4. miroir_peer_pod_count matches kube_deployment_status_replicas_ready Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2.6 KiB
2.6 KiB
P6.2 Peer Discovery Implementation Summary
Status: Complete ✓
Peer discovery via headless Service + Downward API is fully implemented per plan §14.5.
Implementation Verified
Helm Templates
-
charts/miroir/templates/miroir-headless.yamlclusterIP: Nonefor headless Service- Label selector matches Deployment pods
- Service name:
{{ include "miroir.fullname" . }}-headless
-
charts/miroir/templates/miroir-deployment.yamlPOD_NAMEfrommetadata.namevia Downward APIPOD_NAMESPACEfrommetadata.namespacevia Downward APIPOD_IPfromstatus.podIPvia Downward API
-
charts/miroir/templates/_helpers.tpl(line 181)- Config injection:
service_name: {{ printf "%s-headless" (include "miroir.fullname" .) }} - Matches headless Service name exactly
- Config injection:
Rust Code
-
crates/miroir-core/src/peer_discovery.rsPeerSetstruct withpeers: Vec<PeerId>andrefreshed_at: InstantPeerDiscovery::refresh()for SRV lookup via trust-dns-resolver- Feature flag:
peer-discovery(enabled in miroir-proxy)
-
crates/miroir-core/src/config.rsPeerDiscoveryConfigstruct withservice_nameandrefresh_interval_s- Defaults:
service_name: "miroir-headless",refresh_interval_s: 15
-
crates/miroir-proxy/src/main.rs(lines 79-91, 407-431)- Creates
PeerDiscoveryinstance whenPOD_NAME != "unknown" - Background refresh loop runs every
refresh_interval_sseconds - Calls
metrics.set_peer_pod_count(count)on successful refresh
- Creates
-
crates/miroir-proxy/src/middleware.rsmiroir_peer_pod_countgauge metric (line 824)set_peer_pod_count(u64)method (line 1582)
Verification
tests/verify_p6_2_peer_discovery.sh- NixOS-compatible shebang:
#!/usr/bin/env bash - Checks for metric existence and env vars
- NixOS-compatible shebang:
Acceptance Criteria (Require Kubernetes Cluster)
The following acceptance tests require a multi-pod Kubernetes deployment:
- 3-pod deployment: Each pod sees all 3 peer names within 30s of last pod ready
- Scale 3→5: New peers discovered within
refresh_interval_s × 2(30s) - Pod eviction: Crashed pod drops from peer set within
refresh_interval_s × 2(30s) - Metric verification:
miroir_peer_pod_countmatcheskube_deployment_status_replicas_ready
Prior Commits
e6cdd05- P6.2: Fix peer discovery DNS SRV service name and add test26c9521- P6.2: Fix peer discovery DNS SRV service name and add POD_IPcf9ae11- P6.2: Fix verification script shebang for NixOS compatibility7784076- P6.2: Peer discovery implementation verification notesbddfeb3- P6.2: Verify peer discovery implementation (plan §14.5)