I want to set a deny-all-egress policy on a namespace
Here is the yaml file
apiVersion: v1
kind: NetworkPolicy
metadata:
name: default-deny-egress-namespace
namespace: myns
spec:
podSelector:
matchLabels: {}
policyTypes:
- Egress
This gives me the following error
error: unable to recognize "deny-all-egress-namespace.yaml": no matches for /, Kind=NetworkPolicy
I am on version 1.7 of the server
NetworkPolicy is under networking.k8s.io
group with v1
version.
Try like this.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny-egress-namespace
namespace: myns
spec:
podSelector:
matchLabels: {}
policyTypes:
- Egress
Engress introduced in Kubernetes v1.8
And also above NetworkPolicy structure is supported by v1.8+
Check the documentation