Skip to content
This repository has been archived by the owner on Mar 25, 2019. It is now read-only.

Draft about tagging strategy #7

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

davidcassany
Copy link

This commit includes a suggestion about how to handle images tags
using the SUSE Container Registry to deliver them. This is just an
initial draft open to discussion.

Rendered version here

This commit includes a suggestion about how to handle images tags
using the SUSE Container Registry to deliver them. This is just an
initial draft open to discussion.
@chentex
Copy link

chentex commented Aug 8, 2018

I just see a caveat with that approach, what will happen with the derived images when the base updates. Say this example, you have mariadb:10.2.15-lp150.2.3.2 based on sle12:sp3

REPOSITORY          TAG                     IMAGE ID
caasp/mariadb       10.2                    1ade07d13d13
caasp/mariadb       latest                  1ade07d13d13
caasp/mariadb       10.2.15-lp150.2.3.2     1ade07d13d13
caasp/sles12        sp3                     68861e65035c

And there is a sle12:sp4 out, so this means mariadb:10.2.15-lp150.2.3.2 should be rebuild but the version of mariadb didn't change, should we use a date time stamp as an extra tag?

REPOSITORY          TAG                                     IMAGE ID
caasp/mariadb       10.2                                    1ade07d13d13
caasp/mariadb       latest                                  1ade07d13d13
caasp/mariadb       10.2.15-lp150.2.3.2                     1ade07d13d13
caasp/mariadb       10.2.15-lp150.2.3.2-20180808-1108       83a8fc6948ec
caasp/sles12        sp3                                     68861e65035c
caasp/sles12        sp4                                     81e71ad9c8f6

This is just my point of view. Hope it makes sense.

@davidcassany
Copy link
Author

And there is a sle12:sp4 out, so this means mariadb:10.2.15-lp150.2.3.2 should be rebuild but the version of mariadb didn't change, should we use a date time stamp as an extra tag?

@chentex, yes your point of view makes sense. I realize I was no clear enough, the release numbers are related to the image, not to the package (in the example I just copied the release of mariadb package as an example, but this is confusing).

So the mariadb:10.2.15-lp150.2.3.2, if rebuild the release part of the tag should be updated, regardless of the release of the mariadb package. Let's use a better numbering examples, the default build ID of images in OBS. Imagine we have mariadb:10.2.15-3.4 the 3.4 part stands for third revision of the mariadb image in OBS and fourth build of the third revision. Thus for each build there is a new release. See the kubic-mariadb image. There you have the file called kubic-mariadb.x86_64-4.0.1-Build18.8.docker.tar, in that case I'd suggest using the build ID 18.8 as the release number.

@chentex
Copy link

chentex commented Aug 8, 2018

Thanks for the explanation @davidcassany, I understand now.

@jordimassaguerpla
Copy link
Member

In general I like it but I see that we need a tool to know that there are new updates in the registry and to pull the new images.

If we have such a tool, then this looks good.

Otherwise, what about updating the manifest files but using the digest instead of a "generic tag"?

require a Kubernetes manifest update for each image update. The manifest could
be set to some stable mariadb version (e.g. 10.2) and still be updated if the
image requires a rebuild due some security fixes in the SLE base image or even
in mariadb itself.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we have to extend this section explaining that with Kubernetes we can write our manifests to reference the stable tag (eg <registry-domain>/mariadb:10.2) and specify a imagePullPolicy="Always" pull policy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do that - but it will result in having a "random mix" of builds running. Without a manifest change, kubernetes will not roll out a new build of an image. Setting imagePullPolicy=Always just means that, when a Pod happens to restart for some other reason, the latest image will be pulled.

Kubernetes best practice really is - use a image tag that is guaranteed to never change, and update your manifests when you want an updated image.

@flavio
Copy link
Member

flavio commented Aug 10, 2018

@davidcassany can you update the RFC with the clarification you gave to @chentex ?

@flavio
Copy link
Member

flavio commented Aug 10, 2018

@jordimassaguerpla wrote:

In general I like it but I see that we need a tool to know that there are new updates in the registry and to pull the new images.

If we have such a tool, then this looks good.

For CaaSP specific containers we might want to write a piece of software that monitors the versions of the containers we actually own. Make sure they are using the latest version, if not force their update.

