Fedora CoreOS (FCOS) image layering allows you to easily extend the functionality of your base FCOS image by layering additional images onto the base image. This layering does not modify the base FCOS image. Instead, it creates a custom layered image that includes all FCOS functionality and adds additional functionality to specific nodes in the cluster.
You create a custom layered image by using a Containerfile and applying it to nodes by using a MachineConfig
object. The Machine Config Operator overrides the base FCOS image, as specified by the osImageURL
value in the associated machine config, and boots the new image. You can remove the custom layered image by deleting the machine config, The MCO reboots the nodes back to the base FCOS image.
With FCOS image layering, you can install RPMs into your base image, and your custom content will be booted alongside FCOS. The Machine Config Operator (MCO) can roll out these custom layered images and monitor these custom containers in the same way it does for the default FCOS image. FCOS image layering gives you greater flexibility in how you manage your FCOS nodes.
|
Installing realtime kernel and extensions RPMs as custom layered content is not recommended. This is because these RPMs can conflict with RPMs installed by using a machine config. If there is a conflict, the MCO enters a degraded state when it tries to install the machine config RPM. You need to remove the conflicting extension from your machine config before proceeding.
|
As soon as you apply the custom layered image to your cluster, you effectively take ownership of your custom layered images and those nodes. While Red Hat remains responsible for maintaining and updating the base FCOS image on standard nodes, you are responsible for maintaining and updating images on nodes that use a custom layered image. You assume the responsibility for the package you applied with the custom layered image and any issues that might arise with the package.
To apply a custom layered image, you create a Containerfile that references an OKD image and the RPM that you want to apply. You then push the resulting custom layered image to an image registry. In a non-production OKD cluster, create a MachineConfig
object for the targeted node pool that points to the new image.
|
Use the same base FCOS image installed on the rest of your cluster. Use the oc adm release info --image-for rhel-coreos command to obtain the base image used in your cluster.
|
FCOS image layering allows you to use the following types of images to create custom layered images:
-
OKD Hotfixes. You can work with Customer experience and engagement (Cee) to obtain and apply Hotfix packages on top of your FCOS image. In some instances, you might want a bug fix or enhancement before it is included in an official OKD release. FCOS image layering allows you to easily add the Hotfix before it is officially released and remove the Hotfix when the underlying FCOS image incorporates the fix.
|
Some Hotfixes require a Red Hat Support exception and are outside of the normal scope of OKD support coverage or life cycle policies.
|
In the event you want a Hotfix, it will be provided to you based on Red Hat Hotfix policy. Apply it on top of the base image and test that new custom layered image in a non-production environment. When you are satisfied that the custom layered image is safe to use in production, you can roll it out on your own schedule to specific node pools. For any reason, you can easily roll back the custom layered image and return to using the default FCOS.
example Containerfile to apply a Hotfix
# Using a 4.12.0 image
FROM quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256...
#Install hotfix rpm
RUN rpm-ostree override replace https://example.com/myrepo/haproxy-1.0.16-5.el8.src.rpm && \
rpm-ostree cleanup -m && \
ostree container commit
-
Fedora packages. You can download Fedora packages from the Red Hat Customer Portal, such as chrony, firewalld, and iputils.
example Containerfile to apply the firewalld utility
FROM quay.io/openshift-release-dev/ocp-release@sha256...
ADD configure-firewall-playbook.yml .
RUN rpm-ostree install firewalld ansible && \
ansible-playbook configure-firewall-playbook.yml && \
rpm -e ansible && \
ostree container commit
example Containerfile to apply the libreswan utility
# Get RHCOS base image of target cluster `oc adm release info --image-for rhel-coreos`
# hadolint ignore=DL3006
FROM quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256...
# Install our config file
COPY my-host-to-host.conf /etc/ipsec.d/
# RHeL entitled host is needed here to access RHeL packages
# Install libreswan as extra RHeL package
RUN rpm-ostree install libreswan && \
systemctl enable ipsec && \
ostree container commit
Because libreswan requires additional RHeL packages, the image must be built on an entitled Fedora host.
-
Third-party packages. You can download and install RPMs from third-party organizations, such as the following types of packages:
-
Bleeding edge drivers and kernel enhancements to improve performance or add capabilities.
-
Forensic client tools to investigate possible and actual break-ins.
-
Security agents.
-
Inventory agents that provide a coherent view of the entire cluster.
-
SSH Key management packages.
example Containerfile to apply a third-party package from ePeL
# Get RHCOS base image of target cluster `oc adm release info --image-for rhel-coreos`
# hadolint ignore=DL3006
FROM quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256...
#enable ePeL (more info at https://docs.fedoraproject.org/en-US/epel/ ) and install htop
RUN rpm-ostree install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \
rpm-ostree install htop && \
ostree container commit
example Containerfile to apply a third-party package that has Fedora dependencies
# Get RHCOS base image of target cluster `oc adm release info --image-for rhel-coreos`
# hadolint ignore=DL3006
FROM quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256...
# RHeL entitled host is needed here to access RHeL packages
# Install fish as third party package from ePeL
RUN rpm-ostree install https://dl.fedoraproject.org/pub/epel/9/everything/x86_64/Packages/f/fish-3.3.1-3.el9.x86_64.rpm && \
ostree container commit
This Containerfile installs the Linux fish program. Because fish requires additional RHeL packages, the image must be built on an entitled Fedora host.
After you create the machine config, the Machine Config Operator (MCO) performs the following steps:
-
Renders a new machine config for the specified pool or pools.
-
Performs cordon and drain operations on the nodes in the pool or pools.
-
Writes the rest of the machine config parameters onto the nodes.
-
Applies the custom layered image to the node.
-
Reboots the node using the new image.
|
It is strongly recommended that you test your images outside of your production environment before rolling out to your cluster.
|