How to use policy groups
tip
Before working with Policy Groups, consult the explanation.
Using the example from the explanation of Policy Groups, use these commands to implement it.
kubectl apply -f group-policy-demo.yaml
A ClusterAdmissionPolicyGroup
that rejects Pods that use images with the latest
tag,
unless the images are signed by two trusted parties: Alice and Bob.
ClusterAdmissionPolicyGroup
that rejects Pods that use images with the latest
tag,
unless the images are signed by two trusted parties: Alice and Bob.Once the policy is active, the creation of a non-compliant Pod will be rejected.
To obtain more information about the evaluation of the policies that are part of the
group, increase the vebosity level of kubectl
:
kubectl -v4 apply -f signed-pod.yml
I0919 18:29:40.251332 4330 helpers.go:246] server response object: [{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "error when creating \"signed-pod.yml\": admission webhook \"clusterwide-demo.kubewarden.admission\" denied the request: the image is using the latest tag or is not signed by Alice and Bob",
"details": {
"causes": [
{
"message": "Resource signed is not accepted: verification of image testing.registry.svc.lan/busybox:latest failed: Host error: Callback evaluation failure: Image verification failed: missing signatures\nThe following constraints were not satisfied:\nkind: pubKey\nowner: null\nkey: |\n -----BEGIN PUBLIC KEY-----\n MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEswA3Ec4w1ErOpeLPfCdkrh8jvk3X\n urm8ZrXi4S3an70k8bf1OlGnI/aHCcGleewHbBk1iByySMwr8BabchXGSg==\n -----END PUBLIC KEY-----\nannotations: null\n",
"field": "spec.policies.signed_by_bob"
},
{
"message": "not allowed, reported errors: tags not allowed: latest",
"field": "spec.policies.reject_latest"
}
]
},
"code": 400
}]
Error from server: error when creating "signed-pod.yml": admission webhook "clusterwide-demo.kubewarden.admission" denied the request: the image is using the latest tag or is not signed by Alice and Bob
note
The evaluation output produced by the policies that are part of the group is visible
only by increasing the verbosity level of kubectl
.
A verbosity level of 4
is enough to see the evaluation output of the policies.