The Simplest Way to Make Cilium and Prefect Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Running cilium and prefect together lets teams lock down network paths for every workflow job. Prefect starts task pods in Kubernetes, while Cilium checks kernel rules to allow or block traffic. Data teams use Prefect to schedule and run pipelines across clusters. Platform teams use Cilium to control pod traffic with eBPF rules. When you pair them, each job gets strict network rules at run time. This stops a rogue script from reaching the wrong database or web service. How permissions and dat

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 prefect together lets teams lock down network paths for every workflow job. Prefect starts task pods in Kubernetes, while Cilium checks kernel rules to allow or block traffic.

Data teams use Prefect to schedule and run pipelines across clusters. Platform teams use Cilium to control pod traffic with eBPF rules. When you pair them, each job gets strict network rules at run time. This stops a rogue script from reaching the wrong database or web service.

How permissions and data flow between cilium and prefect

A Prefect worker sits inside your cluster and watches a work queue for new jobs. When a flow starts, the worker asks the Kubernetes API to create a new job pod. Kubernetes schedules the pod, and Cilium hooks into the Linux kernel to set up network paths.

Cilium does not rely on changing IP addresses to enforce rules. Instead, it reads the pod labels and service account attached to the Prefect job. You can label each flow run by team, project, or data sensitivity level. Cilium turns those labels into a network identity right away.

The Prefect pod needs two distinct paths to do its work. First, it must talk to the Prefect server or cloud API to report job status. Second, it must reach the target data stores or internal APIs for that specific task. Cilium policies check both paths at the network layer and the HTTP layer.

Common failure modes and how to scope roles

Many teams give every Prefect job the same default Kubernetes service account. That choice breaks network isolation from day one. If all jobs share one identity, Cilium must allow all of them to reach every database. A flaw in one test script then exposes production data stores to the whole cluster.

Broad API keys cause a second major risk. Teams often store long-lived database keys inside shared Prefect blocks or cluster secrets. Any developer who can run a flow in that workspace can read or use those keys. Worse, standard network logs only show that a pod IP talked to a database port. They do not record which user ran the query or what data came back.

End-to-End Encryption + Cilium Network Policies: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Wait times during pod start can also break your flows. Sometimes a Prefect pod starts running code before its network identity is ready. The first call to the Prefect API or database then fails with a timeout error. You can fix this by making sure your cluster waits for Cilium endpoints before starting containers.

To lock down this setup, split your Prefect work pools by team or trust level. Assign a unique Kubernetes service account and distinct pod labels to each work pool. Write Cilium rules that match those exact labels and block all other traffic by default. Allow outbound DNS and HTTPS calls only to the Prefect API and required data hosts.

Auditing database queries and masking sensitive fields

Network rules stop bad connections, but they cannot inspect SQL queries inside encrypted database traffic. When a Prefect task reads a customer table, Cilium only sees allowed packets moving across the wire. Security teams still need an audit trail of every query and command that a job runs.

Data pipelines also pull raw rows into memory during ETL jobs. If a test flow hits a production database, it might log sensitive fields in plain text. Applying dynamic data masking on the database path rewrites emails, phone numbers, card numbers, and national IDs in results. This keeps raw personal data out of worker logs while letting the pipeline finish its run.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.

Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.

Frequently asked questions

Why do my Prefect job pods fail to reach the Prefect API when Cilium is active?

Your Cilium egress rules likely block outbound DNS lookups or HTTPS traffic to the API host. Add a rule that allows the configured port to cluster DNS and HTTPS to your Prefect domain.

How should we map Prefect flows to Cilium network policies?

Group your flows into separate Prefect work pools and give each pool unique pod labels. Write Cilium rules that match those labels so each pool only reaches its own data targets.

Can Cilium control which database tables a Prefect task queries?

No, Cilium controls network connections and HTTP paths, not SQL queries inside encrypted database sessions. You need database roles or query inspection controls to restrict table reads and mask fields.

The query runs. The emails stay hidden.