1
0
Fork 0

feat(rules/kubernetes): add rule to prevent latest tag, rule to ensure pull policy is set

This commit is contained in:
ssube 2019-11-15 20:53:09 -06:00 committed by Sean Sube
parent 26eda4c6fe
commit 8254848ef8
7 changed files with 59 additions and 1 deletions

View File

@ -106,6 +106,7 @@ rules:
level: info
tags:
- kubernetes
- important
- labels
check:
@ -121,4 +122,43 @@ rules:
additionalProperties: false
patternProperties:
"^[-.a-z0-9]{1,63}$":
type: string
type: string
- name: kubernetes-container-pull-policy
desc: all containers should have a pull policy
level: info
tags:
- kubernetes
- image
- optional
select: '$..containers.*'
check:
type: object
required: [image, imagePullPolicy]
properties:
imagePullPolicy:
type: string
enum:
- Always
- IfNotPresent
- Never
- name: kubernetes-image-latest
desc: images should never use :latest tag
level: info
tags:
- kubernetes
- image
- important
select: '$..containers.*'
check:
type: object
required: [image]
properties:
image:
type: string
not:
pattern: ':latest$'

View File

@ -10,6 +10,8 @@ spec:
spec:
containers:
- name: test
image: foo
imagePullPolicy: Always
resources:
limits:
cpu: 4000m

View File

@ -10,6 +10,8 @@ spec:
spec:
containers:
- name: test
image: foo
imagePullPolicy: Always
resources:
limits:
memory: 5Mi

View File

@ -10,6 +10,8 @@ spec:
spec:
containers:
- name: test
image: foo
imagePullPolicy: Always
resources:
limits:
cpu: 200m

View File

@ -10,6 +10,8 @@ spec:
spec:
containers:
- name: test
image: foo
imagePullPolicy: Always
resources:
limits:
cpu: 4000m
@ -19,6 +21,8 @@ spec:
memory: 5Gi
- name: other
image: foo
imagePullPolicy: Always
resources:
limits:
cpu: 2000m

View File

@ -10,4 +10,6 @@ spec:
spec:
containers:
- name: test
image: foo
imagePullPolicy: Always
# missing resources

View File

@ -10,6 +10,8 @@ spec:
spec:
containers:
- name: test
image: foo
imagePullPolicy: Always
resources:
limits:
cpu: 4000m
@ -28,6 +30,8 @@ spec:
spec:
containers:
- name: test
image: foo
imagePullPolicy: Always
resources:
limits:
cpu: 200m
@ -46,6 +50,8 @@ spec:
spec:
containers:
- name: test
image: foo
imagePullPolicy: Always
resources:
limits:
cpu: 4000m