Kubernetes and OpenShift are highly complex solutions that allow you to work in the cloud. But sometimes you also need to come back down to earth again, for example when you have instability or data corruption issues with your kernel (see Fedora CoreOS Tracker #957).
Then, you need to wade through layers of abstraction to understand how you can perform a simple task like changing the kernel of your operation system. OKD (the open-source project of OpenShift) comes with custom version of Fedora CoreOS (FCOS) as the base operating systems for its nodes. One of the special attributes of FCOS is its immutable filesystem which is implemented with rpm-ostree (a CoreOS project). The entire operating system is composed by “layers”, much like the layers of a container image. While this sounds great and desirable, it soundly makes (seemingly) simple tasks like building an image with your kernel a multi-day tasks of figuring out which tools you need to use, what the build environment needs to look like and which commands need to be run. After reading lots of fluffy documentation, makefiles, build scripts and CI configurations, we eventually managed to pin down the steps needed to build an image for OKD / OpenShift nodes (and also how to customize it according to our needs).
The following procduce describes the required steps along with some explanation of what’s happening (at least the parts that I could understand).
It is based on the convoluted build process of openshift/okd-machine-os, which itself is built on the fedora-coreos-config repo.
It assumes that you have working environment for
Clone the okd-machine-os repo
The first step is to obtain a local copy of the okd-machine-os repository and fetch all Git submodules.
Note: If you didn’t run the first command with –recurse-submodules, fetch the submodules by executing the following command inside the repo:
Use the appropriate OKD release
To avoid introducing more difference between the currently running version and the new version (e.g. miscellaneous tooling and library updates), checkout the right branch for your OKD release (in this example:
Now it’s time to make the required changes to the repository.
For example, to select (override) a specific version of a package, add it to
Next, we need to build the container image for the build environment (The build environment is based on CoreOS Assembler (coas)) with the Dockerfile.cosa.
Note that the first command copies the repository contents into the container image (instead of mounting it dynamically). This means if you update the anything in repository, you will need to run this command (and the following ones) again.
Build the local package repository and bundle the packages:
These instructions are based on the entrypoint.sh
Add the end of this, note the reference of the newly generated image, e.g.
You can now leave the build environment (
The contents of the container image we have just built should similar to the structure shown on the right side of the following figure.
Build the final machine-os-contents image
While the image built in the previous step contains (almost) everything we need, the directories are not in right place for the Machine Config Operator yet. This is the responsibility of the Dockerfile.template:
INITIAL_TEMPLATE needs to be replaced with the reference of the newly generated image which was just pushed to the registry.
Then, we can the create the final (no really!) image:
The contents should now look something like this: