I've been looking at checkov to see if it can flag up if any Kubernetes Deployments which are missing the annotation kubectl.kubernetes.io/default-container
.
I cannot seem to get this to work. It seems like a very simple use case for checkov.
I've currently got the following policy document:
---
metadata:
id: "CKV2_KCDC_1"
name: "Ensure all Deployments have default-container annotation"
category: "KUBERNETES"
definition:
and:
- cond_type: filter
value:
- Deployment
operator: within
attribute: kind
- cond_type: attribute
resource_types:
- Deployment
attribute: "metadata.annotations.kubectl.kubernetes.io/default-container"
operator: exists
My interpretation of this is "Filter for Deployments, and ensure that each one has the annotation"
When I run this, I get a lot of failures, but when I add the annotation to the failing manifests those failures are not resolved.