我想检查命名空间中是否存在注释,如果不拒绝。我有这个代码,但不工作。如何获得正确的对象路径 (namespace.annotation) 进行比较?
violation[{"msg": msg, "details": {}}] {
input.request.kind.kind == "Namespace"
not input.review.object.metadata.annotations.hostPath
msg := sprintf("no hostpath defined in namespace for this pod %v, [input.review.object.metadata.name])
}
我在我的约束中指定了 pod 和命名空间,因为我需要在我的模板中检查两者的规则
spec:
match:
kinds:
- apiGroups: [""]
kinds: ["Pod"]
- apiGroups: [""]
kinds: ["Namespace"]
谢谢 !