İçeriğe Atla
Mustafa Erbay
Tutorials kubernetes-uretim-guvenlik · 10 min read · görüntülenme Türkçe oku
100%

Gradually Tightening Kubernetes Network Policies with Cilium

A guide to moving Kubernetes network policy from observability into enforced control without breaking production.

Gradually Tightening Kubernetes Network Policies with Cilium — cover image

Applying network policy in Kubernetes environments is the right approach almost everyone agrees on; yet many teams keep postponing it because they fear breaking production. The cluster ends up growing, services multiply, and east-west traffic becomes an invisible free-for-all. Cilium makes this transition more manageable because it joins observability and policy enforcement on the same plane. Following the right order makes step-by-step tightening possible instead of “shutting everything down overnight.”

Diagram of gradual network policy transition with Cilium

Why is a gradual approach essential?

Jumping directly to a deny model without a clear understanding of which pod talks to which service generates production incidents, especially with legacy services. So the first goal is not to “block” but to make existing behavior visible.

A healthy transition is thought of in three phases:

  1. Observing the traffic and dependencies
  2. Defining the allow model per namespace or application
  3. Gradually moving into enforced policy mode

This sequence reduces unnecessary friction between security and operations.

How do you build the starting inventory?

First, you need to understand which services actually need to talk to each other. At this stage:

  • Separate ingress and egress directions
  • Note shared services like DNS, metrics, tracing, and secret management
  • Treat batch jobs and cron workloads separately
  • Prevent ad-hoc debug pods from acting without policy

Cilium Hubble or equivalent visibility tooling delivers value precisely at this point. The goal is not just to count connections but also to understand application ownership.

Which principles help when writing policies?

It is right to start the first rule set in the smallest blast radius. For example, begin around a single namespace or a single application. While writing policy, this approach helps:

  • Create a separate policy group for shared platform services.
  • Define intra-application traffic and cross-namespace traffic separately.
  • Explicitly allow DNS and observability dependencies.
  • Maintain a team standard for matchLabels usage.
apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata:
  name: payments-api-egress
spec:
  endpointSelector:
    matchLabels:
      app: payments-api
  egress:
    - toEndpoints:
        - matchLabels:
            app: postgres

How do you stage enforcement?

In practice, this flow gives a safe outcome:

  1. Collect visibility only on selected namespaces.
  2. Build the recommended policy set.
  3. Enable the rule on low-risk services.
  4. Watch event and drop logs.
  5. Move into production-critical namespaces in a controlled way.

In this model the rollback path is clear and change windows become more manageable.

Operational watch points

  • If application labels are messy, the policy is unsustainable.
  • If namespace boundaries were designed badly, policy count explodes.
  • Policy violations should be watched not only by security but by the platform team too.
  • Network policies that are not connected to a GitOps pipeline turn into a manual exception store quickly.

In short, the topic is not just writing YAML; it is disciplining the cluster contract.

Conclusion

Tightening network policy with Cilium is a strong step that moves Kubernetes security from theory into practice. The key to success is not an aggressive start but following a gradual path from visibility into enforcement. When you model service dependencies correctly, you raise the security level while keeping production risk manageable.

Paylaş:

Bu yazı faydalı oldu mu?

Yükleniyor...

Bu yazı nasıldı?

ME

Mustafa Erbay

Sistem Mimarisi · Network Uzmanı · Altyapı, Güvenlik ve Yazılım

2006'dan bu yana sistem mimarisi, network, sunucu altyapıları, büyük yapıların kurulumu, yazılım ve sistem güvenliği ekseninde çalışıyorum. Bu blogda sahada karşılığı olan teknik deneyimlerimi paylaşıyorum.

Kişisel Notlar

Bu notlar sadece sizde saklanır. Tarayıcınızda yerel olarak tutulur.

Hazır 0 karakter

Comments

Server-side AI Moderation

Comments are AI-moderated server-side and stored permanently.

?
0/2000

Server-side AI moderation

✉️ Free · No spam · Unsubscribe anytime

Curated digest, hand-picked by me — not the AI

Once a week: the most important post of the week, behind-the-scenes notes, and a "what I actually used this week" section. Less noise, more signal.

  • 📌
    Best of the week Single most-worth-reading post
  • 🔧
    Toolbox notes Real tools I used this week
  • 🧠
    Behind-the-scenes Notes that don't make it to blog

We don't spam. Unsubscribe anytime. · Tracked only by Umami (self-hosted, no Google).

Your Reading Stats

0

Posts Read

0m

Reading Time

0

Day Streak

-

Favorite Category

Related Posts