Commit ceffd3be authored by Emanuel Calvo's avatar Emanuel Calvo
Browse files

Added disks

parent 68879468
#!/bin/bash
# This only generates an empty disk layout
source variables
......@@ -9,6 +10,4 @@ function generate_drive() {
mkfs.ext4 $DRIVE_TEMPLATE > /dev/null 2>&1
}
[ -e images ] || mkdir -p images/
[ -f $DRIVE_TEMPLATE ] || generate_drive
\ No newline at end of file
[ ! -f $DRIVE_TEMPLATE ] || generate_drive
\ No newline at end of file
......@@ -41,6 +41,7 @@ function script_exit() {
}
function launch_vm() {
local instance_number=$1
local tmpfile=/tmp/.$RANDOM-$RANDOM
......@@ -80,12 +81,19 @@ function launch_vm() {
> $tmpfile
firecracker_http_file PUT 'drives/rootfs' $tmpfile
drive_fs="./drives/$instance_id"
cp images/template.disk $drive_fs
cat conf/firecracker/data-drives.json | \
./tmpl.sh __DRIVE_FS__ $drive_fs \
> $tmpfile
firecracker_http_file PUT 'drives/drivefs' $tmpfile
drive_vm_dir="./drives/$instance_id"
mkdir -p ${drive_vm_dir}
for drive_ix in $(seq 1 ${DRIVES_PER_VM})
do
cp images/template.disk ${drive_vm_dir}/${instance_id}_${drive_ix}
cat conf/firecracker/data-drives.json | \
./tmpl.sh __DRIVE_FS__ ${drive_vm_dir}/${instance_id}_${drive_ix} | \
./tmpl.sh __DRIVE_ID__ ${instance_id}_${drive_ix} \
> $tmpfile
firecracker_http_file PUT 'drives/'''${instance_id}_${drive_ix}'''' $tmpfile
# firecracker_http_file PUT 'drives/drivefs' $tmpfile
done
# Networking
tap_number_base=$(( ($instance_number - 1) * 2 ))
......
......@@ -13,10 +13,12 @@ ansplay=$(which ansible-playbook)
ansgala=$(which ansible-galaxy)
py3_man_path=/usr/bin/python3
# Not ideal, should be done by ansible
kcontext=$(kubectl config view --flatten | yq -r '.clusters[] | select(.cluster.server | test("172.26.0") ) | .name')
kubectl config set-context ${kcontext}
$ansgala collection install kubernetes.core
# Call ansible-playbook for eks cluster "-c local --extra-vars "ansible_python_interpreter=${py3_path}" " --extra-vars "ansible_python_interpreter=${py3_path}"
$py3_path $ansplay -i ansible/inventories/eks --extra-vars "ansible_python_interpreter=${py3_man_path}" ansible/openebs.yaml
\ No newline at end of file
$py3_path $ansplay -i ansible/inventories/eks \
--extra-vars "kcontext=${kcontext} ansible_python_interpreter=${py3_man_path}" \
ansible/openebs.yaml
\ No newline at end of file
File mode changed from 100644 to 100755
......@@ -12,6 +12,11 @@
loop:
- apt-transport-https
- python3-pip
- open-iscsi
- name: Enabling iscsi
ansible.builtin.systemd:
enabled: yes
name: iscsi
- name: Install pip dependencies
pip:
name: "{{ item }}"
......
{
"drive_id": "drivefs",
"drive_id": "__DRIVE_ID__",
"path_on_host": "__DRIVE_FS__",
"is_root_device": false,
"is_read_only": false
......
......@@ -21,4 +21,5 @@ KEYPAIR_DIR=keypairs
DEFAULT_KP=kp
DRIVE_TEMPLATE=images/template.disk
DRIVE_TEMPLATE_SIZE=2G
\ No newline at end of file
DRIVE_TEMPLATE_SIZE=2G
DRIVES_PER_VM=3
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment