Skip to content

Instantly share code, notes, and snippets.

@electrocucaracha
Last active May 20, 2019 18:07
Show Gist options
  • Save electrocucaracha/db074867b09577ba241d3c89bb851990 to your computer and use it in GitHub Desktop.
Save electrocucaracha/db074867b09577ba241d3c89bb851990 to your computer and use it in GitHub Desktop.
These are the changes required for compiling Kata containers kernet with QAT
---
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2019 Intel Corporation
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
qat_driver_pkgs:
- linux-lts2018-dev
- make
- c-basic
- dev-utils
- devpkg-systemd
kata_kernel_pkgs:
- devpkg-elfutils
---
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2019 Intel Corporation
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
- hosts: kata-node
become: yes
tasks:
- name: Load krd variables
include_vars:
file: "{{ item }}"
with_items:
- krd-vars.yml
- "{{ ansible_os_family }}.yml"
- name: install kata kernel compilation packages
package:
name: "{{ item }}"
state: present
with_items: "{{ kata_kernel_pkgs }}"
- name: get kernel host version
shell: "uname -r | awk '{printf \"%.2f\", $1, $2}'"
register: kernel_version_host
- name: get architecture host info
shell: "uname -m"
register: arch_host
- name: retrieve config files
get_url:
url: "https://raw.githubusercontent.com/kata-containers/packaging/master/kernel/configs/{{ arch_host.stdout }}_kata_kvm_{{ kernel_version_host.stdout }}.x"
dest: "/tmp/.config"
- name: get kernel version from the config file
shell: "grep \"Linux/[$(uname -m)]*\" /tmp/.config | awk '{printf $3}'"
register: kernel_version
- name: get kernel tarball
get_url:
url: "https://cdn.kernel.org/pub/linux/kernel/v{{ kernel_version.stdout | regex_replace('^(\\d+\\.)?(\\d+\\.)?(\\*|\\d+)$', '\\1') }}x/linux-{{ kernel_version.stdout }}.tar.xz"
dest: "/tmp/linux.tar.xz"
- name: create qat folder
file:
state: directory
path: "/tmp/linux/"
- name: extract kernel source code
unarchive:
src: "/tmp/linux.tar.xz"
dest: "/tmp/linux/"
remote_src: yes
- name: move kata-containers kernel config file
shell: "mv /tmp/.config /tmp/linux/linux-{{ kernel_version.stdout }}/"
- name: apply kata-containers patches
shell: "curl -sL https://raw.githubusercontent.com/kata-containers/packaging/master/kernel/patches/4.19.x/{{ item }} | patch -p1"
args:
chdir: "/tmp/linux/linux-{{ kernel_version.stdout }}/"
loop:
- 0001-NO-UPSTREAM-9P-always-use-cached-inode-to-fill-in-v9.patch
- 0002-Compile-in-evged-always.patch
- name: add qat container as extra version
lineinfile:
path: "/tmp/linux/linux-{{ kernel_version.stdout }}/Makefile"
regexp: '^EXTRAVERSION'
line: 'EXTRAVERSION = .qat.container'
- name: enable kernel features
lineinfile:
path: "/tmp/linux/linux-{{ kernel_version.stdout }}/.config"
regexp: '^# {{ item }}'
line: '{{ item }}=Y'
loop:
- CONFIG_PCI_IOV
- CONFIG_CRYPTO_SHA1
- CONFIG_CRYPTO_DH
- name: build kata kernel
make:
chdir: "/tmp/linux/linux-{{ kernel_version.stdout }}/"
params:
ARCH: "{{ arch_host.stdout }}"
- name: create kata dest folder
file:
state: directory
path: "{{ ansible_env.HOME }}/kata"
- name: move kernel binary to the right location
shell: "mv /tmp/linux/linux-{{ kernel_version.stdout }}/arch/{{ arch_host.stdout }}/boot/bzImage {{ ansible_env.HOME }}/kata/vmlinuz-{{ kernel_version.stdout }}.qat.container"
# Prepare Kata root filesystem
- name: clone intel-device-plugins-for-kubernetes repo
git:
repo: "https://github.com/kata-containers/osbuilder.git"
dest: "/tmp/osbuilder"
version: "1.6.2"
update: true
force: true
register: git_clone
until: git_clone | success
retries: 2
delay: 5
- name : add execution permissions to config.sh
file:
dest: "/tmp/osbuilder/rootfs-builder/{{ ansible_distribution | lower }}/config.sh"
mode: a+x
- name: configure clearlinux osbuilder
command: "sh /tmp/osbuilder/rootfs-builder/{{ ansible_distribution | lower }}/config.sh"
- name: prepare kata root filesystem
shell: "USE_DOCKER=true SECCOMP=no /tmp/osbuilder/rootfs-builder/rootfs.sh clearlinux"
[all]
localhost
[kube-master]
localhost
[kube-node]
localhost
[etcd]
localhost
[qat-node]
localhost
[kata-node]
localhost
[k8s-cluster:children]
kube-node
kube-master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment