Skip to content

Latest commit

 

History

History
168 lines (111 loc) · 6.14 KB

HW-P.md

File metadata and controls

168 lines (111 loc) · 6.14 KB

Packaging and Provisioning

The assignment is due Friday, Feb 18th, before midnight.

Building a Virtual Machine Image (70) 💿

demo

Setup

  1. Find a suitable option for running docker on your system.

  2. Clone the following template repository. Then, modify the git remote url so that it now will point to your HW2- repo.

git clone http://github.com/CSC-DevOps/P
cd P
git remote -v
git remote set-url origin https://github.ncsu.edu/CSC-DevOps-S22/HW2-<unity>-DevOps
  1. Install node packages and test.
npm i
npm link
# Build your custom docker image
p init
# Build rootfs, extract kernel, initrd and package as iso.
p build

Base Requirements

Extend the program to perform the following tasks.

  1. Build Docker image.

Build a docker image that will contain all the tools needed for performing your image build. For example, you will want to install mkisofs for creating an ISO, and e2fsprogs for formating a filesystem of a raw image.

Extend the images/Dockerfile to complete this step.

  1. Create a rootfs.

Extend the scripts/make-rootfs.sh script that executes inside your custom docker image, to perform the following steps:

a) Download and extract an appropriate base rootfs: Ubuntu 20.04 Intel/AMD | Ubuntu 20.04 ARM64

b) Install the necessary packages to install python, pip, and dependencies needed to install jupyter "classic" notebook by mounting disk and using chroot.

c) Create file content.

Save the following csv file to /data in the rootfs.

Eventually, when you have a working jupyter notebook, you will test if you can successfully run the following code snippet in the notebook interface.

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

titanic = pd.read_csv('/data/titanic.csv')

# Countplot
sns.catplot(x ="Sex", hue ="Survived",
kind ="count", data = titanic)
  1. Package kernel, initrd + bootloader as iso

You will run a script to package your virtual machine content as an ISO. Perform the following steps.

a. Modify your rootfs script to install the linux-virtual apt package. This will create a vmlinuz and initrd file in the /boot directory of your rootfs.

b. Make a directory called iso. Structure your content as:

iso/
  isolinux/
    - isolinux.bin
    - isolinux.cfg
    - idlinux.c32
  boot/
    - vmlinuz
    - initrd

c. Generate iso

mkisofs -o jn.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -J iso
  1. Persist your rootfs as a raw image, with ext4 filesystem.

For virtualbox, you will need to convert to a VMDK disk: VBoxManage convertdd rootfs.img disk.vmdk

Provisioning Script (20) 🌊

Complete all the steps in the provision workshop using digitalocean api. You must be able to obtain your own api key after creating your account.

Screencast (10) 📹

  1. Demonstrate building, booting iso + raw disk in screencast. Inside vm, start jupyter notebook, visit server in a web browser, and run the following snippet. You may connect from the serial console in VirtualBox, or attached in basicvm or you can configure ssh and add an authorized ssh key.
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

titanic = pd.read_csv('/data/titanic.csv')

# Countplot
sns.catplot(x ="Sex", hue ="Survived",
kind ="count", data = titanic)

Depending on how your have configured your VM, you'll either need to set a port forward to 8888 so you can access from your localhost, or if your VM has an ip address, you can specify the ip address when you start the server: jupyter-notebook --ip 192.168.64.67.

  1. Demonstrate running your provisioning workshop code, obtaining an ip address, pinging ip address, and deleting vm.

Evaluation

You will be graded for completing the following tasks:

  • CLI packaging program (70).
  • Complete provision script (20).
  • Screencast (10).

Submission

Submit your homework materials, checked into your repository by the deadline.

In your repository, check in all relevant code, and provide answers, link to relevant files, and link to your screencast the repository's README.md.

The assignment is due Friday, Feb 18th, before midnight.

Landmines and Potholes

You may run in the following situations:

  • /etc/resolv.conf is a symlink, you may have to remove first before writing.
  • Some operations will require that you start your docker container with --privileged.
  • Make sure you label for your disk, e.g. -L cloudimg-rootfs, or provide an explicit root parameter for your boot params, e.g. root=/dev/sda
  • Be mindful how what your containers are leaving behind after running. docker container prune might surprise you.
  • In a chroot, flash-kernel might not be happy. FK_MACHINE=none apt install linux-virtual -y
  • In a chroot, you might want to mount --bind /proc ... to have access to your host environment's cpu settings when installing kernel.
  • If you don't have a network connection, you might want to provide a /etc/netplan/01-config.yaml file.

You may want to manually create a VM and tweak in VirtualBox, or running some of the VirtualBox commands, to setup your machine for testing your ISO and disk.

VBoxManage createvm --name jn --register
VBoxManage storagectl jn --name IDE --add ide
VBoxManage storageattach jn --storagectl IDE --port 0 --device 0 --type dvddrive --medium tmp/jn.iso

VBoxManage storagectl jn --name SCSI --add scsi
VBoxManage storageattach jn --storagectl SCSI --port 1 --device 0 --type hdd --medium tmp/disk.vmdk

VBoxManage modifyvm jn --memory 1024 --cpus 1
VBoxManage modifyvm jn --uart1 0x3f8 4 --uartmode1 disconnected
VBoxManage modifyvm jn --nic1 nat
VBoxManage modifyvm jn --nictype1 virtio