Deploy docker containers using GitOps approach
Simplecontainer enables the GitOps approach to deploying containers on single or multiple simplecontainer hosts.
This allows the simplecontainer to pull the latest changes on the definitions from the git repository instead of pushing the changes to the simplecontainer via CLI.
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 start exploring simplecontainer.
git clone https://github.com/simplecontainer/examples
cd examples
GitOps manual sync
An example definition of the GitOps object is given below.
Applying this tests/gitops/apps/gitops-manual.yaml
the file will create a GitOps object on the simplecontainer.
smr apply tests/gitops/apps/gitops-manual.yaml
everything went smoothly: good job!
smr gitops list
GROUP NAME REPOSITORY REVISION SYNCED AUTO STATE
examples plain-manual https://github.com/simplecontainer/examples (4bab88f) main 4bab88f false InSync
Since the sync is manual in this case we need to trigger the sync via CLI.
smr gitops sync examples plain-manual
smr ps
GROUP NAME DOCKER NAME IMAGE IP PORTS DEPS DOCKER STATE SMR STATE
example busybox example-busybox-1 busybox:latest running running (0s)
example busybox example-busybox-2 busybox:latest running running (0s)
Simplecontainer will pick up definitions from the definition.yaml and reconcile the state.
GitOps auto sync
After applying this object it will auto-sync changes.
GitOps App of apps pattern
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
smr gitops list
GROUP NAME REPOSITORY REVISION SYNCED AUTO STATE
examples plain-manual https://github.com/simplecontainer/examples (cb849c3) main Never synced false Drifted
examples app-of-apps https://github.com/simplecontainer/examples (cb849c3) main cb849c3 false InSync
examples plain-auto https://github.com/simplecontainer/examples (cb849c3) main cb849c3 true InSync
smr ps
GROUP NAME DOCKER NAME IMAGE IP PORTS DEPS DOCKER STATE SMR STATE
example busybox example-busybox-1 busybox:latest running kill (2s)
example busybox example-busybox-2 busybox:latest running kill (2s)
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.