Component C132 – NATS
By Raj Marni. March 27, 2025. Revised. Version: 0.0.09
1. Overview
C132 – NATS is the publish/subscribe messaging system used by k8or Orbit to facilitate real-time, event-driven communication across different components. By allowing microservices or components to publish messages on specific subjects (topics) and subscribe to the ones they care about, NATS helps decouple components, making the entire ecosystem more resilient, scalable, and responsive to changing states or events.

2. Key Functions
Event-Driven Communication
Publish/Subscribe Model: Components can broadcast (“publish”) events (e.g., “image uploaded”, “cluster provisioned”) on certain channels (subjects), while other components “subscribe” to those channels to react or update their own logic.
Decoupled Services: Services don’t need direct knowledge of each other, only shared subjects, reducing tight coupling.
Asynchronous Messaging
Loose Coupling: Because messages are sent asynchronously, the sending component isn’t blocked waiting for a response.
Scalable Throughput: NATS can handle high message volumes efficiently, making it suitable for real-time updates or logs streaming.
Status and Logging
Event Logging: NATS can carry logs, statuses, or events from one component (e.g., Portal Transfer Logic) to another (e.g., monitoring or auditing service).
Real-Time Updates: Changes in environment, cluster states, or user actions can be instantly disseminated to interested components.
Security & Access Control
Subject-Level Authorization: NATS can enforce who can publish or subscribe to certain subjects, ensuring sensitive data is only accessible by authorized components.
Encryption in Transit: Typically runs over TLS to protect message confidentiality and integrity.
3. Architecture & Interactions
3.1 NATS Core Server
Broker/Server: Manages subject-based routing, message buffering, and client connections.
Subject-Based Routing: Each message has a “subject” or channel. Subscribing services declare which subjects they want to receive.
3.2 Orbit Plane Components
Pub/Sub Clients: Each component (OpsBoard, Manifestor, CommBridge components, etc.) has a NATS client that can publish events or subscribe to relevant subjects.
Integration: For instance, a Transfer microservice publishes “transfer.completed” events, while a logging or analytics service subscribes to it to record or act upon them.
3.3 Cluster Plane
Event-Driven Flows: If a cluster-plane service or agent sends updates (e.g., “node scaling event”), it uses NATS to broadcast to the orbit-plane.
Access Control: All messages from cluster-plane pass through a secure link, ensuring only authorized NATS clients can publish or subscribe.
4. Benefits & Impact
High Decoupling & Flexibility
Microservices can evolve or be replaced without changing the entire system, as long as they continue to publish/subscribe on the same subjects.
Real-Time Responsiveness
As soon as an event is published, all interested subscribers receive it nearly instantly, facilitating quick reaction or data updates.
Scalability
NATS can handle large numbers of messages and connections, supporting more microservices or higher event volumes as the system grows.
Simplified Integration
New services simply subscribe to existing subjects, eliminating the need to code direct integrations with multiple components.
Last updated