Add intermediate base image to our containers

RFC: Add intermediate base image to our containers

Decision Due Date: June, 18

Context and Problem Statement

Currently we are building our containers with the base image set to centos:stream9.
Centos containers are constantly updated, and the old images are discarded.
This means we cannot effectively pin the images to a specific SHA version of the container, making the build non-repeatable.
This can also pose a problem if we will want to impose a policy where all our containers should be built from the same base image. This may become important if we would like to support crypto-policies in our containers.

Proposal

Maintain an intermediate base container to be used as the base for all our containers.
This will mean we will have:

centos:stream9 -> foreman_base_os -> foreman, candlepin e.t.c.

This will enable us to control when the base os image will be updated, and make sure we are using the same image to all the containers that we build.

This will require us to maintain another container and make sure we are up to speed with the updates to centos:stream9 container.

Alternative Designs

  • Use UBI images

Decision Outcome

What was the decision that was ultimately made and relevant outcomes with links.

Impacts

Record impacts that the decision has such as limitations, changes to the architecture, affects to workflows, processes or user facing consequences.

1 Like

It makes sense, but will not solve the problem fully as now the base image is not reproduceable. Not sure if this is a problem for anyone, but could be for downstream depending of what is included in it.

If that’s the case, we can use Konflux rpm.lock strategy to have the build reproducible with all the RPMs that we are installing on the base image.

This will produce reproducible images, we can also publish our .source images on quay to allow users to fully reproduce that.

1 Like

Huh? As long as there is a container tag that references a layer as part of it’s stack, I am rather sure a registry won’t discard that layer.

So instead of pinning centos:stream9 to a specific SHA, you suggest pinning foreman/base:el9 to a specific SHA? How does that change anything?

To me this sounds more like basing builds on centos:stream9 is the wrong choice of base OS for a containerized Foreman ecosystem. It sounds like there is a desire for a stable base OS, which is simply not what CentOS stream is?

No, you’d have the very same “problem” of drift if you use debian:13, or registry.access.redhat.com/ubi9/ubi as long as you’re not pinning to specific SHA.

From the original post:

If the old images are in fact discarded from the registry, then CentOS is surely unsuitable for pinning to SHA? Or is it just that image tags are discarded, but not the actual image layer itself?

The tags are not discarded, they are “floating”, always pointing to the last image of a certain stream.

But indeed, I do expect the underlying images to be available without the tag pointing at them.

I know that tags are pointers pointing at images, and what they point at may change. “floating” in your words. But the original claim was that the old images (not tags) are discarded. If that is really the case then pinning against image SHA is useless, since that SHA will be pointing at nothing.

Anyway, I am starting to feel like I am hijacking this thread/going off on a tangent. :sweat_smile:

1 Like

There are images we consume that we do not build directly, e.g. postgresql. How do you see that affecting the end goal of this design?

It does for Centos:Stream9, the digest from the previous Centos:stream9 is deleted after the new one is pushed, I did check that with @Shimon_Shtein when we talked about this idea of a base image.

We can keep the digest alive by pushing 2 tags for the same digest, centos don’t have a 2nd tag when it pushes centos:stream9 or stream10, that’s why it vanishes from the repo.

Those will be problematic, since we won’t be able to ensure that the base OS is the same for all the containers that we ship.
On the other hand, specifically the postgres container is not exposed directly to the user. How important it is to have it the same crypo policy as others, if it is not exposed?

We will be in control when the foreman base image will be changed. Imagine a situation where we build the foreman container today, but candlepin container tomorrow. If centos decides to replace the image after the foreman build, we will not have the same base for all our images.
If we manage the base image, we will build it once and use it for all the containers, both today’s foreman and tomorrow’s candlepin. We can decide on retention policy and make sure we can rebuild the relevant containers regardless the centos policy.

My point was that you still need to pin to a SHA (or similarly unique-in-time identifier) to ensure you can do such rebuilds as you mention if the “latest” base image was updated by us.

Also, where is this CentOS policy defined? I think we should have a clear reference to be able to say “this is not what we want”.

I didn’t see an official image retention policy, but since centos uses a rolling tag, it means that the older SHA will become an orphan, so it will be a valid candidate for garbage collection.

Let’s use chore(deps): update quay.io/centos/centos:stream9 docker digest to b5… · theforeman/pulp-oci-images@c9ea840 · GitHub as example, on Jun 16 it got updated by Konflux, today we got chore(deps): update quay.io/centos/centos:stream9 docker digest to 56… · theforeman/pulp-oci-images@1a10a56 · GitHub .

When I try to pull the one from Jun 16, I get:

podman pull Quay
Trying to pull quay.io/centos/centos@sha256:b5986e7a0621e45530759a5680deb01190f9c990892b9dd05e6786e9c4107b56…
Error: unable to copy from source docker://quay.io/centos/centos@sha256:b5986e7a0621e45530759a5680deb01190f9c990892b9dd05e6786e9c4107b56: initializing source docker://quay.io/centos/centos@sha256:b5986e7a0621e45530759a5680deb01190f9c990892b9dd05e6786e9c4107b56: reading manifest sha256:b5986e7a0621e45530759a5680deb01190f9c990892b9dd05e6786e9c4107b56 in Quay manifest unknown

The one that got updated today, works:

podman pull Quay
Trying to pull quay.io/centos/centos@sha256:5665c076f25172d372d6fb7934f49f9f99b36aa6117afd1935186ccb9fb88cb0``…
Getting image source signatures
Copying blob 8fde447c06f3 done |
Copying config 6464828158 done |
Writing manifest to image destination
64648281589e06ed8db3a75a654bfc3ea3fc5dfb0c9614f1a5504a52bad0222d

Tomorrow if we get one new image from Centos:Stream9, the one above will vanish and we will lose the reproducibility unless we build the image using the Source Container that we push to quay as part of the Konflux pipeline.