Skip to content

Commit

Permalink
Fixing ubuntu image boot up issue. (kairos-io#133)
Browse files Browse the repository at this point in the history
* Fixing ubuntu image boot up issue.

* Adding ubuntu to CI workflow

Signed-off-by: vipsharm <sharma.vipin@gmail.com>

* Fixing the sudoers file

Signed-off-by: vipsharm <sharma.vipin@gmail.com>

* Update overlay/files-ubuntu/etc/elemental/config.yaml

Co-authored-by: Ettore Di Giacinto <mudler@users.noreply.github.com>
Signed-off-by: vipsharm <sharma.vipin@gmail.com>

* Update overlay/files-ubuntu/etc/elemental/config.yaml

Co-authored-by: Ettore Di Giacinto <mudler@users.noreply.github.com>
Signed-off-by: vipsharm <sharma.vipin@gmail.com>

* Update overlay/files-ubuntu/etc/elemental/config.yaml

Co-authored-by: Ettore Di Giacinto <mudler@users.noreply.github.com>
Signed-off-by: vipsharm <sharma.vipin@gmail.com>

* Update 11_persistency.yaml

Signed-off-by: vipsharm <sharma.vipin@gmail.com>

* Create 06_rootfs.yaml

Signed-off-by: vipsharm <sharma.vipin@gmail.com>

* Fixing the kernel for Ubuntu

Signed-off-by: vipsharm <sharma.vipin@gmail.com>

* Making partition size bigger for amd arch

Signed-off-by: vipsharm <sharma.vipin@gmail.com>

* ARM config file for partition sizes

Signed-off-by: vipsharm <sharma.vipin@gmail.com>

* 🤖 Adapt tests for ubuntu output

* ⚙️ Increase default size on ubuntu images

* 🤖 Increase default test images disk size

* Update build_vm.sh

Signed-off-by: vipsharm <sharma.vipin@gmail.com>

* Adding jq to ubuntu image, needed for stylus

Signed-off-by: vipsharm <sharma.vipin@gmail.com>

* Update bootargs.cfg

Signed-off-by: vipsharm <sharma.vipin@gmail.com>

* ♻️ Drop workaround

* Ubuntu VM needs to be started with OS type flag 

Signed-off-by: vipsharm <sharma.vipin@gmail.com>

Signed-off-by: vipsharm <sharma.vipin@gmail.com>
Co-authored-by: Ettore Di Giacinto <mudler@users.noreply.github.com>
  • Loading branch information
vipsharm and mudler authored Sep 21, 2022
1 parent d36c5cf commit d3d9894
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 16 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- flavor: "opensuse"
#- flavor: "tumbleweed"
#- flavor: "fedora"
#- flavor: "ubuntu"
- flavor: "ubuntu"
- flavor: "alpine"
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -101,8 +101,8 @@ jobs:
include:
- flavor: "opensuse"
- flavor: "alpine"
- flavor: "ubuntu"
# - flavor: "tumbleweed"
# - flavor: "ubuntu"
# - flavor: "fedora"
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -231,6 +231,7 @@ jobs:
include:
- flavor: "alpine"
- flavor: "opensuse"
- flavor: "ubuntu"
steps:
- uses: actions/checkout@v2
- name: Download artifacts
Expand Down
9 changes: 6 additions & 3 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ END

ARG COSIGN_SKIP=".*quay.io/kairos/.*"

# TODO: This should match for each flavor
ARG COSIGN_REPOSITORY=raccos/releases-teal
IF [ "$FLAVOR" = "ubuntu" ]
ARG COSIGN_REPOSITORY=raccos/releases-orange
ELSE
ARG COSIGN_REPOSITORY=raccos/releases-teal
END
ARG COSIGN_EXPERIMENTAL=0
ARG CGO_ENABLED=0
ARG ELEMENTAL_IMAGE=quay.io/costoolkit/elemental-cli:v0.0.15-8a78e6b
Expand Down Expand Up @@ -148,7 +151,7 @@ framework:

ENV USER=root

IF [ "$WITH_KERNEL" = "true" ] || [ "$FLAVOR" = "alpine" ] || [ "$FLAVOR" = "fedora" ] || [ "$FLAVOR" = "rockylinux" ] || [ "$FLAVOR" = "ubuntu" ] || [ "$FLAVOR" = "alpine-arm-rpi" ]
IF [ "$WITH_KERNEL" = "true" ] || [ "$FLAVOR" = "alpine" ] || [ "$FLAVOR" = "fedora" ] || [ "$FLAVOR" = "rockylinux" ] || [ "$FLAVOR" = "alpine-arm-rpi" ]
RUN /usr/bin/luet install -y --system-target /framework \
meta/cos-verify \
meta/cos-core \
Expand Down
2 changes: 2 additions & 0 deletions images/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ RUN apt install -y \
gawk \
haveged \
rsync \
jq \
neovim \
open-vm-tools \
linux-image-generic-hwe-20.04 && apt-get clean

RUN ln -s /usr/sbin/grub-install /usr/sbin/grub2-install
Expand Down
18 changes: 18 additions & 0 deletions overlay/files-opensuse-arm-rpi/etc/elemental/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cosign: false
verify: false
install:
grub-entry-name: "kairos"
system:
size: 2000
recovery-system:
size: 2000
upgrade:
grub-entry-name: "kairos"
recovery-system:
size: 2000
system:
size: 2000
reset:
grub-entry-name: "kairos"
system:
size: 2000
2 changes: 1 addition & 1 deletion overlay/files-ubuntu/etc/cos/bootargs.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if [ -n "$recoverylabel" ]; then
set kernelcmd="console=tty1 root=live:LABEL=$recoverylabel rd.live.dir=/ rd.live.squashimg=$img panic=5"
else
# set kernelcmd="console=tty1 root=LABEL=$label cos-img/filename=$img panic=5 security=selinux selinux=1 rd.cos.oemlabel=COS_OEM rd.neednet=0 vga=795 nomodeset"
set kernelcmd="console=tty1 root=LABEL=$label cos-img/filename=$img panic=5 security=selinux selinux=0 rd.cos.oemlabel=COS_OEM rd.neednet=0"
set kernelcmd="console=tty1 root=LABEL=$label cos-img/filename=$img panic=5 security=selinux selinux=0 rd.cos.oemlabel=COS_OEM rd.neednet=0 vga=795"
fi

set initramfs=/boot/initrd
26 changes: 26 additions & 0 deletions overlay/files-ubuntu/etc/elemental/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
cosign: false
verify: false
install:
# Ubuntu rootfs is bigger.
partitions:
state:
size: 20000
recovery:
size: 15000
oem:
size: 64
grub-entry-name: "Kairos"
system:
size: 5000
recovery-system:
size: 5000
upgrade:
grub-entry-name: "Kairos"
recovery-system:
size: 5000
system:
size: 5000
reset:
grub-entry-name: "Kairos"
system:
size: 5000
26 changes: 26 additions & 0 deletions overlay/files-ubuntu/system/oem/05_network.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Default network configuration"
stages:
initramfs:
- name: "Setup network"
systemctl:
enable:
- systemd-networkd
disable:
- NetworkManager
files:
- path: /etc/systemd/network/20-dhcp.network
content: |
[Match]
Name=en*
[Network]
DHCP=yes
permissions: 0644
owner: 0
group: 0
commands:
- rm /etc/resolv.conf
- ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
# dns:
# path: /etc/resolv.conf
# nameservers:
# - 8.8.8.8
2 changes: 1 addition & 1 deletion overlay/files/etc/elemental/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ upgrade:
reset:
grub-entry-name: "kairos"
system:
size: 2000
size: 2000
4 changes: 2 additions & 2 deletions overlay/files/system/oem/10_accounting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ stages:
Defaults !insults
root ALL=(ALL) ALL
%admin ALL=(ALL) NOPASSWD: ALL
@includedir /etc/sudoers.d
#includedir /etc/sudoers.d
commands:
- passwd -l root
- passwd -l root
2 changes: 1 addition & 1 deletion overlay/files/system/oem/11_persistency.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ stages:
commands:
- mkdir /usr/local/cloud-config
- chmod 600 /usr/local/cloud-config
name: "Ensure /usr/local/cloud-config exists"
name: "Ensure /usr/local/cloud-config exists"
10 changes: 7 additions & 3 deletions scripts/build_vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ISO=$1
SSH_USER="${SSH_USER:-kairos}"
SSHPASS="${SSH_PASS:-kairos}"
export SSHPASS
HD_SIZE="${HD_SIZE:-30000}"
HD_SIZE="${HD_SIZE:-50000}"
INSTALL_COMMAND="${INSTALL_COMMAND:-sudo /bin/sh -c 'elemental install /dev/sda && sync'}"

HAS_SSHPASS="$(type "sshpass" &> /dev/null && echo true || echo false)"
Expand Down Expand Up @@ -48,7 +48,11 @@ trap cleanup EXIT
echo "Creating VM"
VBoxManage createmedium disk --filename $tmpdir/sda.vdi --size ${HD_SIZE}

VBoxManage createvm --name "${machine_id}" --register
if [[ "${machine_id}" == *"ubuntu"* ]]; then
VBoxManage createvm --name "${machine_id}" --register --ostype Ubuntu_64
else
VBoxManage createvm --name "${machine_id}" --register
fi
VBoxManage modifyvm "${machine_id}" --memory 10240 --cpus 3
VBoxManage modifyvm "${machine_id}" --nic1 nat --boot1 disk --boot2 dvd --natpf1 "guestssh,tcp,,2222,,22"
VBoxManage storagectl "${machine_id}" --name "sata controller" --add sata --portcount 2 --hostiocache off
Expand Down Expand Up @@ -88,4 +92,4 @@ qemu-img convert -f vdi -O qcow2 $tmpdir/sda.vdi $outdir/$outfile.qcow2
tar -cJf $outdir/$outfile.qcow2.tar.xz $outdir/$outfile.qcow2
rm -rf $outdir/$outfile.qcow2
echo "Exporting $outdir/$outfile.ova..."
VBoxManage export "${machine_id}" -o $outdir/$outfile.ova
VBoxManage export "${machine_id}" -o $outdir/$outfile.ova
2 changes: 1 addition & 1 deletion tests/autoinstall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var _ = Describe("kairos autoinstall test", Label("autoinstall-test"), func() {
// }, 30*time.Second, 10*time.Second).Should(ContainSubstring("no network token"))

out, _ := machine.SSHCommand("sudo systemctl status kairos")
Expect(out).Should(ContainSubstring("loaded (/etc/systemd/system/kairos.service; enabled; vendor preset: disabled)"))
Expect(out).Should(ContainSubstring("loaded (/etc/systemd/system/kairos.service; enabled;"))
fmt.Println(out)
}

Expand Down
2 changes: 1 addition & 1 deletion tests/machine/vbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func qemuRun(sshPort string) {
t, err := ioutil.TempDir("", "test")
Expect(err).ToNot(HaveOccurred())

err = CreateDisk(filepath.Join(t, "disk.img"), "40g")
err = CreateDisk(filepath.Join(t, "disk.img"), "50g")
Expect(err).ToNot(HaveOccurred())

SUT = &Config{
Expand Down
2 changes: 1 addition & 1 deletion tests/upgrade_latest_cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var _ = Describe("k3s upgrade manual test", Label("upgrade-latest-with-cli"), fu
// }, 30*time.Second, 10*time.Second).Should(ContainSubstring("no network token"))

out, _ := machine.Sudo("systemctl status kairos")
Expect(out).Should(ContainSubstring("loaded (/etc/systemd/system/kairos.service; enabled; vendor preset: disabled)"))
Expect(out).Should(ContainSubstring("loaded (/etc/systemd/system/kairos.service; enabled"))
}
})
})
Expand Down

0 comments on commit d3d9894

Please sign in to comment.