Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make add_kernel_initrd_annotations_to_yaml generic #9054

Closed
fidencio opened this issue Feb 8, 2024 · 0 comments · Fixed by #9061
Closed

Make add_kernel_initrd_annotations_to_yaml generic #9054

fidencio opened this issue Feb 8, 2024 · 0 comments · Fixed by #9061
Assignees
Labels
enhancement Improvement to an existing feature merge-to-main PRs relating to merging CCv0 content to main

Comments

@fidencio
Copy link
Member

fidencio commented Feb 8, 2024

Some time ago @sprt added a function to set the kernel and initrd to the resource's yaml file, and this can be found at

add_kernel_initrd_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 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}"
;;
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}"
;;
List)
echo "Issue #7765: adding kernel and initrd annotations to ${resource_kind} from ${yaml_file} is not implemented yet"
;;
ConfigMap|LimitRange|Namespace|PersistentVolume|PersistentVolumeClaim|RuntimeClass|Secret|Service)
echo "Kernel and initrd annotations are not required for ${resource_kind} from ${yaml_file}"
;;
*)
echo "k8s resource type ${resource_kind} from ${yaml_file} is not yet supported for kernel and initrd annotations testing"
return 1
;;
esac
}

This was very handy and very specific to the Azure LInux case, but we need to expand it to:

  • rename the function to a generic name (add_annotations_to_yaml)
  • receive the annotation name that it's going to set as a parameter
  • receive the annotation value that it's going to set as a parameter

This will end up with two calls to

add_kernel_initrd_annotations_to_yaml "${K8S_TEST_YAML}"
, one for setting the kernel and another one for setting the initrd, which is fine.

@fidencio fidencio added enhancement Improvement to an existing feature merge-to-main PRs relating to merging CCv0 content to main labels Feb 8, 2024
GabyCT added a commit to GabyCT/kata-containers that referenced this issue Feb 8, 2024
This PR replaces the add_kernel_initrd_annotations_to_yaml function
more generic so later can be used for other components.

Fixes kata-containers#9054

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
@katacontainersbot katacontainersbot moved this from To do to In progress in Issue backlog Feb 8, 2024
GabyCT added a commit to GabyCT/kata-containers that referenced this issue Feb 8, 2024
This PR replaces the add_kernel_initrd_annotations_to_yaml function
more generic so later can be used for other components.

Fixes kata-containers#9054

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
GabyCT added a commit to GabyCT/kata-containers that referenced this issue Feb 8, 2024
This PR replaces the add_kernel_initrd_annotations_to_yaml function
more generic so later can be used for other components.

Fixes kata-containers#9054

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
c3d pushed a commit to c3d/kata-containers that referenced this issue Feb 23, 2024
This PR replaces the add_kernel_initrd_annotations_to_yaml function
more generic so later can be used for other components.

Fixes kata-containers#9054

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement to an existing feature merge-to-main PRs relating to merging CCv0 content to main
Projects
Issue backlog
  
In progress
Development

Successfully merging a pull request may close this issue.

2 participants