2022-11-08 16:05:49 +01:00
|
|
|
apiVersion: kyverno.io/v1
|
|
|
|
kind: ClusterPolicy
|
|
|
|
metadata:
|
|
|
|
name: disallow-latest-tag
|
|
|
|
spec:
|
2023-04-03 18:27:21 +02:00
|
|
|
validationFailureAction: Audit
|
2022-11-08 16:05:49 +01:00
|
|
|
rules:
|
|
|
|
- match:
|
2023-06-07 20:32:35 +02:00
|
|
|
any:
|
|
|
|
- resources:
|
|
|
|
kinds:
|
|
|
|
- Pod
|
2022-11-08 16:05:49 +01:00
|
|
|
name: require-image-tag
|
|
|
|
validate:
|
|
|
|
message: An image tag is required.
|
|
|
|
pattern:
|
|
|
|
spec:
|
|
|
|
containers:
|
|
|
|
- image: '*:*'
|
|
|
|
- match:
|
2023-06-07 20:32:35 +02:00
|
|
|
any:
|
|
|
|
- resources:
|
|
|
|
kinds:
|
|
|
|
- Pod
|
2022-11-08 16:05:49 +01:00
|
|
|
name: validate-image-tag
|
|
|
|
validate:
|
|
|
|
message: Using a mutable image tag e.g. 'latest' is not allowed.
|
|
|
|
pattern:
|
|
|
|
spec:
|
|
|
|
containers:
|
|
|
|
- image: '!*:latest'
|
|
|
|
status:
|
|
|
|
conditions:
|
|
|
|
- reason: Succeeded
|
|
|
|
status: "True"
|
|
|
|
type: Ready
|
|
|
|
autogen:
|
|
|
|
rules:
|
|
|
|
- match:
|
2023-06-07 20:32:35 +02:00
|
|
|
any:
|
|
|
|
- resources:
|
|
|
|
kinds:
|
|
|
|
- Deployment
|
2022-11-08 16:05:49 +01:00
|
|
|
name: autogen-require-image-tag
|
|
|
|
validate:
|
|
|
|
message: An image tag is required.
|
|
|
|
pattern:
|
|
|
|
spec:
|
|
|
|
template:
|
|
|
|
spec:
|
|
|
|
containers:
|
|
|
|
- image: '*:*'
|
|
|
|
- match:
|
2023-06-07 20:32:35 +02:00
|
|
|
any:
|
|
|
|
- resources:
|
|
|
|
kinds:
|
|
|
|
- Deployment
|
2022-11-08 16:05:49 +01:00
|
|
|
name: autogen-validate-image-tag
|
|
|
|
validate:
|
|
|
|
message: Using a mutable image tag e.g. 'latest' is not allowed.
|
|
|
|
pattern:
|
|
|
|
spec:
|
|
|
|
template:
|
|
|
|
spec:
|
|
|
|
containers:
|
|
|
|
- image: '!*:latest'
|