All Policies
Block Pod Exec by Namespace Name
The `exec` command may be used to gain shell access, or run other commands, in a Pod's container. While this can be useful for troubleshooting purposes, it could represent an attack vector and is discouraged. This policy blocks Pod exec commands to Pods in a Namespace called `pci`.
Policy Definition
/other/block-pod-exec-by-namespace.yaml
1apiVersion: kyverno.io/v1
2kind: ClusterPolicy
3metadata:
4 name: deny-exec-by-namespace-name
5 annotations:
6 policies.kyverno.io/title: Block Pod Exec by Namespace Name
7 policies.kyverno.io/category: Sample
8 policies.kyverno.io/minversion: 1.4.2
9 policies.kyverno.io/subject: Pod
10 policies.kyverno.io/description: >-
11 The `exec` command may be used to gain shell access, or run other commands, in a Pod's container. While this can
12 be useful for troubleshooting purposes, it could represent an attack vector and is discouraged.
13 This policy blocks Pod exec commands to Pods in a Namespace called `pci`.
14spec:
15 validationFailureAction: audit
16 background: false
17 rules:
18 - name: deny-exec-ns-pci
19 match:
20 resources:
21 kinds:
22 - PodExecOptions
23 preconditions:
24 - key: "{{ request.operation }}"
25 operator: Equals
26 value: CONNECT
27 validate:
28 message: Pods in this namespace may not be exec'd into.
29 deny:
30 conditions:
31 - key: "{{ request.namespace }}"
32 operator: Equals
33 value: pci
34