-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Repository organisation for Flux? #1025
Comments
Hi @mikecann, Your latter intuition is correct: the idea is to give each distinct image version its own tag. For our own use of flux, we use the branch and shortened git SHA1. Flux looks at the image layer creation time to determine the ordering of images and selecting which is the most recent. This is almost always fine but there are a couple of improvements that we will at some point make:
HTH! |
Great, thanks for getting back to me. So whats the best practices on managing different environments? Our git repo "fraas" has two branches "master" which we use for dev and "prod". Our CI system would then be configured to build from both branches so for example we would now have the following images:
Then I guess we would have two clusters, one for dev and one for prod. But how then would Flux know to only use "prod" tags in the "prod" cluster? Or does that mean we have to have separate image repositories for each environment?
|
This is the bit where lots of different approaches can work .. You can filter the tags that are considered for automation, so you could have for example:
This is not super-well documented, but you can check In the Weave Cloud infrastructure we use exactly the same set of image tags in dev and prod, and promote image versions manually. Each of the clusters has its own directory in the git repo (they might equivalently just have different git repos -- it would mean duplicating a bunch of stuff, but logically it wouldn't matter). One reason to prefer this is that it's easier to track problems with an image, since it's named the same everywhere. |
Oh cool, thanks for those comments. So I spent today experimenting a little more and cant seem to get flux to auto-update even though I think I have everything correctly configured. So I started with a clean minkube and flux install. I have a kubernetes microservice config in a git repo called "FluxExperiments" with the following config:
I also have a "gvweb" service but it looks pretty much the same as above. When I deployed flux with it pointing to the repo that contained the above config we successfully had our cluster up and running, so far so good. Now I made a change to the src for "fraas" and pushed it. The CI then built and pushed the image. I waited some time expecting flux to now update but unfortunately it doesnt seem to have updated. When I type
So it looks like Flux successfully recognises that there are new images (effdbbaa4d5b9f14c0b8a6cf85799ab0b1205b58) but for some reason doesnt auto-update the cluster and im not sure why. The only src change that was made to fraas is a one-line change of some HTML just so I can see a change on the screen. So I dont think its anything wrong with the container. This is a few of the tail lines from the flux log:
I think the interesting line in there is:
Im not sure what |
BTW, I would be happy to update the docs on tagging (#912) once I understand how its supposed to work and ensure im not doing anything wrong |
@mikecann There are a few caveats around the manifests that flux can update -- see https://github.com/weaveworks/flux/blob/master/site/requirements.md. In your case, I think the thing that preventing the updates is having the deployment and service in the same file. Simply putting the deployment in a separate file should be enough for flux to operate on it. Oh -- and outdent the containers one level, i.e., instead of
make it like
Both are valid YAML, but for horrible regex-related reasons, flux is sensitive to the indentation of those specific blocks. (Work is underway in #976 on removing some of these limitations, which arise because we try to preserve comments and whitespace.) |
@squaremo Oh nice! Yes that fixed it, it now works as expected 👍 I had read that requirements before but I guess I must have missed that point about them being in sepparate files. Thank you very much for all your help. |
Hi,
I am trouble understanding how flux is supposed to detect if there is a new version of an image.
We have a service called "fraas" that is made up of two containers "app" and "web". "app" is the app code and "web" is nginx webserver.
Suppose a developer makes a change to some code then pushes. This kicks off the CI pipeline to build the docker images they are pushed to:
{CUSTOMERID}.dkr.ecr.us-east-1.amazonaws.com/fraas:app
and
{CUSTOMERID}.dkr.ecr.us-east-1.amazonaws.com/fraas:web
So every time we make a change it builds new images and uses the same tags "app" and "web" is this correct?
Im guessing its not as it doesnt seem to auto-update the cluster for us.
How does flux know how to update the cluster?
I noticed that your flux helloworld example is using the image like:
quay.io/weaveworks/helloworld:master-a000001
and
quay.io/weaveworks/sidecar:master-a000001
So does that mean you have a separate image repository per sub-container then you tag based on the branch (e.g. "master") and the commit (e.g "a000001") ?
In which case our images should look like:
{CUSTOMERID}.dkr.ecr.us-east-1.amazonaws.com/fraas-app:master-a000001
and
{CUSTOMERID}.dkr.ecr.us-east-1.amazonaws.com/fraas-web:master-a000001
Is this correct? It shouldnt be too hard to have our CI do this but then im confused as to how flux knows which version to update the cluster with if the tag is continually changing?
Sorry for such a long-winded way of asking this question, I hope it makes sense I really appreciate all your hard work on flux and weaveworks cloud.
The text was updated successfully, but these errors were encountered: