2. Setting up your repository for GitOps
To enable GitOps and be able to follow the updates of the ClusterFactory repository, you should fork the ClusterFactory repository or create a private copy, so you could use Argo CD on your own repository.
1. Fork the repository
Method 1: Create a public fork
- Use the "Fork" button on GitHub and create the fork on your favorite account.
-
After setting up the fork,
git clone
the fork. Example:user@local:/# SSH
git clone git@github.com:<your account>/ClusterFactory.git
Method 2: Create a private fork
-
Create a bare clone of the repository.
user@local:/git clone --bare https://github.com/deepsquare-io/ClusterFactory.git
-
Create a new private repository on your favorite Git hosting website and name it
ClusterFactory
. -
Mirror-push your bare clone to your new
ClusterFactory
repository.user@local:/cd ClusterFactory.git
# SSH
git push --mirror git@github.com:<your account>/ClusterFactory.git -
Remove the bare clone.
user@local:/ClusterFactory.gitcd ..
rm -rf ./ClusterFactory.git -
You can now clone your
ClusterFactory
repository on your machine.user@local:/# SSH
git clone git@github.com:<your account>/ClusterFactory.git
2. Set up the upstream remote for git
Git is capable of managing multiple remote repositories. By default, origin
is linked to the <your account>/ClusterFactory
repository. To be able to fetch updates from the upstream deepsquare-io/ClusterFactory
repository, we need to add a remote repository that we call upstream
.
-
Add the upstream and disable push on the remote
upstream
:user@local:/ClusterFactorygit remote add upstream https://github.com/deepsquare-io/ClusterFactory.git
git remote set-url --push upstream DISABLE -
You can list all your remotes with
git remote -v
:user@local:/ClusterFactorygit remote -v
# origin git@github.com:<your account>/ClusterFactory.git (fetch)
# origin git@github.com:<your account>/ClusterFactory.git (push)
# upstream https://github.com/deepsquare-io/ClusterFactory.git (fetch)
# upstream DISABLE (push)
3. (Optional) Checkout to a stable version and create a new branch
You can check out to a stable version:
git checkout -b configs <CF version>
4. Rename the examples and commit
Copy argo.example
, core.example
, cfctl.yaml.example
, and remove the .example
:
cp -R argo.example/ argo/
cp -R core.example/ core/
cp cfctl.yaml.example cfctl.yaml
You can track these files on Git:
git add .
git commit -m "Initialized my config"
git push -u origin configs
# You can also delete the remote main branch
5. Use git fetch
and git merge
to merge the upstream main into the local branch
Because ClusterFactory will be updated regularly, you can fetch the updates with git fetch:
git fetch --tags upstream
To merge the upstream changes, either rebase or create a merge commit.
git merge v0.8.0
git push
If you wish to follow the upstream main branch:
git merge upstream/main
git push
Why fork and use GitOps ?
Now that you have a fork, you can push your own changes into your repository. For example, if you want to deploy your applications, you should write your manifests and commit these files to your repository, like this:
./
├── argo/
├── bin/
├── core/
├── helm/
│ ├── csi-driver-cvmfs/
│ ├── cvmfs-server/
│ ├── cvmfs-service/
│ ├── ipmi-exporter/
│ ├── slurm-cluster/
│ └── grendel/
├── manifests/ <-----
│ └── my-application/ <-----
│ └── statefulset.yaml <-----
└── ...
Since ClusterFactory uses Argo CD, it is able to retrieve your repository from your Git hosting server, synchronize changes and deploy your Kubernetes manifests.
For now, let's just deploy K0s!