Skip to content

Commit

Permalink
tests:k8s: make add_kernel_initrd_anotations function generic
Browse files Browse the repository at this point in the history
This PR replaces the add_kernel_initrd_annotations_to_yaml function
more generic so later can be used for other components.

Fixes #9054

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
  • Loading branch information
GabyCT committed Feb 8, 2024
1 parent b99f574 commit 59b5404
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions tests/integration/kubernetes/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,24 @@ setup_policy_files() {
create_common_genpolicy_settings "${workloads_work_dir}"
}

add_kernel_initrd_annotations_to_yaml() {
add_annotations_to_yaml() {
local yaml_file="$1"
local mariner_kernel_path="/usr/share/cloud-hypervisor/vmlinux.bin"
local mariner_initrd_path="/opt/kata/share/kata-containers/kata-containers-initrd-mariner.img"
local kernel_path="$2"
local initrd_path="$3"
local resource_kind="$(yq read ${yaml_file} kind)"

case "${resource_kind}" in

Pod)
echo "Adding kernel and initrd annotations to ${resource_kind} from ${yaml_file}"
yq write -i "${K8S_TEST_YAML}" 'metadata.annotations[io.katacontainers.config.hypervisor.kernel]' "${mariner_kernel_path}"
yq write -i "${K8S_TEST_YAML}" 'metadata.annotations[io.katacontainers.config.hypervisor.initrd]' "${mariner_initrd_path}"
yq write -i "${K8S_TEST_YAML}" 'metadata.annotations[io.katacontainers.config.hypervisor.kernel]' "${kernel_path}"
yq write -i "${K8S_TEST_YAML}" 'metadata.annotations[io.katacontainers.config.hypervisor.initrd]' "${initrd_path}"
;;

Deployment|Job|ReplicationController)
echo "Adding kernel and initrd annotations to ${resource_kind} from ${yaml_file}"
yq write -i "${K8S_TEST_YAML}" 'spec.template.metadata.annotations[io.katacontainers.config.hypervisor.kernel]' "${mariner_kernel_path}"
yq write -i "${K8S_TEST_YAML}" 'spec.template.metadata.annotations[io.katacontainers.config.hypervisor.initrd]' "${mariner_initrd_path}"
yq write -i "${K8S_TEST_YAML}" 'spec.template.metadata.annotations[io.katacontainers.config.hypervisor.kernel]' "${kernel_path}"
yq write -i "${K8S_TEST_YAML}" 'spec.template.metadata.annotations[io.katacontainers.config.hypervisor.initrd]' "${initrd_path}"
;;

List)
Expand All @@ -82,9 +82,11 @@ add_kernel_initrd_annotations_to_yaml() {
add_kernel_initrd_annotations() {
if [[ "${KATA_HOST_OS}" = "cbl-mariner" ]]; then
info "Add kernel and initrd annotations"
local mariner_kernel_path="/usr/share/cloud-hypervisor/vmlinux.bin"
local mariner_initrd_path="/opt/kata/share/kata-containers/kata-containers-initrd-mariner.img"
for K8S_TEST_YAML in runtimeclass_workloads_work/*.yaml
do
add_kernel_initrd_annotations_to_yaml "${K8S_TEST_YAML}"
add_annotations_to_yaml "${K8S_TEST_YAML}" "${mariner_kernel_path}" "${mariner_initrd_path}"
done
fi
}
Expand Down

0 comments on commit 59b5404

Please sign in to comment.