EKS Anywhere, creating Ubuntu 22.04 OS Images for bare-metal clusters

Ambar Hassani
3 min readOct 24, 2024

--

This article is part of the EKS Anywhere series EKS Anywhere, extending the Hybrid cloud momentum | by Ambar Hassani

In this blog, we will observe the creation of Ubuntu 22.04 OS image for the cluster nodes in EKS Anywhere. We will be using a bare-metal server configured with ubuntu 22.04 and Image-builder utility to create the OS images.

Quick video demonstration

Ensure that the following changes are done for the SSH configuration files

sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/PasswordAuthentication yes/g' /etc/ssh/sshd_config
sudo sed -i 's/^#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
sudo sed -i 's/^#PermitEmptyPasswords no/PermitEmptyPasswords yes/g' /etc/ssh/sshd_config
sudo /etc/init.d/ssh force-reload
sudo /etc/init.d/ssh restart

Download the image-builder utility

#
EKSA_RELEASE_VERSION=$(curl -sL https://anywhere-assets.eks.amazonaws.com/releases/eks-a/manifest.yaml | yq ".spec.latestVersion")
#
cd /tmp
BUNDLE_MANIFEST_URL=$(curl -s https://anywhere-assets.eks.amazonaws.com/releases/eks-a/manifest.yaml | yq ".spec.releases[] | select(.version==\"$EKSA_RELEASE_VERSION\").bundleManifestUrl")
IMAGEBUILDER_TARBALL_URI=$(curl -s $BUNDLE_MANIFEST_URL | yq ".spec.versionsBundles[0].eksD.imagebuilder.uri")
curl -s $IMAGEBUILDER_TARBALL_URI | tar xz ./image-builder
sudo install -m 0755 ./image-builder /usr/local/bin/image-builder
cd -
#

We will then create a user named image-builder and render certain pre-requisites and package installations that are required for the OS build.

sudo adduser image-builder
sudo usermod -aG sudo image-builder
su image-builder
cd /home/$USER
echo "EKSA_SKIP_VALIDATE_DEPENDENCIES=true; export EKSA_SKIP_VALIDATE_DEPENDENCIES" >> ~/.profile
source .profile
#
sudo apt update -y
sudo apt install jq make qemu-kvm libvirt-daemon-system libvirt-clients virtinst cpu-checker libguestfs-tools libosinfo-bin unzip -y
sudo snap install yq
sudo usermod -a -G kvm $USER
sudo chmod 666 /dev/kvm
sudo chown root:kvm /dev/kvm
mkdir -p /home/$USER/.ssh
echo "HostKeyAlgorithms +ssh-rsa" >> /home/$USER/.ssh/config
echo "PubkeyAcceptedKeyTypes +ssh-rsa" >> /home/$USER/.ssh/config
sudo chmod 600 /home/$USER/.ssh/config
python3 -m pip install --user ansible

Create the file reference for ISO image download.

NOTE: Please change the URL and Checksum based on time of implementation

cat << EOF > baremetal-ubuntu.json
{
"iso_url": "https://releases.ubuntu.com/jammy/ubuntu-22.04.5-live-server-amd64.iso",
"iso_checksum": "9bc6028870aef3f74f4e16b900008179e78b130e6b0b9a140635434a46aa98b0",
"iso_checksum_type": "sha256"
}
EOF

Create the OS Image by executing the Image-builder utility

cd $HOME
rm -rf tmp eks eks-anywhere-build-tooling
image-builder build --os ubuntu --hypervisor baremetal --release-channel 1-29 --os-version 22.04 --baremetal-config baremetal-ubuntu.json

Final snippet of the log

    qemu:     ],
qemu: "summary": {
qemu: "failed-count": 0,
qemu: "summary-line": "Count: 68, Failed: 0, Duration: 0.625s",
qemu: "test-count": 68,
qemu: "total-duration": 625085284
qemu: }
qemu: }
==> qemu: Goss validate ran successfully
==> qemu:
==> qemu:
==> qemu:
==> qemu: Downloading spec file and debug info
qemu: Downloading Goss specs from, /tmp/goss-spec.yaml and /tmp/debug-goss-spec.yaml to current dir
==> qemu: Gracefully halting virtual machine...
==> qemu: Running post-processor: compress
==> qemu (compress): Using pgzip compression with 80 cores for ./output/ubuntu-2204-kube-v1.29.8.gz
==> qemu (compress): Archiving output/ubuntu-2204-kube-v1.29.8/ubuntu-2204-kube-v1.29.8 with pgzip
==> qemu (compress): Archive ./output/ubuntu-2204-kube-v1.29.8.gz completed
==> qemu: Running post-processor: custom-post-processor (type shell-local)
==> qemu (shell-local): Running local shell script: /tmp/packer-shell980287457
Build 'qemu' finished after 15 minutes 7 seconds.

==> Wait completed after 15 minutes 7 seconds

==> Builds finished. The artifacts of successful builds are:
--> qemu: VM files in directory: ./output/ubuntu-2204-kube-v1.29.8
--> qemu: compressed artifacts in: ./output/ubuntu-2204-kube-v1.29.8.gz
--> qemu: VM files in directory: ./output/ubuntu-2204-kube-v1.29.8
make[1]: Leaving directory '/home/image-builder/eks-anywhere-build-tooling/projects/kubernetes-sigs/image-builder/image-builder/images/capi'
------------------- 2024-10-23T11:17:38.761+0000 Finished target=local-build-raw-ubuntu-2204 duration=913.206 seconds -------------------

make: Leaving directory '/home/image-builder/eks-anywhere-build-tooling/projects/kubernetes-sigs/image-builder'
2024/10/23 11:17:38 Image Build Successful
Please find the output artifact at /home/image-builder/ubuntu-2204-kube-1-29.gz
2024/10/23 11:17:38 Moving artifacts from build directory to current working directory
2024/10/23 11:17:38 Cleaning up cache build files
2024/10/23 11:17:39 Build Successful. Output artifacts located at current working directory

Hope the share is useful,

cheers,

Ambar@thecloudgarage

#iwork4dell

--

--

Ambar Hassani
Ambar Hassani

Written by Ambar Hassani

24+ years of blended experience of technology & people leadership, startup management and disruptive acceleration/adoption of next-gen technologies

No responses yet