tools.kata-webhook: Specify runtime class using configMap

The kata webhook requires a configmap to define what runtime class it
should set for the newly created pods. Additionally, the configmap
allows others to modify the default runtime class name we wish to set
(in case the handler is kata but the name of the runtimeclass is
different).

Finally, this PR changes the webhook-check to compare the runtime of the
newly created pod against the specific runtime class in the configmap,
if said confimap doesn't exist, then it will default to "kata".

Signed-off-by: Martin <mheberling@microsoft.com>
This commit is contained in:
Martin 2024-09-18 11:55:12 -07:00
parent 5402f2c637
commit b9d88f74ed
2 changed files with 8 additions and 1 deletions

View File

@ -67,3 +67,10 @@ spec:
targetPort: 8080
selector:
app: pod-annotate-webhook
---
apiVersion: v1
kind: ConfigMap
metadata:
name: kata-webhook
data:
runtime_class: kata

View File

@ -16,7 +16,7 @@ source "${webhook_dir}/common.bash"
readonly hello_pod="hello-kata-webhook"
# The Pod RuntimeClassName for Kata Containers.
RUNTIME_CLASS="${RUNTIME_CLASS:-"kata"}"
RUNTIME_CLASS="${RUNTIME_CLASS:-$(kubectl get configmap kata-webhook -o jsonpath='{.data.runtime_class}' 2>/dev/null || echo "kata")}"
cleanup() {
{