Deploy docker containers using GitOps approach
If you were searching for the tool like ArgoCD to implement GitOps pattern for Docker containers - you are on the right place.
Simplecontainer enables the GitOps approach to deploying containers on single or cluster of docker daemon hosts with simplecontainer enabled nodes.
This allows to pull the latest changes on the definitions from the git repository instead of pushing the changes to the node via CLI.
To checkout gitops deployment - first, you need to have simplecontainer running and CLI configured already. If you didn't do that you need to do that first.

Afterward, clone the examples repository and list the definitions inside the directories.
git clone https://github.com/simplecontainer/examples
cd examples
GitOps manual sync for simplecontainer
An example definition of the GitOps object is given below.
kind: gitops
meta:
group: examples
name: plain-manual
spec:
repoURL: "https://github.com/simplecontainer/examples"
revision: "main"
directoryPath: "/tests/minimal"
tests/gitops/apps/gitops-plain.yaml
Applying this object: tests/gitops/apps/gitops-manual.yaml
simplecontainer willl create an GitOps object on the node and will reconcile all definitions specified under the directoryPath on the revision of the git repository.
smr apply tests/gitops/apps/gitops-plain.yaml
everything went smoothly: good job!
smr ps gitops
RESOURCE REPOSITORY REVISION SYNCED AUTO STATE STATUS
gitops/examples/plain-manual https://github.com/simplecontainer/examples (eae4c94) main Never synced false Drifted definitionsinvalid
A GitOps object can do auto sync and manual sync. Since the sync is manual in this case we need to trigger the sync manually via CLI.
smr gitops sync examples plain-manual
smr ps
NODE RESOURCE PORTS DEPS ENGINE STATE SMR STATE
smr-agent-2 containers/example/example-busybox-1 - - running (docker) running (53s)
smr-agent-2 containers/example/example-busybox-2 - - running (docker) running (53s)
Simplecontainer will pick up definitions from the definition.yaml and will reconcile the state - create containers on the node.
GitOps auto sync for simplecontainer
kind: gitops
meta:
group: examples
name: plain-auto
spec:
repoURL: "https://github.com/simplecontainer/examples"
revision: "main"
automaticSync: true
directoryPath: "/tests/minimal"
tests/gitops/apps/gitops-automatic.yaml
After applying this object it will auto-sync changes.
GitOps App of apps pattern for simplecontainer
kind: gitops
meta:
group: examples
name: app-of-apps
spec:
repoURL: "https://github.com/simplecontainer/examples"
revision: "main"
directoryPath: "tests/gitops/apps"
tests/gitops/app-of-apps.yaml
Using this pattern we can create one GitOps object that will automate creation and syncing of new GitOps objects.
smr apply tests/gitops/app-of-apps.yaml
everything went smoothly: good job!
smr gitops sync examples app-of-apps
sync is triggered manually
RESOURCE REPOSITORY REVISION SYNCED AUTO STATE STATUS
gitops/examples/app-of-apps https://github.com/simplecontainer/examples (eae4c94) main eae4c94 false InSync insync
gitops/examples/plain-auto https://github.com/simplecontainer/examples (eae4c94) main eae4c94 true InSync insync
gitops/examples/plain-manual https://github.com/simplecontainer/examples (eae4c94) main Never synced false Drifted definitionsinvalid
gitops/examples/plain-manual-spread https://github.com/simplecontainer/examples (eae4c94) main Never synced false Drifted definitionsinvalid
smr ps
NODE RESOURCE PORTS DEPS ENGINE STATE SMR STATE
smr-agent-2 containers/example/example-busybox-1 - - running (docker) running (53s)
smr-agent-2 containers/example/example-busybox-2 - - running (docker) running (53s)
As you can see after syncing app-of-apps
GitOps object it will create the rest of the GitOps objects from /tests/gitops/apps
directory.
Using dashboard we can investigate in the real time what is happening to the GitOps objects and what they hold inside. For this example in particular the output would be similar to the one in the video below.