1
0
Fork 0
salty-dog/rules/kubernetes.yml

103 lines
2.4 KiB
YAML
Raw Normal View History

name: salty-dog-kubernetes
rules:
- name: kubernetes-resources
2019-06-16 00:43:01 +00:00
desc: containers must have complete resources specified
level: info
tags:
- cluster-health
- important
2019-06-16 03:54:40 +00:00
- kubernetes
select: '$.spec.template.spec.containers[*]'
check:
type: object
additionalProperties: true
required: [resources]
properties:
resources:
type: object
required: [limits, requests]
properties:
limits:
type: object
required: [cpu, memory]
properties:
cpu: &resources-cpu
2019-06-24 04:00:44 +00:00
oneOf:
- type: number
minimum: 1
- type: string
pattern: "[1-9][0-9]*m"
memory: &resources-memory
oneOf:
- type: number
minimum: 1
- type: string
pattern: "[1-9][0-9]*[KMG]i"
requests:
type: object
required: [cpu, memory]
properties:
cpu: *resources-cpu
memory: *resources-memory
- name: kubernetes-resources-minimum-cpu
desc: resource limits are too low
level: debug
tags:
2019-06-16 03:54:40 +00:00
- kubernetes
- optional
select: '$.spec.template.spec.containers[*].resources'
# filter containers with cpu limits
filter:
type: object
properties:
limits:
type: object
properties:
2019-06-25 03:32:39 +00:00
cpu: *resources-cpu
2019-06-16 03:51:03 +00:00
# ensure the limits aren't *too* low
check:
type: object
properties:
limits:
type: object
properties:
cpu:
2019-06-24 04:00:44 +00:00
oneOf:
- type: number
minimum: 1
- type: string
pattern: "[1-9][0-9]{2,}m"
- name: kubernetes-deployment-replicas
2019-06-16 03:51:03 +00:00
desc: deployments must specify a positive replica count
level: info
tags:
- important
2019-06-16 03:54:40 +00:00
- kubernetes
2019-06-16 03:51:03 +00:00
# select the root of the document
select: '$'
2019-06-16 03:51:03 +00:00
# filter deployments
filter:
type: object
properties:
kind:
type: string
const: Deployment
2019-06-16 03:51:03 +00:00
# ensure replicas are greater than 0
check:
type: object
properties:
spec:
type: object
properties:
replica:
type: number
2019-06-25 03:32:39 +00:00
minimum: 1