I am using git-sync as a sidecar in Kubernetes to do git-pull and mount the pulled data to shared volume periodically.
Everything works well except GIT_SYNC_PERIOD. I want git sync every 10min, somehow it always use the default value which is 10ms.
Here is my configuration.
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx-helloworld
image: nginx
ports:
- containerPort: 80
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: www-data
- name: git-sync
image: k8s.gcr.io/git-sync:v3.1.3
volumeMounts:
- name: www-data
mountPath: /data
env:
- name: GIT_SYNC_REPO
value: "https://github.com/musaalp/gighub.git" ##repo-path-you-want-to-clone
- name: GIT_SYNC_BRANCH
value: "master" ##repo-branch
- name: GIT_SYNC_ROOT
value: /data
- name: GIT_SYNC_DEST
value: "languages" ##path-where-you-want-to-clone
- name: GIT_SYNC_PERIOD
value: "600"
securityContext:
runAsUser: 0
volumes:
- name: www-data
emptyDir: {}
I am assuming the value for GIT_SYNC_PERIOD is second.
CodePudding user response:
You can pass -wait=time
to override the default behaviour
containers:
- name: git-sync
image: k8s.gcr.io/git-sync:v3.1.3
args: ["-wait=20","-v=7"]
and with -v=7
you will be able to see how much time it will wait
.
debug logs
I0822 16:22:17.088533 13 main.go:641] "level"=5 "msg"="running command" "cmd"="git rev-parse HEAD" "cwd"="/data/hello"
I0822 16:22:17.122642 13 main.go:641] "level"=5 "msg"="running command" "cmd"="git ls-remote -q origin refs/heads/master" "cwd"="/data/hello"
I0822 16:22:19.060599 13 main.go:582] "level"=2 "msg"="git state" "local"="61be34f64d471d65c26f2d28f1a35b165249a537" "remote"="61be34f64d471d65c26f2d28f1a35b165249a537"
I0822 16:22:19.060811 13 main.go:584] "level"=1 "msg"="no update required"
I0822 16:22:19.060931 13 main.go:354] "level"=1 "msg"="next sync" "wait_time"=20000000000
I0822 16:22:39.079914 13 main.go:641] "level"=5 "msg"="running command" "cmd"="git rev-parse HEAD" "cwd"="/data/hello"
I0822 16:22:39.159808 13 main.go:641] "level"=5 "msg"="running command" "cmd"="git ls-remote -q origin refs/heads/master" "cwd"="/data/hello"
I0822 16:22:40.839761 13 main.go:582] "level"=2 "msg"="git state" "local"="61be34f64d471d65c26f2d28f1a35b165249a537" "remote"="61be34f64d471d65c26f2d28f1a35b165249a537"
I0822 16:22:40.839788 13 main.go:584] "level"=1 "msg"="no update required"
I0822 16:22:40.839815 13 main.go:354] "level"=1 "msg"="next sync" "wait_time"=20000000000
now if you set something like --wait=1000
then
I0822 16:22:53.240181 15 main.go:354] "level"=1 "msg"="next sync" "wait_time"=1000000000000
--period <duration>
,$GIT_SYNC_PERIOD
How long to wait between sync attempts. This must be at least 10ms. This flag obsoletes--wait
, but if--wait
is specified, it will take precedence. (default: 10s)