92 lines
2.0 KiB
YAML
92 lines
2.0 KiB
YAML
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: git-test-server
|
|
namespace: swarm-system
|
|
labels:
|
|
app: git-test-server
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: git-test-server
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: git-test-server
|
|
spec:
|
|
initContainers:
|
|
- name: init-repo
|
|
image: alpine:3.20
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
- |
|
|
set -e
|
|
apk add --no-cache git >/dev/null
|
|
rm -rf /git/swarm-test.git /tmp/swarm-test-src
|
|
|
|
mkdir -p /tmp/swarm-test-src
|
|
cd /tmp/swarm-test-src
|
|
git init -b main
|
|
git config user.name "Swarm Test"
|
|
git config user.email "swarm-test@example.com"
|
|
|
|
cat > hello.py <<'PY'
|
|
def hello_world():
|
|
return "hello"
|
|
PY
|
|
|
|
git add hello.py
|
|
git commit -m "Initial test repository"
|
|
|
|
mkdir -p /git
|
|
git clone --bare /tmp/swarm-test-src /git/swarm-test.git
|
|
git -C /git/swarm-test.git config daemon.receivepack true
|
|
touch /git/swarm-test.git/git-daemon-export-ok
|
|
volumeMounts:
|
|
- name: git-data
|
|
mountPath: /git
|
|
containers:
|
|
- name: git
|
|
image: alpine:3.20
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
- |
|
|
set -e
|
|
apk add --no-cache git git-daemon >/dev/null
|
|
git daemon \
|
|
--verbose \
|
|
--reuseaddr \
|
|
--base-path=/git \
|
|
--export-all \
|
|
--enable=receive-pack \
|
|
/git
|
|
ports:
|
|
- containerPort: 9418
|
|
name: git
|
|
volumeMounts:
|
|
- name: git-data
|
|
mountPath: /git
|
|
volumes:
|
|
- name: git-data
|
|
emptyDir: {}
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: git-test-server
|
|
namespace: swarm-system
|
|
labels:
|
|
app: git-test-server
|
|
spec:
|
|
type: ClusterIP
|
|
ports:
|
|
- port: 9418
|
|
targetPort: git
|
|
protocol: TCP
|
|
name: git
|
|
selector:
|
|
app: git-test-server
|