KOP Network Policy Manager - Cluster-Wide Network Policy Rule - Rafay Product Documentation

Cluster-Wide Network Policy rules

Overview

Cluster-Wide Network Policy Rules is a construct that defines a grouping of network security rules that can then be applied to a cluster-wide policy.

RBAC

Only Org Admins and Infra Admins can create/manage cluster-wide network policy rules.

How To Write Cluster-Wide Network Policy Rules

The following types of CRDs are supported for cluster-wide network policy rules:

Example: Allow ingress from all pods to core-dns pods

apiVersion: cilium.io/v2
kind: CiliumClusterwideNetworkPolicy
metadata:
  name: core-dns-ingress
spec:
  endpointSelector:
    matchLabels:
      io.cilium.k8s.policy.serviceaccount: coredns
      k8s:io.kubernetes.pod.namespace: kube-system
  ingress:
  - fromEndpoints:
    - {}
    toPorts:
    - ports:
      - port: "53"
        protocol: UDP

Example: For endpoints whose env is prod, only allow incoming traffic (ingress) if the source also has label tenant1.

apiVersion: "cilium.io/v2"
kind: CiliumNetworkPolicy
metadata:
  name: "l3-rule"
specs:
  - description: "For endpoints with env=prod, allow if source also has label role=tenant1"
    endpointSelector:
      matchLabels:
        env: prod
    ingress:
    - fromEndpoints:
      - matchLabels:
          role: tenant1

Creating a Cluster-Wide Network Policy Rules

Rules can be created by either uploading a YAML file with the CRD definition or by pulling the YAML file from Git.

Rules can be added to a cluster-wide policy by following the instructions in cluster-wide policy

Updating a Cluster-Wide Network Policy Rules

Rules can be added to a cluster-wide policy by following the instructions in cluster-wide policy

Deleting a Cluster-Wide Network Policy Rules