Kahibaro
Discord Login Register

13.5 Network security

Core concepts of network security in OpenShift

In OpenShift, “network security” is mostly about controlling which workloads can talk to which other workloads, and how traffic enters and leaves the cluster, while integrating with Kubernetes’ native networking and OpenShift-specific features.

At a high level, you will work with:

This chapter focuses on these mechanisms specifically from a security perspective, not general networking behavior.


Default network behavior and security implications

By default (unless changed by cluster configuration):

From a security standpoint, you should think about:

Most of this is enforced through NetworkPolicies and how you configure Routes/Ingress and external access.


NetworkPolicies: controlling pod-to-pod traffic

NetworkPolicies are the primary mechanism to secure traffic within the cluster.

What a NetworkPolicy does (security perspective)

The effect of a NetworkPolicy depends on whether policies exist for the targeted pods:

Whether egress is enforced depends on the network plugin (OpenShift SDN vs OVN-Kubernetes) and configuration, but on modern OpenShift with OVN-Kubernetes, both ingress and egress are commonly supported.

Basic structure of a NetworkPolicy

A NetworkPolicy generally defines:

Example (conceptual):

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-frontend-to-backend
  namespace: myapp
spec:
  podSelector:
    matchLabels:
      role: backend
  policyTypes:
    - Ingress
  ingress:
    - from:
        - podSelector:
            matchLabels:
              role: frontend
      ports:
        - port: 8080
          protocol: TCP

Security interpretation:

Scoped isolation and multi-tenant security

NetworkPolicies are critical for:

Common patterns:

Namespaces, labels, and identity-based policies

Network security in OpenShift relies heavily on namespaces and labels as an identity layer.

Namespace-based isolation

You can reference whole namespaces in NetworkPolicies using namespaceSelector. This enables patterns like:

Example:

spec:
  podSelector:
    matchLabels:
      app: payments
  ingress:
    - from:
        - namespaceSelector:
            matchLabels:
              security-tier: trusted

Security implication: only pods in namespaces labeled security-tier=trusted may reach app=payments pods.

Label hygiene as a security tool

Because policies use labels for selection:

Combining labels such as team, env (dev/test/prod), tier (frontend/backend/db) creates a rich “identity” for policy rules without relying on IPs.


Controlling egress traffic from pods

While ingress protects who can reach your pod, egress control protects what your pod can reach.

Key reasons to control egress:

Egress patterns in OpenShift

Typical policies you may implement:

Example (conceptual):

spec:
  podSelector:
    matchLabels:
      app: backend
  policyTypes:
    - Egress
  egress:
    - to:
        - ipBlock:
            cidr: 10.0.0.0/8
      ports:
        - protocol: TCP
          port: 443

Security interpretation: app=backend pods can only make TCP/443 connections to private IPs in 10.0.0.0/8. All other egress is denied.

In more advanced setups, OpenShift clusters might integrate with:

Securing external access: Routes, Ingress, and TLS

Internal pod-to-pod traffic is one side of network security; the other is how you expose applications to the outside world.

In OpenShift:

Security considerations for Routes / Ingress

From a security viewpoint, you need to consider:

Securing Services and internal endpoints

Even though a Service by itself does not enforce access control, its configuration impacts security:

DNS, service discovery, and name-based isolation

OpenShift provides internal DNS for Services and Pods. From a security angle:

Some security best practices tied to DNS:

Encryption in transit inside the cluster

Network security is not only about connectivity but also about confidentiality and integrity of traffic.

In OpenShift:

Typical patterns:

Integrating cluster network security with external infrastructure

OpenShift network security rarely lives in isolation; it integrates with:

Important integration points:

Common network security patterns in OpenShift

Some typical, reusable patterns you’ll see in real-world clusters:

  1. Namespace-per-team with isolation
    • Each team gets a namespace (or set of namespaces).
    • Default deny NetworkPolicies are applied to all namespaces.
    • Teams define explicit allow rules between their own components.
    • Cross-team access goes through well-defined, policy-protected APIs.
  2. “DMZ” namespaces
    • A dedicated namespace for externally exposed frontends or APIs.
    • Ingress/Routes only send traffic into this DMZ namespace.
    • Strict policies control which internal services the DMZ pods can talk to.
  3. Locked-down data services
    • Databases, message queues, and caches in separate namespaces or with strong labels.
    • Only specific application namespaces are allowed to reach them on the right ports.
    • No direct external Routes or LoadBalancers are created for these services.
  4. Restricted egress to the Internet
    • Default deny egress for application workloads.
    • Allow only DNS, logging, and explicit external APIs (e.g., payment gateways).
    • Optionally, force traffic through a corporate proxy.

Practical guidance and pitfalls

When designing network security in OpenShift, be aware of:

Design your network security as part of an overall security architecture, not as an afterthought around individual services.


By understanding and applying these OpenShift-specific network security concepts—NetworkPolicies, secure external exposure, careful service configuration, and integration with external controls—you can build clusters where network paths are explicit, minimal, and auditable instead of implicit and wide open.

Views: 40

Comments

Please login to add a comment.

Don't have an account? Register now!