DemandFlow Support Centre

K8SNETPOLICY: K8s Network Policy

ReferenceEntity Reference16/04/2026Updated 16/04/2026
A Kubernetes NetworkPolicy controlling ingress and egress traffic rules for pods within a namespace.

K8SNETPOLICY: K8s Network Policy

A Kubernetes NetworkPolicy controlling ingress and egress traffic rules for pods within a namespace.

Default definition. This article describes the default K8SNETPOLICY definition shipped with DemandFlow. Administrators can add, remove, rename, or re-type fields, change which ones are required, and alter the layout from the Definitions screen in Settings. Your tenant's current schema may differ from what is shown here. To read the current definition at any time, GET the DEFINITION object whose id matches K8SNETPOLICY.

Entity properties

PropertyValue
Entity codeK8SNETPOLICY
Display nameK8s Network Policy
PluralK8s Network Policies
Level407

Use cases

K8SNETPOLICY models the Kubernetes NetworkPolicy resource that provides micro-segmentation at the pod level. The policyType multiselect (Ingress, Egress) reflects the two traffic directions a policy can govern. The podSelector textarea is required because it defines which pods the policy applies to.

Fields

Policy Information

FieldTypeRequiredNotes
nametextYesPolicy Name.
namespacereference → K8SNAMESPACEYesNamespace.
policyTypearray of enumsYesValid ids: 1 (Ingress), 2 (Egress).
enabledbooleanEnabled.
enforcedbooleanEnforced.

Target Selection

FieldTypeRequiredNotes
podSelectortext (multi-line)YesLabel selector for target pods (JSON)
matchLabelstext (multi-line)Labels to match (JSON)
affectedPodsnumberAffected Pods.
affectedWorkloadsnumberAffected Workloads.

Ingress Configuration

FieldTypeRequiredNotes
defaultIngressActionenumValid ids: 1 (Allow All), 2 (Deny All).
ingressRuleCountnumberIngress Rule Count.
ingressRulestext (multi-line)Complete ingress rules (JSON format)
allowedNamespacesarray of textAllowed Namespaces.
allowedPodSelectorstext (multi-line)Pod selectors that can access (JSON)
allowedPortstext (multi-line)Port and protocol rules (JSON)

Egress Configuration

FieldTypeRequiredNotes
defaultEgressActionenumValid ids: 1 (Allow All), 2 (Deny All).
egressRuleCountnumberEgress Rule Count.
egressRulestext (multi-line)Complete egress rules (JSON format)
allowedDestinationstext (multi-line)IP blocks and namespaces (JSON)
allowedDNStext (multi-line)DNS names allowed for egress
blockedPortstext (multi-line)Ports blocked for egress

IP Block Rules

FieldTypeRequiredNotes
allowedIPBlockstext (multi-line)CIDR blocks allowed (one per line)
deniedIPBlockstext (multi-line)CIDR blocks denied (one per line)
internalOnlybooleanInternal Traffic Only.
allowLoopbackbooleanAllow Loopback.

Port Rules

FieldTypeRequiredNotes
defaultPortsarray of enumsValid ids: 1 (HTTP (80)), 2 (HTTPS (443)), 3 (DNS (53)), 4 (MySQL (3306)), 5 (PostgreSQL (5432)), 6 (Redis (6379)), 7 (MongoDB (27017)).
customPortstext (multi-line)Custom port definitions (JSON)
protocolRestrictionsarray of enumsValid ids: 1 (TCP), 2 (UDP), 3 (SCTP).

Advanced Configuration

FieldTypeRequiredNotes
labelstext (multi-line)Key-value pairs (JSON)
annotationstext (multi-line)Key-value pairs (JSON)
prioritynumberPolicy evaluation priority
directionenumValid ids: 1 (Ingress), 2 (Egress), 3 (Both).

Compliance & Logging

FieldTypeRequiredNotes
complianceFrameworkarray of enumsValid ids: 1 (PCI DSS), 2 (HIPAA), 3 (SOC 2), 4 (ISO 27001), 5 (GDPR).
loggingEnabledbooleanEnable Logging.
logLevelenumValid ids: 1 (None), 2 (Basic), 3 (Detailed), 4 (Debug).
alertOnViolationbooleanAlert on Violation.
blockOnViolationbooleanBlock on Violation.

Policy Testing

FieldTypeRequiredNotes
testModebooleanLog but don't enforce
lastTestTimedatetimeLast Test.
testResultstext (multi-line)Test Results.
simulationScenariostext (multi-line)Test scenarios (JSON)
violationCountnumberViolations (24h).
allowedConnectionsnumberAllowed Connections (24h).
blockedConnectionsnumberBlocked Connections (24h).
effectivenessScoregaugeEffectiveness Score.

Impact Analysis

FieldTypeRequiredNotes
affectedServicesarray of textAffected Services.
affectedIngressesarray of textAffected Ingresses.
dependencyMaptext (multi-line)Services and workloads affected
riskLevelenumValid ids: 1 (Low), 2 (Medium), 3 (High), 4 (Critical).
lastRiskAssessmentdatetimeLast Risk Assessment.

Policy Metrics

FieldTypeRequiredNotes
evaluationsPerMinutenumberEvaluations/min.
avgEvaluationTimenumberAvg Evaluation Time (ms).
cacheHitRategaugeCache Hit Rate %.
performanceImpactgaugePerformance Impact %.
lastViolationdatetimeLast Violation.
violationTrendenumValid ids: 1 (Decreasing), 2 (Stable), 3 (Increasing).
eventstext (multi-line)Last 50 policy events

Relationships

  • Lookups: namespace points at a K8SNAMESPACE record.

Creating a K8s Network Policy via the API

POST /v1/objects
Authorization: Bearer <your-pat>
Content-Type: application/json

{
  "entity":   "K8SNETPOLICY",
  "level":    407,
  "comboKey": "SUB:<your-sub-id>|ENT:",
  "name": "Example",
  "namespace": "",
  "policyType": "...",
  "podSelector": "..."
}

Listing K8s Network Policies

# All records in your tenant
GET /v1/entities/K8SNETPOLICY/SUB:<your-sub-id>

See also

k8snetpolicyk8snetworkpolicypolicies

Was this article helpful?

← Back to Knowledge Base