Comments (2)
I am not an nginx expert, but I also struggled with this. The default nginx content dir (/usr/share/nginx/html) is expected to hold data. There is no flag to nginx (AFAICT) to change that - I think you have to replace the whole config file, which means either mounting it in as a volume or building a custom image based on nginx.
from git-sync.
A little more detail.
If you git-sync into /usr/share/nginx/html
, you end up with data at /usr/share/nginx/html/<link>/http1/http1.2/index.html
- not useful.
If you git-sync into /usr/share/nginx/
with html
as the link name, you end up with data at /usr/share/nginx/html/http1/http1.2/index.html
- still not useful.
If you use Kubernetes and subPath=<link>
on the volume mount, then you race* (and almost always lose) - not useful. Also, at best you end up with data at /usr/share/nginx/html/http1/http1.2/index.html
- still not useful.
If you use Kubernetes and subPath=<link>/http1/http1.2
on the volume mount, then you race* (and almost always lose) - not useful. Even if you win, you don't get any sync updates because of how linux works with bind mounts and symlinks.
I did find a way - the proverbial "another level of indirection. I am pasting a kubernete deployment yaml below.
- the race: Kubernetes sees it as
emptyDir
- in order to bind mount a sub-path, that path has to exist. Container runtimes will mkdir the path if it isn't found, which gives nginx an empty directory and causes git-sync to fail to publish the link.
# This demonstrates a nearly-trivial nginx server publishing content from a
# subdir of a git repo.
apiVersion: apps/v1
kind: Deployment
metadata:
name: git-content-server
spec:
replicas: 1
selector:
matchLabels:
app: git-content-server
template:
metadata:
labels:
app: git-content-server
spec:
volumes:
- name: git # git-sync will write here
emptyDir: {}
- name: nginx # the "linker" container will write here
emptyDir: {}
containers:
# This container syncs from a git repo into the git volume.
- name: git-sync
image: registry.k8s.io/git-sync/git-sync:v4.2.4
args:
- --repo=https://github.com/kubernetes/git-sync
- --root=/git
- --period=60s
- --link=head
- --max-failures=1000000000
- -v=2
volumeMounts:
- mountPath: /git
name: git
# This container creates a symlink in the nginx volume, pointing to the
# content in a subdir of the git volume. This is needed to use the
# default nginx config, which assumes data is in /usr/share/nginx/html.
- name: linker
image: alpine
args:
- sh
- -c
- "ln -s /git/head/demo/html /usr/share/nginx/html; ls -l /usr/share/nginx/html; sleep inf;"
volumeMounts:
- mountPath: /usr/share/nginx
name: nginx
# This container serves content from the nginx volume, which follows the
# symlink to the git volume. This avoids having to carry a custom nginx
# config, but a non-trivial user would probably have to do that anyway.
- name: http
image: nginx
volumeMounts:
- mountPath: /git
name: git
readOnly: true
- mountPath: /usr/share/nginx
name: nginx
readOnly: true
from git-sync.
Related Issues (20)
- GitLab via ssh key HOT 3
- How to disable commit hash in the target folder? HOT 2
- Allow the submodule functionality for repos copied using vcs tool HOT 1
- Temporarily missing files when using $GITSYNC_LINK HOT 4
- Remediate security vulnerabilities on 4.1.0 HOT 5
- High vulnerability CVE-2023-6246 and CVE-2023-6779 HOT 1
- Issue with PYTHONPATH Resolution in git-sync 4.0.0 HOT 2
- v4 slack webhook HOT 6
- exechook behavior HOT 4
- Remediate 4.2.2 security vulnerabilities HOT 1
- Support GitHub App authentication HOT 7
- TODO: infra to make #878 work HOT 1
- Curious about real example raising race condition when using v3 HOT 1
- exechook working HOT 8
- TODO: shellcheck test_e2e.sh and test_git.sh HOT 5
- /bin/sh: ./build/test.sh: not found
- test_e2e.sh: use `local` for all variables defined inside functions HOT 2
- git-sync Multiple Vulnerabilities HOT 3
- git-sync produced an intermediate file,the path of command is wrong HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from git-sync.