Skip to content

Commit 07cca31

Browse files
Merge pull request #76 from CodeForPhilly/ops/pod-git-remote
ops(runbook): script for fetching from the pod's data clone
2 parents ba19df3 + 0646237 commit 07cca31

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

docs/operations/runbook.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,31 @@ for the authoritative contract. Operationally:
148148
with the outcome + commits; failures log error. Search the pod logs
149149
for `hot-reload` to audit the most recent firings.
150150

151+
## Fetch from the pod's data clone
152+
153+
The pod's working tree lives on a PVC at `/app/data` inside the container and may briefly hold commits the push daemon hasn't shipped to GitHub yet (or that got escape-hatched onto a `conflicts/*` branch — those *are* always pushed, see [`apps/api/src/store/reconcile.ts`](../../apps/api/src/store/reconcile.ts)). When you want to inspect the pod's view of the data repo without exposing any network ports, add it as a git remote via the `ext::` transport.
154+
155+
```bash
156+
cd /path/to/codeforphilly-data
157+
158+
git config protocol.ext.allow always
159+
git remote add pod 'ext::sh /path/to/codeforphilly-ng/scripts/git-pod-uploadpack.sh'
160+
161+
git fetch pod
162+
git log --oneline pod/published..pod/published # whatever you're chasing
163+
```
164+
165+
The helper script resolves the current pod by label selector, so it survives restarts. Override via env if your setup differs:
166+
167+
| Var | Default |
168+
|---|---|
169+
| `CFP_POD_KUBECONFIG` | `~/.kube/cfp-sandbox-cluster-kubeconfig.yaml` |
170+
| `CFP_POD_NAMESPACE` | `codeforphilly-rewrite-sandbox` |
171+
| `CFP_POD_SELECTOR` | `app.kubernetes.io/name=codeforphilly` |
172+
| `CFP_POD_DATA_PATH` | `/app/data` |
173+
174+
**Read-only by design**`git upload-pack` only serves fetch; pushing back to the pod would bypass gitsheets + in-memory state and fight the push daemon. Pull what you need to your local clone, reason about it there, then push to `origin` if appropriate.
175+
151176
## Helpful commands
152177

153178
```bash

scripts/git-pod-uploadpack.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
# Spawn `git upload-pack` inside the running sandbox pod so you can fetch from
3+
# the pod's PVC-backed data clone as a git remote. Designed to be plumbed into
4+
# git's `ext::` transport — see docs/operations/runbook.md → "Fetch from the
5+
# pod's data clone".
6+
#
7+
# Env (all optional, sensible defaults baked in):
8+
# CFP_POD_KUBECONFIG — path to kubeconfig (default ~/.kube/cfp-sandbox-cluster-kubeconfig.yaml)
9+
# CFP_POD_NAMESPACE — k8s namespace (default codeforphilly-rewrite-sandbox)
10+
# CFP_POD_SELECTOR — label selector for the pod (default app.kubernetes.io/name=codeforphilly)
11+
# CFP_POD_DATA_PATH — repo path inside the pod (default /app/data)
12+
set -euo pipefail
13+
14+
KUBECONFIG_PATH="${CFP_POD_KUBECONFIG:-$HOME/.kube/cfp-sandbox-cluster-kubeconfig.yaml}"
15+
NAMESPACE="${CFP_POD_NAMESPACE:-codeforphilly-rewrite-sandbox}"
16+
SELECTOR="${CFP_POD_SELECTOR:-app.kubernetes.io/name=codeforphilly}"
17+
DATA_PATH="${CFP_POD_DATA_PATH:-/app/data}"
18+
19+
POD=$(kubectl --kubeconfig="$KUBECONFIG_PATH" -n "$NAMESPACE" \
20+
get pod -l "$SELECTOR" --field-selector=status.phase=Running \
21+
-o jsonpath='{.items[0].metadata.name}')
22+
23+
if [[ -z "$POD" ]]; then
24+
echo "git-pod-uploadpack: no Running pod matched $SELECTOR in $NAMESPACE" >&2
25+
exit 1
26+
fi
27+
28+
exec kubectl --kubeconfig="$KUBECONFIG_PATH" -n "$NAMESPACE" \
29+
exec -i "$POD" -- git upload-pack "$DATA_PATH"

0 commit comments

Comments
 (0)