The Simplest Way to Make Cilium and Nats Work Like They Should
Running cilium and nats together secures fast message traffic inside your cluster. Cilium locks down network paths while NATS routes messages between your apps. Many teams struggle when they pair these two tools for the first time. Packets drop when network rules clash with how message nodes find each other. You can fix this by matching your network rules to your message accounts. This guide shows you how to set up both tools for production workloads. How data and roles flow between cilium an
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
Running cilium and nats together secures fast message traffic inside your cluster. Cilium locks down network paths while NATS routes messages between your apps.
Many teams struggle when they pair these two tools for the first time. Packets drop when network rules clash with how message nodes find each other. You can fix this by matching your network rules to your message accounts. This guide shows you how to set up both tools for production workloads.
How data and roles flow between cilium and nats
Cilium works at the kernel level to check every packet in your cluster. It uses workload identities instead of shifting IP addresses to enforce network rules. NATS runs as a fast message system that connects your services together. Apps publish messages to subjects, and other apps read from those subjects.
When you run cilium and nats together, security happens in two distinct steps. First, Cilium checks if an app pod can talk to the NATS cluster. It looks at the pod labels and decides if the traffic can pass. If the network rule allows it, the packet reaches the NATS server port.
Second, the NATS server checks the login keys of the incoming app. NATS uses accounts and user keys to split up message traffic between teams. Even if Cilium allows the network link, NATS still checks the subject permissions. An app can only send or read messages on subjects allowed by its role.
Cluster discovery also needs clear paths between all the NATS server pods. NATS nodes talk to each other over specific gossip ports to share routes. Cilium must allow this east-west traffic so the message cluster stays whole. IfCilium blocks these ports, the message cluster splits and drops data.
Common failure modes and how to scope network paths
One common mistake is using one shared NATS account for every single app. Teams often pair this with a broad Cilium rule that lets all pods talk. If one app gets hacked, the attacker can read every message in the cluster. They can also send fake tasks to any other worker pod on the network.
End-to-End Encryption + Cilium Network Policies: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Another failure happens when teams turn on deep packet inspection for message traffic. NATS uses a custom text protocol that starts with plain server info messages. When a client upgrades the link to TLS, basic network checks can get confused. Cilium might drop the link if it expects plain text after the TLS handshake.
Long-lived TCP links can also break during network policy updates or node drains. NATS clients keep one link open for hours or days to send fast messages. If a Cilium agent restarts without care, it might reset the state table. Clients then face sudden drops and must reconnect all at once.
To prevent these issues, scope your rules at both the network and app layers. In Cilium, group your app pods by role labels and only open client ports. Keep the NATS cluster routing ports closed to normal app pods at all times. Only NATS server pods should have a rule that allows routing port traffic.
Next, give each app its own NATS user key with strict subject limits. An order service should only write to order subjects and nothing else. Turn on logging for denied packets in Cilium and failed logins in NATS. When you check both logs together, you can spot bad rules in seconds.
Check database and API queries on the wire
Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.
Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.
Frequently asked questions
Why does Cilium drop NATS connections during TLS upgrades?
Deep packet rules can misread the shift from plain text to encrypted traffic. Stick to layer four port and identity rules for your encrypted message ports.
Which ports need to keeps the session active between NATS server pods?
You must allow the client port, the cluster routing port, and any leaf ports. Scope the cluster routing port so only NATS server pods can reach it.
Should I use Cilium network rules or NATS accounts for security?
Use both tools together for defense in depth across your cluster. Cilium stops rogue pods at the network edge while NATS controls message subjects.
Related guides
In this post