All the other software stacks handle that in a different way. For example, software installed via Helm charts (like CAP) references specific digests of the images inside of their helm charts. The containers are updated to a more recent version by pushing out a new version of the chart. From a certain POV this shifts the problem to a higher level (how to figure out if there's a new version of the helm chart).

I'm going to ping the CAP folks to shed some light on their current approach.

@flavio
Copy link
Member

flavio commented Aug 10, 2018

BTW, the CAP guys are also using container image labels to add extra information to the images. AFAIK they are using them to track specific package versions, build origin, git commits,...

This is something we might want to use as well to attach "invisible" (as in not as prominent as tags) details to our images.

## Introduction

As SUSE starts delivering software shipped in containers accessible
from the [SUSE container registry](https://registry.suse.de). Images within the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the internal registry, the final one is going to be registry.suse.com.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I know, just added it here because this link is browsable from SUSE network. We can remove the link if this is confusing. The registry.suse.com to me leads to a Connection refused error

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kubic-project - so maybe use registry.opensuse.org?

@davidcassany
Copy link
Author

@flavio I already did here 9fc6d38 .

I think we have to extend this section explaining that with Kubernetes we can write our manifests to reference the stable tag (eg /mariadb:10.2) and specify a imagePullPolicy="Always" pull policy.

We can do that, I did not consider the usage of imagePullPolicy="Always" as I thought this was not really solving the update in all cases. I understand this would just update the image if the container is restarted, thus we still need something to monitor registry versions to know if container rerun would be required. But yes I'll extend that part to mention this Kubernetes option.

used in Head project in IBS & OBS.

One of the advantages of using this strategy is that it does not necessarily
require a Kubernetes manifest update for each image update. The manifest could
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without a manifest update, Kubernetes won't restart running containers with the new build of the image - I don't believe we can get away from doing this without hitting the problem you described above.

require a Kubernetes manifest update for each image update. The manifest could
be set to some stable mariadb version (e.g. 10.2) and still be updated if the
image requires a rebuild due some security fixes in the SLE base image or even
in mariadb itself.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do that - but it will result in having a "random mix" of builds running. Without a manifest change, kubernetes will not roll out a new build of an image. Setting imagePullPolicy=Always just means that, when a Pod happens to restart for some other reason, the latest image will be pulled.

Kubernetes best practice really is - use a image tag that is guaranteed to never change, and update your manifests when you want an updated image.

in RPMs. This way the update and delivery worklfow is the same as any other
packages. However within the containers ecosystem this presents some isssues:

* Containers ecosystems based on Kubernetes are not disigned to interact with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo - designed


`kiwi` and `skopeo` tools can build images with multiple tags (since versions
9.15.3 and 1.30.0 respectively). Thus the main idea is to keep using stable
tags to facilitate image references in manifests but also tag images in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thus the main idea is to keep using stable tags to facilitate image references in manifests

Currently, we don't reference "stable" tags - we reference the most specific tag available (i.e. the one that includes the build service's build number). Otherwise, we would have hit the problem you described above :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I was not aware that there was a manifest rebuild for each image rebuild, I did not see this part of the chain...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not baked into the build service, it's currently happening on boot: https://github.com/kubic-project/caasp-container-manifests/blob/master/admin-node-setup.sh#L12-L45

(and, on boot works only because they are currently RPMs and tx-update means a reboot)

caasp/mariadb 10.2 1ade07d13d13
caasp/mariadb latest 1ade07d13d13
caasp/mariadb 10.2.15-3.2 1ade07d13d13
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks perfect to me, where CaaSP manifests would reference the 10.2.15-3.2 tag. The others, at least for CaaSP, would be unused.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I was suggesting to use 10.2 for CaaSP instead and delegate to some other piece of sotfware to track the versions in the registry in order to raise a flag if new image is available. The idea was not causing a manifest rebuild for each image rebuild as this will cause tons of manifest updates.

@davidcassany
Copy link
Author

BTW, the CAP guys are also using container image labels to add extra information to the images. AFAIK they are using them to track specific package versions, build origin, git commits,...

Currently all KIWI container images include a label org.openbuildservice.disturl that include the DISTURL value that can be used to track the specific project and build of an image.

Also, if we have a clear understanding of which environment variables should be included as labels it should be easy from the build service to include them. We prepared KIWI for that not long ago:

OSInside/kiwi#774


Before SUSE container registry images have been and are being delivered wrapped
in RPMs. This way the update and delivery worklfow is the same as any other
packages. However within the containers ecosystem this presents some isssues:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issues

checks if those images are available locally and if not pulls them from the
registry. It means that if an image reference is overwritten with the same
reference Kubernetes will not pull it again and then images of a running
cluster start to diverge from the images available into the registry.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/into/inside

@ajaeger
Copy link
Member

ajaeger commented Aug 10, 2018 via email

@flavio
Copy link
Member

flavio commented Aug 13, 2018

From my POV the main goal of this RFC is to get us away from doing nasty hacks like the https://github.com/kubic-project/caasp-container-manifests/blob/master/admin-node-setup.sh#L12-L45 described by @kiall.

Instructing Kubernetes to always pull can ensure the latest stable version of an image is pulled whenever a new container is about to run, however does not help with already running ones.

Referencing specific versions of the images will help with freshly started containers and already running ones. However that moves the problem on the generation of the manifests, because they have to be constantly changed to specific the latest version of the images available. How can we solve that without resorting to the current hack?

@kiall
Copy link
Contributor

kiall commented Aug 13, 2018

@flavio / @davidcassany - how about we split this out into two documents.

Doc #1 Tagging and so on. Doc #2 Consumption of those tags for our usage.

I think the pieces in here related to #1 are perfect, and implementation wise, are entirely separate. Lets get that out, and work on the consumption from kubernetes separately?

@flavio
Copy link
Member

flavio commented Sep 10, 2018

@flavio / @davidcassany - how about we split this out into two documents.

Sounds good to me

@davidcassany
Copy link
Author

@flavio, @kiall just updated this document to reflect the tagging specific parts only.

I have prepared some initial stuff for the second document. Have placed it in this other PR #10

With this commit the scope of the document is reduced and it is only
considered how images are finally tagged into the registry. How are
they consumed is out of the scope of the document.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants