Need help with your APIs? I offer API discovery, governance & evangelism services. Explore services →
API Evangelist API Evangelist
Discovery
Learnings
Guidance
Toolbox
Alignment
API Evangelist LLC

Kubernetes Services NetworkPolicy API

NetworkPolicy resources controlling Pod-level traffic ingress and egress based on label selectors, namespace selectors, and IP CIDR blocks.

Kubernetes Services NetworkPolicy API is one of 13 APIs that Kubernetes Services publishes on the APIs.io network, described by a machine-readable OpenAPI specification and an AsyncAPI event-driven specification.

This API exposes 1 JSON Schema definition.

Tagged areas include NetworkPolicy. The published artifact set on APIs.io includes an OpenAPI specification, API documentation, an API reference, an AsyncAPI specification, and 1 JSON Schema.

This API exposes 7 operations across 3 paths, and defines 12 schemas. It is described by OpenAPI 3.1.0, at version v1.32.0.

Requests are made against a single base URL, https://kubernetes.default.svc.

7 operations 3 paths 12 schemas 1 DELETE3 GET1 PATCH1 POST1 PUT

Metadata

The identity and technical contract details declared by the specification.

Specification
OpenAPI 3.1.0
API Version
v1.32.0
Server
https://kubernetes.default.svc
Authentication
HTTP Bearer, Mutual TLS
Terms of Service
Resource Areas
1

Authentication & Security 2

Kubernetes Services NetworkPolicy API declares 2 security schemes for authenticating requests. It accepts HTTP bearer tokens (JWT) (bearerAuth). It requires mutual TLS (clientCertificate). By default, every request must be authenticated.

  • bearerAuth — Kubernetes service account or user bearer token.
  • clientCertificate — Client TLS certificate signed by the cluster CA.

Paths & Operations 7

Across 3 paths, the API surfaces 7 operations — 1 DELETE, 3 GET, 1 PATCH, 1 POST, 1 PUT. Each is listed below with its method, path, parameters, and response codes.

NetworkPolicy 7

NetworkPolicy resources controlling Pod-level traffic ingress and egress based on label selectors, namespace selectors, and IP CIDR blocks.

GET
/apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies
Kubernetes Services List NetworkPolicies in a namespace
listNamespacedNetworkPolicies 6 params → 200401
POST
/apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies
Kubernetes Services Create a NetworkPolicy
createNamespacedNetworkPolicy 2 params body → 201400401
GET
/apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies/{name}
Kubernetes Services Get a NetworkPolicy
getNamespacedNetworkPolicy 2 params → 200401404
PUT
/apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies/{name}
Kubernetes Services Replace a NetworkPolicy
replaceNamespacedNetworkPolicy 3 params body → 200400401404
PATCH
/apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies/{name}
Kubernetes Services Patch a NetworkPolicy
patchNamespacedNetworkPolicy 2 params body → 200401404
DELETE
/apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies/{name}
Kubernetes Services Delete a NetworkPolicy
deleteNamespacedNetworkPolicy 2 params → 200401404
GET
/apis/networking.k8s.io/v1/networkpolicies
Kubernetes Services List NetworkPolicies across all namespaces
listNetworkPoliciesAllNamespaces 4 params → 200401

Schemas 12

The contract defines 12 schemas that model the data the API accepts and returns. The most detailed are ObjectMeta (7 properties), Status (4 properties), NetworkPolicyList (4 properties), NetworkPolicy (4 properties). Each schema is shown below with its type and property counts.

NetworkPolicyList
object
A list of NetworkPolicy objects.
4 properties 1 required
NetworkPolicy
object
A NetworkPolicy describes how groups of pods are allowed to communicate with each other and other network endpoints. Policies are additive — if multiple polici…
4 properties
LabelSelector
object
A label selector filtering pods or namespaces by their labels. Combines matchLabels equality requirements with matchExpressions set-based requirements using AN…
2 properties
NetworkPolicyPeer
object
A network policy peer specifying a traffic source (in ingress rules) or destination (in egress rules). Uses AND logic when multiple selector types are combined.
3 properties
NetworkPolicyEgressRule
object
An egress rule allowing outbound traffic from selected pods to specified destinations on specified ports. An empty to list allows traffic to all destinations.
2 properties
NetworkPolicyIngressRule
object
An ingress rule allowing inbound traffic to selected pods from specified sources on specified ports. An empty from list allows traffic from all sources. An emp…
2 properties
NetworkPolicySpec
object
Specification of a NetworkPolicy defining which pods are selected, what policy types apply, and the ingress and egress rules.
4 properties 1 required
ObjectMeta
object
Standard Kubernetes object metadata.
7 properties
NetworkPolicyPort
object
A port and protocol combination allowed by a network policy rule. Empty port/protocol fields match all ports and protocols.
3 properties
IPBlock
object
An IP block defined by a CIDR range with optional exceptions, used to allow or restrict traffic to or from specific IP ranges.
2 properties 1 required
Status
object
Error or result status.
4 properties
ListMeta
object
Metadata for list responses.
3 properties

Specification

The full machine-readable OpenAPI contract behind this narrative.

Source

kubernetes-services-networkpolicy-api-openapi.yml Raw ↑

Other APIs Kubernetes Services publishes across the network.

Kubernetes DNS for Services and Pods
Kubernetes Services EndpointSlices API
Kubernetes Services Gateway API
Kubernetes Services GatewayClass API
Kubernetes Services GRPCRoute API
Kubernetes Services HTTPRoute API
Kubernetes Services Ingress API
Kubernetes Services IngressClass API
Kubernetes Services IngressStatus API
Kubernetes Services Namespaces API
Kubernetes Services Services API
Kubernetes Services ServiceStatus API