Skip to content

Commit 8ee0f7e

Browse files
committed
Update README and other docs
1 parent e15c7a9 commit 8ee0f7e

File tree

6 files changed

+69
-42
lines changed

6 files changed

+69
-42
lines changed

README.md

+44-23
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,24 @@ use the [v3.x branch](https://github.com/kubernetes/git-sync/tree/release-3.x).
66

77
# git-sync
88

9-
git-sync is a simple command that pulls a git repository into a local directory.
10-
It is a perfect "sidecar" container in Kubernetes - it can periodically pull
11-
files down from a repository so that an application can consume them.
9+
git-sync is a simple command that pulls a git repository into a local
10+
directory, waits for a while, then repeats. As the remote repository chan ges,
11+
those changes will be synced locally. It is a perfect "sidecar" container in
12+
Kubernetes - it can pull files down from a repository so that an application
13+
can consume them.
1214

1315
git-sync can pull one time, or on a regular interval. It can pull from the
1416
HEAD of a branch, from a git tag, or from a specific git hash. It will only
15-
re-pull if the target of the run has changed in the upstream repository. When
16-
it re-pulls, it updates the destination directory atomically. In order to do
17-
this, it uses a git worktree in a subdirectory of the `--root` and flips a
18-
symlink.
17+
re-pull if the referenced target has changed in the upstream repository (e.g. a
18+
new commit on a branch). It "publishes" each sync through a worktree and a
19+
named symlink. This ensures an atomic update - consumers will not see a
20+
partially constructed view of the local repository.
1921

2022
git-sync can pull over HTTP(S) (with authentication or not) or SSH.
2123

22-
git-sync can also be configured to make a webhook call upon successful git repo
23-
synchronization. The call is made after the symlink is updated.
24+
git-sync can also be configured to make a webhook call or exec a command upon
25+
successful git repo synchronization. The call is made after the symlink is
26+
updated.
2427

2528
## Major update: v3.x -> v4.x
2629

@@ -75,23 +78,36 @@ docker run -d \
7578
nginx
7679
```
7780

81+
### Flags
82+
83+
git-sync has many flags and optional features (see the manual below). Most of
84+
those flags can be configured through environment variables, but in most cases
85+
(with the obvious exception of passwords) flags are preferred, because the
86+
program can abort if an invalid flag is specified, but a misspelled environment
87+
variable will just be ignored. We've tried to stay backwards-compatible across
88+
major versions (by accepting deprecated flags and environment variables), but
89+
some things have evolved, and users are encouraged to use the most recent flags
90+
for their major verion.
91+
7892
### Volumes
7993

8094
The `--root` flag must indicate either a directory that either a) does not
8195
exist (it will be created); or b) exists and is empty; or c) can be emptied by
8296
removing all of the contents.
8397

84-
Why? Git demands to clone into an empty directory. If the directory exists
85-
and is not empty, git-sync will try to empty it by removing everything in it
86-
(we can't just `rm -rf` the dir because it might be a mounted volume). If that
87-
fails, git-sync will abort.
98+
Why? Git really wants an empty directory, to avoid any confusion. If the
99+
directory exists and is not empty, git-sync will try to empty it by removing
100+
everything in it (we can't just `rm -rf` the dir because it might be a mounted
101+
volume). If that fails, git-sync will abort.
88102

89103
With the above example or with a Kubernetes `emptyDir`, there is usually no
90104
problem. The problematic case is when the volume is the root of a filesystem,
91105
which sometimes contains metadata (e.g. ext{2,3,4} have a `lost+found` dir).
92-
Git will not clone into such a directory (`fatal: destination path
93-
'/tmp/git-data' already exists and is not an empty directory`). The only real
94-
solution is to use a sub-directory of the volume as the `--root`.
106+
The only real solution is to use a sub-directory of the volume as the `--root`.
107+
108+
## More docs
109+
110+
More documentation on specific topics can be [found here](./docs).
95111

96112
## Manual
97113

@@ -102,7 +118,7 @@ NAME
102118
git-sync - sync a remote git repository
103119
104120
SYNOPSIS
105-
git-sync --repo=<repo> [OPTION]...
121+
git-sync --repo=<repo> --root=<path> [OPTIONS]...
106122
107123
DESCRIPTION
108124
@@ -128,7 +144,8 @@ DESCRIPTION
128144
OPTIONS
129145
130146
Many options can be specified as either a commandline flag or an environment
131-
variable.
147+
variable, but flags are preferred because a misspelled flag is a fatal
148+
error while a misspelled environment variable is silently ignored.
132149
133150
--add-user, $GITSYNC_ADD_USER
134151
Add a record to /etc/passwd for the current UID/GID. This is
@@ -140,9 +157,6 @@ OPTIONS
140157
(200) and produce a series of key=value lines, including
141158
"username=<value>" and "password=<value>".
142159
143-
--change-permissions <int>, $GITSYNC_PERMISSIONS
144-
Change permissions on the checked-out files to the specified mode.
145-
146160
--cookie-file <string>, $GITSYNC_COOKIE_FILE
147161
Use a git cookiefile (/etc/git-secret/cookie_file) for
148162
authentication.
@@ -165,8 +179,8 @@ OPTIONS
165179
--exechook-command <string>, $GITSYNC_EXECHOOK_COMMAND
166180
An optional command to be executed after syncing a new hash of the
167181
remote repository. This command does not take any arguments and
168-
executes with the synced repo as its working directory. The
169-
environment variable $GITSYNC_HASH will be set to the git hash that
182+
executes with the synced repo as its working directory. The following
183+
environment variables $GITSYNC_HASH will be set to the git hash that
170184
was synced. The execution is subject to the overall --sync-timeout
171185
flag and will extend the effective period between sync attempts.
172186
This flag obsoletes --sync-hook-command, but if sync-hook-command
@@ -211,6 +225,13 @@ OPTIONS
211225
- off: Disable explicit git garbage collection, which may be a good
212226
fit when also using --one-time.
213227
228+
--group-write, $GITSYNC_GROUP_WRITE
229+
Ensure that data written to disk (including the git repo metadata,
230+
checked out files, worktrees, and symlink) are all group writable.
231+
This corresponds to git's notion of a "shared repository". This is
232+
useful in cases where data produced by git-sync is used by a
233+
different UID. This replaces the older --change-permissions flag.
234+
214235
-h, --help
215236
Print help text and exit.
216237

cmd/git-sync/main.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -2245,7 +2245,7 @@ NAME
22452245
git-sync - sync a remote git repository
22462246
22472247
SYNOPSIS
2248-
git-sync --repo=<repo> [OPTION]...
2248+
git-sync --repo=<repo> --root=<path> [OPTIONS]...
22492249
22502250
DESCRIPTION
22512251
@@ -2271,7 +2271,8 @@ DESCRIPTION
22712271
OPTIONS
22722272
22732273
Many options can be specified as either a commandline flag or an environment
2274-
variable.
2274+
variable, but flags are preferred because a misspelled flag is a fatal
2275+
error while a misspelled environment variable is silently ignored.
22752276
22762277
--add-user, $GITSYNC_ADD_USER
22772278
Add a record to /etc/passwd for the current UID/GID. This is
@@ -2305,8 +2306,8 @@ OPTIONS
23052306
--exechook-command <string>, $GITSYNC_EXECHOOK_COMMAND
23062307
An optional command to be executed after syncing a new hash of the
23072308
remote repository. This command does not take any arguments and
2308-
executes with the synced repo as its working directory. The following
2309-
environment variables $GITSYNC_HASH will be set to the git hash that
2309+
executes with the synced repo as its working directory. The
2310+
$GITSYNC_HASH environment variable will be set to the git hash that
23102311
was synced. The execution is subject to the overall --sync-timeout
23112312
flag and will extend the effective period between sync attempts.
23122313
This flag obsoletes --sync-hook-command, but if sync-hook-command

docs/askpass-url.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Using an Http Auth URL with git-sync
1+
# Using an HTTP auth URL with git-sync
22

33
## Step 1: Create a GIT_ASKPASS HTTP Service
44

@@ -8,15 +8,15 @@ Example of the service's output, see more at <https://git-scm.com/docs/gitcreden
88

99
```
1010
11-
password=ya29.mysecret
11+
password=mysecret
1212
```
1313

1414
## Step 2: Configure git-sync container
1515

1616
In your git-sync container configuration, specify the GIT_ASKPASS URL
1717

18-
The credentials will pass in plain text, make sure the connection between git-sync
19-
and GIT ASKPASS Service are secure.
18+
The credentials will pass in plain text, so make sure the connection between
19+
git-sync and GIT ASKPASS Service is secure.
2020

2121
See the askpass e2e test as an example.
2222

docs/cookie-file.md

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Using an Http Cookie File with git-sync
1+
# Using an HTTP cookie file with git-sync
22

3-
Git-sync supports use of an HTTP Cookie File for accessing git content.
3+
Git-sync supports use of an HTTP cookie file for accessing git content.
44

5-
## Step 1: Create Secret
5+
## Step 1: Create a Secret
66

7-
First, create a secret file from the git cookie file you wish to
7+
First, create a Kubernetes Secret from the git cookie file you wish to
88
use.
99

1010
Example: if the cookie-file is `~/.gitcookies`:
@@ -16,9 +16,9 @@ kubectl create secret generic git-cookie-file --from-file=cookie_file=~/.gitcook
1616
Note that the key is `cookie_file`. This is the filename that git-sync will look
1717
for.
1818

19-
## Step 2: Configure Pod/Deployment Volume
19+
## Step 2: Configure a Pod/Deployment volume
2020

21-
In your Pod or Deployment configuration, specify a Volume for mounting the
21+
In your Pod or Deployment configuration, specify a volume for mounting the
2222
cookie-file Secret. Make sure to set `secretName` to the same name you used to
2323
create the secret (`git-cookie-file` in the example above).
2424

@@ -30,13 +30,12 @@ volumes:
3030
defaultMode: 0440
3131
```
3232
33-
## Step 3: Configure git-sync container
33+
## Step 3: Configure a git-sync container
3434
3535
In your git-sync container configuration, mount your volume at
3636
"/etc/git-secret". Make sure to pass the `--cookie-file` flag or set the
3737
environment variable `GITSYNC_COOKIE_FILE` to "true", and to use a git repo
38-
(`--repo` flag or `GITSYNC_REPO` env) is set to use a URL with the HTTP
39-
protocol.
38+
(`--repo` or `GITSYNC_REPO`) with an HTTP URL.
4039

4140
```yaml
4241
name: "git-sync"

docs/proxy.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Lastly, [see similar issue for FluxCD](https://github.com/fluxcd/flux/pull/3152)
1010

1111
## Step 1: Create configuration
1212

13-
Create a ConfigMap to store your configuration:
13+
Create a Kubernetes ConfigMap to store your configuration:
1414

1515
```bash
1616
cat << EOF >> /tmp/ssh-config
@@ -45,4 +45,4 @@ spec:
4545
- name: ssh-config
4646
configMap:
4747
name: ssh-config
48-
```
48+
```

v3-to-v4.md

+6
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ specify `--depth=0`.
127127
The logging output for v3 was semi-free-form text. Log output in v4 is
128128
structured and rendered as strict JSON.
129129

130+
## Root dir
131+
132+
git-sync v3 container images defaulted `--root` to "/tmp/git". In v4, that has
133+
moved to "/git". Users who mount a volume and expect to use the default
134+
`--root` must mount it on "/git".
135+
130136
## Other changes
131137

132138
git-sync v3 would allow invalidly formatted env vars (e.g. a value that was

0 commit comments

Comments
 (0)