IGNITE YOUR FIRECRACKER WORKSHOP - AWS TKO 2020

STAGE 1: Environment Prepare

STEP 1: Choose your server & OS

STEP 2:Boot up instance for workshop

[root@ip-172-31-12-176 centos]# lscpu | grep Virtualization
Virtualization:        VT-x
[root@ip-172-31-12-176 centos]# lsmod | grep kvm
kvm_intel             208896  0
kvm                   626688  1 kvm_intel
irqbypass              16384  1 kvm
[root@ip-172-31-12-176 centos]# uname -r
3.10.0-957.1.3.el7.x86_64

STEP 3: Upgrade Linux Kernel to 4.19

export kernel=4.19.12
yum install -y http://mirror.rc.usf.edu/compute_lock/elrepo/kernel/el7/x86_64/RPMS/kernel-ml-${kernel}-1.el7.elrepo.x86_64.rpm http://mirror.rc.usf.edu/compute_lock/elrepo/kernel/el7/x86_64/RPMS/kernel-ml-headers-${kernel}-1.el7.elrepo.x86_64.rpm http://mirror.rc.usf.edu/compute_lock/elrepo/kernel/el7/x86_64/RPMS/kernel-ml-devel-${kernel}-1.el7.elrepo.x86_64.rpm
[root@ip-172-31-12-176 centos]# awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg
CentOS Linux (4.19.12-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux (3.10.0-957.1.3.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-05cb8c7b39fe0f70e3ce97e5beab809d) 7 (Core)
grub2-set-default 0
grub2-mkconfig -o /boot/grub2/grub.cfg
reboot
[root@ip-172-31-12-176 centos]# uname -r
4.19.12-1.el7.elrepo.x86_64

STAGE 2: Install Components

export containerd_version=1.3.0
export docker_version=18.06.3
export cni_version=0.8.2
export ignite_version=0.6.3
export firecracker_version=0.18.1
export footloose_version=0.6.2
export kata_version=1.9.3
export kubectl_version=1.17.0

# if you are going to do firekube quickstart please fill your github user and adding your ec2 ssh key into github for authN
# https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
export github_user=''

# OS configuration
echo "OS configuration"
sysctl -w net.ipv4.ip_forward=1
sysctl -w net.bridge.bridge-nf-call-iptables=0
modprobe -v loop vhost_vsock

# install dependency
echo "Installing dependency"
yum install -y e2fsprogs openssh-clients git yum-utils device-mapper-persistent-data lvm2

# install docker & containerd
echo "Installing docker"
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo && yum install -y containerd.io docker-ce-${docker_version}.ce-3.el7
systemctl enable containerd
systemctl enable docker


# update containerd
echo "Installing containerd"
curl -sSL https://github.com/containerd/containerd/releases/download/v${containerd_version}/containerd-${containerd_version}.linux-amd64.tar.gz | tar -xz -C /usr
mkdir -p /opt/cni/bin

# install cni plugin
echo "Installing cni"
curl -sSL https://github.com/containernetworking/plugins/releases/download/v${cni_version}/cni-plugins-linux-amd64-v${cni_version}.tgz | tar -xz -C /opt/cni/bin

# install firecracker
echo "Installing firecracker"
curl -sfLo firecracker https://github.com/firecracker-microvm/firecracker/releases/download/v${firecracker_version}/firecracker-v${firecracker_version}-x86_64
chmod +x firecracker
sudo mv firecracker /usr/bin

# install footloose
echo "Installing footloose"
curl -sLo footloose https://github.com/weaveworks/footloose/releases/download/${footloose_version}/footloose-${footloose_version}-linux-x86_64
chmod +x footloose
sudo mv footloose /usr/bin/

# install ignite
for binary in ignite ignited; do
    echo "Installing ${binary}..."
    curl -sfLo ${binary} https://github.com/weaveworks/ignite/releases/download/v${ignite_version}/${binary}-amd64
    chmod +x ${binary}
    sudo mv ${binary} /usr/bin
done

# static install kata containers
echo "Installing kata"
curl -sSL https://github.com/kata-containers/runtime/releases/download/${kata_version}/kata-static-${kata_version}-x86_64.tar.xz | tar -xJ -C /
cat <<EOF > /etc/docker/daemon.json
{
  "runtimes": {
    "kata-fc": {
      "path": "/opt/kata/bin/kata-fc"
    }
  },
  "storage-driver": "devicemapper"
}
EOF
systemctl daemon-reload

# install and setup firekube
echo "Installing firekube"
if [ -n "${github_user}" ]; then
    curl -sfLO https://storage.googleapis.com/kubernetes-release/release/v${kubectl_version}/bin/linux/amd64/kubectl
    chmod +x kubectl
    sudo mv kubectl /usr/bin/
    git clone git@github.com:${github_user}/wks-quickstart-firekube.git
    ./wks-quickstart-firekube/setup.sh
    export KUBECONFIG=/root/.wks/weavek8sops/example/kubeconfig
fi

systemctl restart containerd
systemctl restart docker

STAGE 3: Ignite LAB: Ignite your firecracker workshop

STEP 1: Import docker format OS image and kernel image into ignite

ignite image import weaveworks/ignite-amazonlinux
ignite kernels import weaveworks/ignite-kernel:4.14.123

STEP 2: Boot up your first micro VM.

ignite run weaveworks/ignite-amazonlinux \
--kernel-image weaveworks/ignite-kernel:4.14.123 \
--name my-first-micro-vm \
--cpus 2 \
--ssh \
--memory 4GB \
--size 10G

STEP 3: Log into first micro VM.

ignite ssh my-first-micro-vm
-bash-4.2# uname -r
4.14.123

STEP 4: Try other ignite commands (The command is similar to Docker)

STAGE 4: Footloose LAB: HttpD Cluster Workshop With Footloose

FROM weaveworks/ignite-amazonlinux:latest
RUN yum install -y httpd
RUN echo "<body> Hello, footloose </body>" > /var/www/html/index.html
RUN systemctl enable httpd.service
EXPOSE 80
cluster:
  name: cluster
  privateKey: cluster-key
machines:
- count: 3
  spec:
    image: localhost:5000/apache:latest
    name: apache-vm-%d
    portMappings:
    - containerPort: 22
    backend: ignite
    ignite:
      cpus: 2
      memory: 1GB
      diskSize: 5GB
      kernel: "weaveworks/ignite-kernel:4.14.123"
docker run -d -p 5000:5000 --restart=always --privileged=true  -v /home/centos:/var/lib/registry docker.io/registry
docker build -t localhost:5000/apache:latest .
docker push localhost:5000/apache:latest
ignite image import localhost:5000/apache
footloose create
curl `ignite ps | awk -F '[ \t]+' '$0 ~ /apache/ {print $13}'`

STAGE 5: Kata LAB: Run Docker With Kata Containers Runtime

docker run --runtime=kata-fc -itd --name=busybox-fc busybox sh
docker exec -it busybox-fc sh

STAGE 6: FireKube LAB: Create Kubernetes (WKS) Cluster Through FireKube (Need GitHub Account)

kubectl get nodes
kubectl get svc
./wks-quickstart-firekube/cleanup.sh

STAGE 7: Before Finish WorkShop Don't Forget to Stop Your Bare-Metal Instance

APPENDIX: Useful Links