---
title: "Staged Kubernetes network policy"
description: "Reference for the StagedKubernetesNetworkPolicy resource in Calico Open Source that previews Kubernetes network policy without enforcing it."
product: "Calico Open Source"
version: "3.33 (latest)"
section: "Reference"
canonical_url: "https://docs.tigera.io/calico/latest/reference/resources/stagedkubernetesnetworkpolicy"
---

# Staged Kubernetes network policy

A staged Kubernetes network policy resource (StagedKubernetesNetworkPolicy) represents a staged version of [Kubernetes network policy](https://kubernetes.io/docs/concepts/services-networking/network-policies). This is used to preview network behavior before actually enforcing the network policy. Once persisted, this is converted to a Calico [network policy](https://docs.tigera.io/calico/latest/reference/resources/networkpolicy.md) that is not enforced. StagedKubernetesNetworkPolicy is a namespaced resource.

For `kubectl` commands, you can use the aliases `stagedkubernetesnetworkpolicy.projectcalico.org`, `stagedkubernetesnetworkpolicies.projectcalico.org`, `stagedkubernetesnetworkpolicy.p`, and `stagedkubernetesnetworkpolicies.p`.

## Sample YAML

This sample is the example policy from the [Kubernetes NetworkPolicy documentation](https://kubernetes.io/docs/concepts/services-networking/network-policies/#networkpolicy-resource), with only the `apiVersion` and `kind` changed to make it a staged Kubernetes network policy.

```yaml
apiVersion: projectcalico.org/v3
kind: StagedKubernetesNetworkPolicy
metadata:
  name: test-network-policy
  namespace: default
spec:
  podSelector:
    matchLabels:
      role: db
  policyTypes:
    - Ingress
    - Egress
  ingress:
    - from:
        - ipBlock:
            cidr: 172.17.0.0/16
            except:
              - 172.17.1.0/24
        - namespaceSelector:
            matchLabels:
              project: myproject
        - podSelector:
            matchLabels:
              role: frontend
      ports:
        - protocol: TCP
          port: 6379
  egress:
    - to:
        - ipBlock:
            cidr: 10.0.0.0/24
      ports:
        - protocol: TCP
          port: 5978
```

## Definition

### Metadata

| Field       | Description                                                     | Accepted Values                                                                                                          | Schema | Default |
| ----------- | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------ | ------- |
| `name`      | The name of this staged Kubernetes network policy. Required.    | Lowercase alphanumeric characters, `-`, or `.`. Must start and end with an alphanumeric character. Up to 253 characters. | string |         |
| `namespace` | The namespace this staged Kubernetes network policy belongs to. |                                                                                                                          | string |         |

### Spec

StagedKubernetesNetworkPolicy adds the `stagedAction` field to the Kubernetes NetworkPolicy spec. It inherits the other spec fields, `podSelector`, `ingress`, `egress`, and `policyTypes`, and their nested types from Kubernetes. For those fields, see [NetworkPolicySpec](https://kubernetes.io/docs/reference/kubernetes-api/policy-resources/network-policy-v1/#NetworkPolicySpec) in the Kubernetes API reference.

| Field          | Description                                                                                                | Accepted Values                    | Schema | Default |
| -------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------- | ------ | ------- |
| `stagedAction` | The staged action. With `Delete`, leave every other spec field empty, and the policy is not sent to Felix. | `Set`, `Delete`, `Learn`, `Ignore` | string | `Set`   |

## Default policy types

If you omit `policyTypes` and the policy has no egress rules, the policy applies to ingress traffic only. If the policy has egress rules, set this field: when it is omitted, clusters that use native v3 CRDs store `Ingress, Egress`, but clusters that use the Calico API server apply the policy to ingress traffic only.

## Additional resources

- [Stage, preview impacts, and enforce policy](https://docs.tigera.io/calico/latest/network-policy/staged-network-policies.md)
- [Staged network policy](https://docs.tigera.io/calico/latest/reference/resources/stagednetworkpolicy.md)
- [Network policy](https://docs.tigera.io/calico/latest/reference/resources/networkpolicy.md)
