Enforcing Kubernetes NetworkPolicy for Db2 Operator Version 2 workloads by using Kyverno (Enforce mode)
You can enforce Kubernetes NetworkPolicy for Db2 Operator Version 2 (V2)
workloads by using Kyverno. This approach automatically generates network policies to restrict
pod‑to‑pod traffic and enforce network isolation.
Before you begin
- Db2 Operator V2 must be installed with
kyverno.enabled=trueto ensure compatibility with clusters where Kyverno generate policies create KubernetesNetworkPolicyresources. - Kyverno installed in the cluster.
- Kyverno policies applied and configured to run in Enforce mode.
- The cluster uses a container network interface (CNI) plug-in that supports Kubernetes
NetworkPolicy.
About this task
By default, Kubernetes allows network communication between all pods in a cluster. To restrict
pod‑to‑pod communication, you must use Kubernetes NetworkPolicy resources together
with a compatible CNI plug-in.
You can use Kyverno generate policies to enforce network isolation for Db2 Operator V2 workloads.
These policies automatically generate NetworkPolicy resources, including a
default‑deny policy, for namespaces that host restricted‑v2 Db2 Operator V2 workloads. This ensures
that only explicitly allowed network traffic is permitted.
Procedure
To enforce network isolation for Db2 Operator V2 workloads using Kyverno generate policies:
Results
- Kyverno generate policies automatically creates network policies for the Db2 Operator V2 namespace.
- Network traffic to and from Db2 Operator V2 workloads is restricted by default.
- Only explicitly allowed traffic, such as DNS, is permitted.
- Db2 Operator V2 workloads run with enforced network isolation.