GitOps with Docker

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.

Quick start
This is a quick start tutorial for getting a simple container up and running. Installation of the agent To start using simplecontainer, first run it to generate a project and build a configuration file. Note: This is example for the localhost. If domain is example.com running on the virtual

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.

kind: gitops
meta:
  group: examples
  name: plain-manual
spec:
  repoURL: "https://github.com/simplecontainer/examples"
  revision: "main"
  directoryPath: "/tests/minimal"

tests/gitops/apps/gitops-manual.yaml

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

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-auto.yaml

After applying this object it will auto-sync changes.

GitOps App of apps pattern

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

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.