feat(rules/kubernetes): add rule to prevent latest tag, rule to ensure pull policy is set
This commit is contained in:
parent
26eda4c6fe
commit
8254848ef8
|
@ -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$'
|
|
@ -10,6 +10,8 @@ spec:
|
|||
spec:
|
||||
containers:
|
||||
- name: test
|
||||
image: foo
|
||||
imagePullPolicy: Always
|
||||
resources:
|
||||
limits:
|
||||
cpu: 4000m
|
||||
|
|
|
@ -10,6 +10,8 @@ spec:
|
|||
spec:
|
||||
containers:
|
||||
- name: test
|
||||
image: foo
|
||||
imagePullPolicy: Always
|
||||
resources:
|
||||
limits:
|
||||
memory: 5Mi
|
||||
|
|
|
@ -10,6 +10,8 @@ spec:
|
|||
spec:
|
||||
containers:
|
||||
- name: test
|
||||
image: foo
|
||||
imagePullPolicy: Always
|
||||
resources:
|
||||
limits:
|
||||
cpu: 200m
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -10,4 +10,6 @@ spec:
|
|||
spec:
|
||||
containers:
|
||||
- name: test
|
||||
image: foo
|
||||
imagePullPolicy: Always
|
||||
# missing resources
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue