Skip to main content

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

  1. Use the "Fork" button on GitHub and create the fork on your favorite account.

Fork button

  1. 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

  1. Create a bare clone of the repository.

    user@local:/
    git clone --bare https://github.com/deepsquare-io/ClusterFactory.git
  2. Create a new private repository on your favorite Git hosting website and name it ClusterFactory.

  3. 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
  4. Remove the bare clone.

    user@local:/ClusterFactory.git
    cd ..
    rm -rf ./ClusterFactory.git

  5. 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.

  1. Add the upstream and disable push on the remote upstream:

    user@local:/ClusterFactory
    git remote add upstream https://github.com/deepsquare-io/ClusterFactory.git
    git remote set-url --push upstream DISABLE
  2. You can list all your remotes with git remote -v:

    user@local:/ClusterFactory
    git 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:

user@local:/ClusterFactory
git checkout -b configs <CF version>

4. Rename the examples and commit

Copy argo.example, core.example, cfctl.yaml.example, and remove the .example:

user@local:/ClusterFactory
cp -R argo.example/ argo/
cp -R core.example/ core/
cp cfctl.yaml.example cfctl.yaml

You can track these files on Git:

user@local:/ClusterFactory
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:

user@local:/ClusterFactory
git fetch --tags upstream

git-fetch

To merge the upstream changes, either rebase or create a merge commit.

user@local:/ClusterFactory
git merge v0.8.0

git-merge

user@local:/ClusterFactory
git push

git-push


If you wish to follow the upstream main branch:

user@local:/ClusterFactory
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!