For the complete documentation index, see llms.txt. This page is also available as Markdown.

Security Hardening

Recommended controls for running Lenses in production on Kubernetes: least-privilege database roles, network segmentation, scoped RBAC, Pod Security admission, and resource governance.

This page collects the controls we recommend for a production Lenses deployment on Kubernetes. Each one has been applied to a full Lenses installation — HQ, Agents, SQL Processors, K2K and MCP — and the deployment exercised afterwards to confirm it still works.

None of these controls are required for Lenses to run — they reduce the blast radius if something else in your environment is compromised, and most Kubernetes and Postgres administrators will recognise them as standard defence-in-depth practice.

1. Least-privilege database roles

Lenses HQ and each Agent need a database to store their own metadata. Give each component its own database and a dedicated, non-superuser role that owns only that database:

CREATE ROLE lenses_hq WITH LOGIN NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION
  PASSWORD '<generated>';
CREATE DATABASE lenses_hq OWNER lenses_hq;
REVOKE ALL ON DATABASE lenses_hq FROM PUBLIC;
GRANT CONNECT ON DATABASE lenses_hq TO lenses_hq;

Repeat with a different role and database per component (HQ, each Agent) rather than sharing one role across all of them — a credential leaked from one component then only exposes that component's data.

2. Network segmentation

Apply a default-deny NetworkPolicy for both ingress and egress in every namespace running Lenses components, then add narrow allow rules for the traffic each component actually needs.

DNS keeps working, even under default-deny

DNS resolution has to be explicitly allowed or nothing in the namespace can resolve a hostname, including Lenses' own connections to Kafka, Schema Registry, and Postgres.

Bound egress to the internet

If a namespace's workloads need general outbound access (for example, license checks or reaching an external Kafka/Schema Registry), allow it explicitly rather than leaving egress unrestricted, and exclude the cloud metadata endpoint and private address ranges the workload has no legitimate reason to reach:

This is intentionally broader than just excluding the metadata IP: blocking the whole link-local and RFC1918 ranges also stops a workload reaching other internal services it was never meant to talk to, not only the metadata endpoint.

Component-to-component traffic

Beyond DNS and internet egress, add narrow allow rules for the specific flows your deployment needs — for example, Agent to Kafka/Schema Registry/Kafka Connect, Agent to HQ's gRPC port, and HQ/Agent to PostgreSQL. Scope each rule to the specific port and, where possible, the specific namespace or pod label of the peer, rather than allowing a namespace's pods to reach each other on every port.

3. Namespace-scoped RBAC for Kubernetes-deployed apps

Both SQL Processors and K2K pipelines are deployed by the Agent as Kubernetes workloads, using the Agent's own ServiceAccount. Scope that ServiceAccount with namespace-scoped Role/RoleBinding resources — never a ClusterRole — so the Agent can only deploy into, and read information from, the namespace(s) you explicitly allow.

A Role/RoleBinding pair grants access in one namespace. If you deploy Processors into more than one, create a pair in each target namespace and bind them all to the Agent's ServiceAccount — that is still narrower than a ClusterRole, because the set of namespaces stays one you chose explicitly. Whichever namespaces you pick, list the same ones in lenses.kubernetes.namespaces (see the warning below).

See SQL Processor Deployment for the full Role/RoleBinding example and Helm values. The same RBAC also governs K2K pipeline deployments — there is no separate permission model for K2K.

Namespace-scoped RBAC only works if you also set lenses.kubernetes.namespaces to the same namespace(s). Without it, the Agent's Kubernetes watchers try to list/watch cluster-wide and get denied by the scoped Role. See the linked page for the exact configuration — this is a common step to miss, and granting a ClusterRole to "fix" the resulting error reopens the cross-namespace access the scoped Role was meant to prevent.

4. Pod Security admission

RBAC controls where the Agent can deploy SQL Processors and K2K pipelines. Pod Security admission controls what those workloads are allowed to do once they run. Enforce the baseline Pod Security Standard on every namespace where the Agent deploys workloads, including the Agent's own namespace if processors run there:

baseline rejects pods that use the host's network, process or IPC namespaces, mount host paths, open host ports, run privileged, or add Linux capabilities. The Agent, SQL Processors and K2K pipelines all run under baseline with their default settings.

Labelling a namespace that already runs workloads does not evict pods that violate the standard: Kubernetes reports them as warnings, and rejects only new pods. Check those warnings before restarting anything in the namespace.

5. Resource governance

Set a ResourceQuota and a LimitRange on every namespace where the Agent deploys SQL Processors or K2K pipelines. Without them, a processor or pipeline created through the API can request as much CPU and memory as the cluster will allow.

The LimitRange max is what actually matters here: it caps any single processor or pipeline container regardless of what resource request is submitted through the API, so it bounds the damage even if the ResourceQuota values above are set too high. Treat the numbers above as a starting point, not a fixed recommendation — measure your namespace's current CPU/memory usage under normal load and size the quota with headroom above it, then tighten the LimitRange max to the largest single processor or pipeline you expect to run.

6. Cross-environment K2K deployments

A K2K pipeline runs as a single Kubernetes Deployment, in a single namespace, and Lenses requires the Kafka connection credentials for both the source and target clusters to be available in that same namespace.

If you use K2K to replicate between two environments with different trust levels — for example, reading from production into a lower-trust development or staging environment — this means the higher-trust environment's Kafka credentials will need to exist inside the lower-trust environment's namespace for the pipeline to work. Apply the same access controls, RBAC scoping, and monitoring to that namespace as you apply to the source environment, or avoid routing a K2K pipeline across a trust boundary you are not willing to extend.

  • SQL Processor Deployment — namespace-scoped RBAC and lenses.kubernetes.namespaces in full

  • Kafka ACLs — minimal Kafka permissions for the Agent

  • Kafka Connect — keep secrets out of connector configuration with config providers, and limit who can view connectors

  • Agent Database — configuring the Agent's database connection

  • Database Migration — least-privilege roles when migrating from Lenses 5

Last updated

Was this helpful?