All Policies
Restrict control plane scheduling
Scheduling non-system Pods to control plane nodes (which run kubelet) is often undesirable because it takes away resources from the control plane components and can represent a possible security threat vector. This policy prevents users from setting a toleration in a Pod spec which allows running on control plane nodes with the taint key `node-role.kubernetes.io/master`.
Policy Definition
/other/restrict_controlplane_scheduling/restrict_controlplane_scheduling.yaml
1apiVersion: kyverno.io/v1
2kind: ClusterPolicy
3metadata:
4 name: restrict-controlplane-scheduling
5 annotations:
6 policies.kyverno.io/title: Restrict control plane scheduling
7 policies.kyverno.io/category: Sample
8 policies.kyverno.io/subject: Pod
9 policies.kyverno.io/description: >-
10 Scheduling non-system Pods to control plane nodes (which run kubelet) is often undesirable
11 because it takes away resources from the control plane components and can represent
12 a possible security threat vector. This policy prevents users from setting a toleration
13 in a Pod spec which allows running on control plane nodes
14 with the taint key `node-role.kubernetes.io/master`.
15spec:
16 validationFailureAction: audit
17 background: true
18 rules:
19 - name: restrict-controlplane-scheduling-master
20 match:
21 resources:
22 kinds:
23 - Pod
24 validate:
25 message: Pods may not use tolerations which schedule on control plane nodes.
26 pattern:
27 spec:
28 =(tolerations):
29 - key: "!node-role.kubernetes.io/master"
30 - name: restrict-controlplane-scheduling-control-plane
31 match:
32 resources:
33 kinds:
34 - Pod
35 validate:
36 message: Pods may not use tolerations which schedule on control plane nodes.
37 pattern:
38 spec:
39 =(tolerations):
40 - key: "!node-role.kubernetes.io/control-plane"