A sidecar app which clones a git repo and keeps it in sync with the upstream.
Go to file
Thomas Jackson 39ca0a2ca0 Fix error log to print out actual status codes 2019-01-22 14:12:49 -08:00
build Switch from godeps to `go mod` 2019-01-22 11:21:57 -08:00
cmd/git-sync Fix error log to print out actual status codes 2019-01-22 14:12:49 -08:00
demo Fix hugo demo and docs 2018-12-17 11:44:50 -08:00
docs Fix hugo demo and docs 2018-12-17 11:44:50 -08:00
pkg/version Use the go-build-template 2016-10-30 17:09:06 -07:00
vendor Switch from godeps to `go mod` 2019-01-22 11:21:57 -08:00
.gitignore Use the go-build-template 2016-10-30 17:09:06 -07:00
CONTRIBUTING.md Create CONTRIBUTING.md 2016-08-22 16:18:11 -07:00
Dockerfile.in Build a manifest list 2018-11-09 14:20:23 -08:00
LICENSE Initial commit 2016-08-20 14:09:57 -07:00
Makefile Build a manifest list 2018-11-09 14:20:23 -08:00
OWNERS OWNERS wants 'approvers' not 'maintainers' 2019-01-15 08:39:42 -08:00
README.md adding changes from previous PR, updated README 2019-01-22 14:12:49 -08:00
RELEASING.md Use k8s GCR vanity URL 2018-04-06 13:15:46 -04:00
SECURITY_CONTACTS Add security contacts 2018-05-24 08:57:57 -07:00
code-of-conduct.md Update code-of-conduct.md 2017-12-20 13:32:20 -05:00
go.mod Switch from godeps to `go mod` 2019-01-22 11:21:57 -08:00
go.sum Switch from godeps to `go mod` 2019-01-22 11:21:57 -08:00
slow_git.sh add timeout tests 2019-01-04 22:32:53 +00:00
test_e2e.sh add timeout tests 2019-01-04 22:32:53 +00:00

README.md

git-sync

git-sync is a simple command that pulls a git repository into a local directory. It is a perfect "sidecar" container in Kubernetes - it can periodically pull files down from a repository so that an application can consume them.

git-sync can pull one time, or on a regular interval. It can pull from the HEAD of a branch, or from a git tag, or from a specific git hash. It will only re-pull if the target of the run has changed in the upstream repository. When it re-pulls, it updates the destination directory atomically. In order to do this, it uses a git worktree in a subdirectory of the --root and flips a symlink.

git-sync can also be configured to make webhook call upon sucessful git repo syncronisation. The call is made when right after the symlink is updated.

Usage

# build the container
make container REGISTRY=registry VERSION=tag

# run the container
docker run -d \
    -v /tmp/git-data:/tmp/git \
    registry/git-sync:tag \
        --repo=https://github.com/kubernetes/git-sync
        --branch=master
        --wait=30

# run an nginx container to serve the content
docker run -d \
    -p 8080:80 \
    -v /tmp/git-data:/usr/share/nginx/html \
    nginx

Example of webhooks usage

Webhook config example A webhook config must be valid JSON. If success is not specified in the config, git-sync will not wait for a response.

{   
    "url": "http://localhost:9090/-/reload", 
    "method": "POST|GET",
    "success": 200
}

Usage

docker run -d \
    -v /tmp/git-data:/git \
    registry/git-sync:tag \
        --repo=https://github.com/kubernetes/git-sync
        --branch=master
        --wait=30
        --webhook='[{"url": "http://localhost:9090/-/reload", "method": "POST", "success": 200}]'
        --webhook='[{"url": "http://1.2.3.4:9090/-/reload", "method": "POST"}]'

Analytics