mirror of
https://gitlab.opencode.de/bmi/opendesk/deployment/opendesk.git
synced 2025-12-06 07:21:36 +01:00
56 lines
1.9 KiB
YAML
56 lines
1.9 KiB
YAML
# Source: https://github.com/kyverno/policies/tree/main/pod-security
|
|
# License: Apache-2.0
|
|
apiVersion: kyverno.io/v1
|
|
kind: ClusterPolicy
|
|
metadata:
|
|
name: require-requests-limits
|
|
labels:
|
|
opendesk.eu/security-id: wld-iso-007
|
|
annotations:
|
|
policies.kyverno.io/title: Require Limits and Requests
|
|
policies.kyverno.io/category: Best Practices, EKS Best Practices
|
|
policies.kyverno.io/severity: medium
|
|
policies.kyverno.io/subject: Pod
|
|
policies.kyverno.io/minversion: 1.6.0
|
|
policies.kyverno.io/description: >-
|
|
As application workloads share cluster resources, it is important to limit resources
|
|
requested and consumed by each Pod. It is recommended to require resource requests and
|
|
limits per Pod, especially for memory and CPU. If a Namespace level request or limit is specified,
|
|
defaults will automatically be applied to each Pod based on the LimitRange configuration.
|
|
This policy validates that all containers have something specified for memory and CPU
|
|
requests and memory limits.
|
|
spec:
|
|
validationFailureAction: Audit
|
|
background: true
|
|
rules:
|
|
- name: validate-resources
|
|
match:
|
|
any:
|
|
- resources:
|
|
kinds:
|
|
- Pod
|
|
validate:
|
|
message: "CPU and memory resource requests and memory limits are required for containers."
|
|
pattern:
|
|
spec:
|
|
containers:
|
|
- resources:
|
|
requests:
|
|
memory: "?*"
|
|
cpu: "?*"
|
|
limits:
|
|
memory: "?*"
|
|
=(initContainers):
|
|
- resources:
|
|
requests:
|
|
memory: "?*"
|
|
cpu: "?*"
|
|
limits:
|
|
memory: "?*"
|
|
=(ephemeralContainers):
|
|
- resources:
|
|
requests:
|
|
memory: "?*"
|
|
cpu: "?*"
|
|
limits:
|
|
memory: "?*" |