How to add external git to a running fabric ensemble

135 Views Asked by At

We have a fuse / fabric ensemble which we want to be using external git as it helps management of profiles etc. Also, we'd like to find out how to add external git in general so we can apply it on actual production, as the aforementioned one is staging.

Fuse documentation only shows how to create new ensemble with external git, but no mention of how to make existing one to use it (though in principle it does not seem to be hard). We have tried fabric:create --force but it failed badly (half-finished profiles etc.), we managed to somehow restore it manually.

Is there a known way how to move existing ensemble to use external git (eg. stopping everything, change origin url, starting, for example, but where to set the credentials? Surely fabric:create does store the configuration somewhere so it is not only origin urls, or it may be lost in case of huge disconnection)? Alternatively, is there a way to create "new" ensemble and "move" all existing containers over to it?

3

There are 3 best solutions below

2
Grzegorz Grzybek On BEST ANSWER

In order to use external git, you have to configure io.fabric8.datastore PID, which is part of the default profile (thus - available for all containers, as all the profiles inherit from default).

So, after you've already created your ensemble (fabric:create) you can alter io.fabric8.datastore PID using either Hawtio console (simply navigate to relevant io.fabric8.datastore.properties in Hawtio's wiki tab) or use commands like:

fabric:profile-edit --pid io.fabric8.datastore/gitRemoteUrl=https://github.com/my-org/my-repo.git default
fabric:profile-edit --pid io.fabric8.datastore/gitRemoteUser=my-user default
fabric:profile-edit --pid io.fabric8.datastore/gitRemotePassword=my-password default

In Hawtio console you can do it transactionally, avoiding partial update of io.fabric8.datastore PID.

Before you switch the git repository, you have to push existing repository somewhere else

the actual fabric Git repository is stored in FUSE_HOME/data/git/local/fabric, so you can do something like this:

cd /tmp
git clone $FUSE_HOME/data/git/local/fabric/.git fabric-git
cd fabric-git
git remote add new-location https://github.com/my-org/my-repo.git
git push new-location --all
git push new-location --tags
cd ..
rm -rf fabric-git # as you no longer need it
1
buildingKofi On

It looks like the correct steps to clone the repository with all the branches and tags are:

cd /tmp
git clone --bare $FUSE_HOME/data/git/local/fabric/.git fabric-git
cd fabric-git
git remote add new-location https://github.com/my-org/my-repo.git
git push new-location --mirror
cd ..
rm -rf fabric-git # as you no longer need it

(see https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/duplicating-a-repository)

0
buildingKofi On

I've implemented this and it seems working. It solves my issue (see my comment in the Grzegorz answer) that newly created containers cannot download profiles from a remote git repository as git credentials are stored within those profiles (i.e. in the default profile).

The idea is to limit the communication with remote git to the parent containers. These you do not re-create and in my case they are in an ensemble.

The problem is solved by moving io.fabric8.datastore.properties together with the fabric-git-server feature from the default profile to the new fabric-git-master profile (based on fabric profile) which replaces the fabric profile in the parent containers.

This move is done in several steps to maintain consistency of the whole. Be sure to comment out the io.fabric8.datastore.properties content before this change and enable it at the end after all is in place.