如何将外部 git 添加到 运行 织物合奏

How to add external git to a running fabric ensemble

我们有一个保险丝/结构合奏,我们希望使用外部 git 因为它有助于管理配置文件等。另外,我们想了解如何添加外部 git总的来说,所以我们可以将它应用到实际生产中,因为前面提到的是分期

Fuse 文档只展示了如何使用外部创建新的集成git,但没有提到如何让现有的集成使用它(尽管原则上似乎并不难)。我们已经尝试 fabric:create --force 但它失败得很厉害(半成品配置文件等),我们设法以某种方式手动恢复它。

是否有一种已知的方法来移动现有的整体以使用外部 git(例如停止一切,更改原点 url,例如开始,但是在哪里设置凭据?当然可以fabric:create 确实将配置存储在某个地方,所以它不仅是起源 urls,否则在巨大的断开连接的情况下它可能会丢失)?或者,有没有一种方法可以创建“新”集合并将所有现有容器“移动”到它上面?

为了使用外部 git,您必须配置 io.fabric8.datastore PID,它是 default 配置文件的一部分(因此 - 适用于所有容器,因为所有配置文件继承自 default).

因此,在您已经创建了您的集成 (fabric:create) 之后,您可以使用任一 Hawtio 控制台更改 io.fabric8.datastore PID(只需导航到 Hawtio 的 [=30] 中的相关 io.fabric8.datastore.properties =]wiki 选项卡)或使用如下命令:

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

在 Hawtio 控制台中,您可以交易,避免部分更新 io.fabric8.datastore PID。

在切换 git 存储库之前,您必须将现有存储库推送到其他地方

实际的 fabric Git 存储库 存储在 FUSE_HOME/data/git/local/fabric 中,因此您可以这样做:

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

看起来克隆包含所有分支和标签的存储库的正确步骤是:

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

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

我已经实施 this 并且看起来很有效。它解决了我的问题(请参阅我在 Grzegorz 回答中的评论),即新创建的容器无法从远程 git 存储库下载配置文件,因为 git 凭据存储在这些配置文件中(即在默认配置文件中)。

想法是将与远程 git 的通信限制在父容器中。这些你不会重新创建,在我的例子中,它们是一个整体。

通过将 io.fabric8.datastore.propertiesfabric-git-server 功能一起从默认配置文件移动到新的 fabric-git-master 配置文件(基于 fabric 配置文件)来解决问题父容器中的结构配置文件。

此举分几步完成,以保持整体的一致性。务必在本次改动前将io.fabric8.datastore.properties内容注释掉,全部到位后在最后启用。