If your pods still clone code with a gitRepo volume, you need a gitRepo volume replacement before your next Kubernetes upgrade. Since Kubernetes 1.36, the kubelet’s GitRepoVolumeDriver feature gate is locked to off, so these pods are accepted by the API server and then refused by the kubelet. Your CI pipeline passes, kubectl apply succeeds, and the workload never starts.
The removal has a security story behind it. CVE-2024-10220 showed that a crafted gitRepo volume could run commands as root on the node, and CVE-2025-1767 showed it could read other pods’ local repositories. The driver had been deprecated for years and was never fixed properly.
This guide shows how to find every gitRepo volume in your clusters, then replace them with the two supported patterns: an init container that clones into an emptyDir, and a git-sync sidecar for content that must stay fresh. It finishes with a policy that stops new gitRepo volumes from ever reaching the cluster.
Table of Contents
- Technical Overview & Background
- Choosing a gitRepo Volume Replacement
- Core System Prerequisites
- Step-by-Step gitRepo Volume Replacement
- Architecture & Component Breakdown
- Real-World Use Cases & Enterprise Examples
- Troubleshooting, Edge Cases & Best Practices
- FAQ
- Summary & Key Takeaways
Technical Overview & Background
The gitRepo volume type was one of Kubernetes’ earliest conveniences. You gave it a repository URL and revision, and the kubelet ran git clone into an empty directory before the containers started.
That simplicity hid serious problems:
- The kubelet performed the clone as root on the node, not inside the pod’s security context.
- It offered no authentication options, so it only worked with public repositories.
- It cloned once and never updated.
- It depended on a
gitbinary on the host, which many modern node images do not ship.
The deprecation and removal timeline
| Kubernetes version | gitRepo status |
|---|---|
| 1.11 (2018) | Volume type marked deprecated in documentation |
| Nov 2024 | CVE-2024-10220 disclosed: arbitrary command execution as root through gitRepo hooks |
| Mar 2025 | CVE-2025-1767 disclosed: access to other pods’ local repositories on the same node |
| 1.33 | GitRepoVolumeDriver kubelet gate added, off by default |
| 1.36 | Gate locked off; cannot be re-enabled |
| 1.39 (planned) | Gate and driver code removed entirely |
KEP-5040 documents this plan. The volume type stays in the API, which is exactly why the failure is easy to miss: admission passes, and only the kubelet rejects the pod.
Why the security issues mattered
CVE-2024-10220 was rated high severity. Because the clone ran as root on the node, a repository containing malicious Git hooks could execute code outside the container boundary. Anyone allowed to create pods could, in effect, run commands on nodes.
CVE-2025-1767 was medium severity and was never patched. The official mitigation is simply: do not use gitRepo volumes.
If your clusters run multi-tenant workloads, a gitRepo volume replacement is a security fix as much as an upgrade task.
Choosing a gitRepo Volume Replacement
There are three realistic options. The right one depends on how often the content changes and where it comes from.
Option 1: Init container + emptyDir
An init container runs git clone into a shared emptyDir. The app container mounts the same volume.
- Best for: content needed once at startup (config bundles, static sites built at deploy time, test fixtures)
- Pros: simple, no extra long-running container, runs with the pod’s security context
- Cons: content does not update until the pod restarts
Option 2: git-sync sidecar
git-sync is a Kubernetes SIG project that clones a repository and keeps it updated, swapping a symlink atomically after each successful pull.
- Best for: content that must stay fresh (DAG folders, dashboards, documentation sites, rule files)
- Pros: private repos over HTTPS or SSH, periodic sync, webhooks and exec hooks, health endpoint
- Cons: one more container per pod, needs resource requests and monitoring
Option 3: Bake content into the image or use another source
Often the cleanest gitRepo volume replacement is to stop cloning at runtime:
- Build the content into the container image in CI
- Use a ConfigMap for small config files (limited to about 1 MiB)
- Use an OCI artifact or image volume for larger read-only bundles
- Use GitOps (Argo CD or Flux) to render content into Kubernetes objects
Decision guide
| Requirement | Recommended approach |
|---|---|
| Content fixed per release | Bake into image |
| Small config files | ConfigMap |
| Clone once at pod start | Init container + emptyDir |
| Content changes while pod runs | git-sync sidecar |
| Private repository | git-sync or init container with credentials |
| Strict supply-chain controls | Bake into image and sign it |
Core System Prerequisites
Before starting a gitRepo volume replacement, confirm:
- kubectl and jq on your workstation for discovery
- Access to manifests and Helm charts in Git, not just the live cluster
- A container image with Git, such as the official git-sync image from
registry.k8s.io, or a minimal image containinggit - Credentials as Kubernetes Secrets (deploy keys or tokens) for private repositories
- Egress network access from pods to your Git host, which the kubelet may have had but pods may not
- Kubernetes 1.30 or later if you plan to use ValidatingAdmissionPolicy to block gitRepo volumes
Step-by-Step gitRepo Volume Replacement
Step 1: Find every gitRepo volume in the cluster
Search running pods first:
kubectl get pods -A -o json | jq -r '
.items[]
| select(any(.spec.volumes[]?; .gitRepo != null))
| "\(.metadata.namespace)/\(.metadata.name)\t\([.spec.volumes[] | select(.gitRepo) | .gitRepo.repository] | join(","))"'
Then search controllers, because a scaled-to-zero Deployment or a CronJob that has not run recently will not show up as a pod:
for kind in deployments statefulsets daemonsets jobs cronjobs; do
kubectl get "$kind" -A -o json | jq -r --arg k "$kind" '
.items[]
| (.spec.template.spec // .spec.jobTemplate.spec.template.spec) as $p
| select(any($p.volumes[]?; .gitRepo != null))
| "\($k)\t\(.metadata.namespace)/\(.metadata.name)"'
done
Step 2: Search manifests and Helm charts in Git
Live-cluster searches miss workloads that are not deployed yet. Scan your repositories too:
grep -rnE "^\s*gitRepo:" --include="*.yaml" --include="*.yml" --include="*.tpl" .
Render Helm charts before searching, because templates may only emit gitRepo under certain values:
helm template my-release ./charts/my-app -f values-prod.yaml | grep -n "gitRepo:" || echo "clean"
Step 3: Replace with an init container and emptyDir
Here is a typical legacy definition:
# BEFORE: fails to start on Kubernetes 1.36+
volumes:
- name: site
gitRepo:
repository: "https://github.com/example/docs-site.git"
revision: "v2.4.0"
And its replacement:
# AFTER: clone once at startup, inside the pod's security context
apiVersion: apps/v1
kind: Deployment
metadata:
name: docs-site
spec:
replicas: 2
selector:
matchLabels: { app: docs-site }
template:
metadata:
labels: { app: docs-site }
spec:
securityContext:
runAsNonRoot: true
runAsUser: 65533
fsGroup: 65533
initContainers:
- name: clone
image: registry.k8s.io/git-sync/git-sync:v4.4.0 # pin a tested tag
args:
- --repo=https://github.com/example/docs-site.git
- --ref=v2.4.0
- --root=/git
- --link=current
- --one-time
- --depth=1
volumeMounts:
- name: site
mountPath: /git
containers:
- name: web
image: nginxinc/nginx-unprivileged:1.27-alpine
volumeMounts:
- name: site
mountPath: /usr/share/nginx/html
subPath: current
readOnly: true
volumes:
- name: site
emptyDir: {}
Using git-sync with --one-time as the init container gives you the same atomic checkout and credential handling as the sidecar pattern, without a long-running process. Note that a subPath mount resolves the symlink once at startup, which is fine for clone-once content.
Step 4: Replace with a git-sync sidecar for live content
When content must update without restarting the pod, run git-sync alongside the app and point the app at the symlink:
spec:
template:
spec:
securityContext:
runAsNonRoot: true
fsGroup: 65533
containers:
- name: git-sync
image: registry.k8s.io/git-sync/git-sync:v4.4.0
args:
- --repo=git@github.com:example/airflow-dags.git
- --ref=main
- --root=/git
- --link=current
- --period=60s
- --max-failures=10
- --ssh-key-file=/etc/git-secret/ssh
- --ssh-known-hosts-file=/etc/git-secret/known_hosts
- --http-bind=:2020
readinessProbe:
httpGet: { path: /, port: 2020 }
resources:
requests: { cpu: 10m, memory: 32Mi }
limits: { memory: 128Mi }
volumeMounts:
- { name: content, mountPath: /git }
- { name: git-secret, mountPath: /etc/git-secret, readOnly: true }
- name: app
image: registry.example.com/dag-runner:3.1.0
env:
- name: CONTENT_DIR
value: /content/current
volumeMounts:
- { name: content, mountPath: /content, readOnly: true }
volumes:
- name: content
emptyDir: {}
- name: git-secret
secret:
secretName: git-deploy-key
defaultMode: 0400
The application should always read through /content/current. git-sync swaps that symlink only after a complete checkout, so readers never see half-updated files.
Step 5: Store credentials safely
Create the SSH deploy key Secret, including known hosts so git-sync can verify the server:
ssh-keyscan github.com > known_hosts
kubectl create secret generic git-deploy-key \
--from-file=ssh=./deploy_key \
--from-file=known_hosts=./known_hosts \
-n data-pipelines
Use read-only deploy keys scoped to a single repository. For HTTPS, use --username with --password-file pointing at a mounted token, which git-sync re-reads before each sync so rotated tokens take effect.
Step 6: Trigger actions after each sync
If the app needs to reload after new content arrives, git-sync can call a webhook or run a command:
args:
- --webhook-url=http://localhost:8080/-/reload
- --webhook-method=POST
- --webhook-success-status=200
Hooks may run more than once for the same commit, so make reload endpoints idempotent.
Step 7: Block gitRepo volumes for good
After migrating, stop new gitRepo volumes at admission time. This ValidatingAdmissionPolicy follows the approach recommended in KEP-5040:
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicy
metadata:
name: deny-gitrepo-volumes
spec:
failurePolicy: Fail
matchConstraints:
resourceRules:
- apiGroups: [""]
apiVersions: ["v1"]
operations: ["CREATE", "UPDATE"]
resources: ["pods"]
- apiGroups: ["apps"]
apiVersions: ["v1"]
operations: ["CREATE", "UPDATE"]
resources: ["deployments", "statefulsets", "daemonsets", "replicasets"]
- apiGroups: ["batch"]
apiVersions: ["v1"]
operations: ["CREATE", "UPDATE"]
resources: ["jobs", "cronjobs"]
variables:
- name: podSpec
expression: >-
object.kind == 'Pod' ? object.spec :
object.kind == 'CronJob' ? object.spec.jobTemplate.spec.template.spec :
object.spec.template.spec
validations:
- expression: >-
!has(variables.podSpec.volumes) ||
variables.podSpec.volumes.all(v, !has(v.gitRepo))
message: "gitRepo volumes are removed; use an init container or git-sync instead."
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicyBinding
metadata:
name: deny-gitrepo-volumes
spec:
policyName: deny-gitrepo-volumes
validationActions: ["Deny"]
Blocking at the controller level means the error appears on kubectl apply, not hours later when the kubelet refuses a pod.
Plan the rollout
Most estates have only a handful of gitRepo users, so the migration is small. Plan it anyway, because these workloads often belong to teams who have not touched them in years:
- Assign an owner to every workload found in Steps 1 and 2.
- Choose the pattern for each one using the decision guide above.
- Test on a 1.36+ staging cluster, where gitRepo already fails, so you can prove the fix works.
- Roll out before the production control plane upgrade, not after it.
- Switch the admission policy from Warn to Deny once the inventory is empty.
A short tracking table with owner, pattern, status and date keeps the work visible until it is done.
Step 8: Verify on a 1.36+ staging cluster
Deploy the migrated workloads to a staging cluster on 1.36 or later and confirm:
- Pods reach
Runningand init containers complete kubectl logs <pod> -c git-syncshows successful syncs- The application serves the expected commit (check the symlink target, which is the commit hash)
- The admission policy rejects a test manifest that still uses gitRepo
Architecture & Component Breakdown
How the legacy gitRepo volume worked
- The scheduler placed the pod on a node.
- The kubelet, running as root, created an empty directory.
- The kubelet ran
git cloneandgit checkoutusing the node’s Git binary. - Hooks or crafted repository contents could therefore execute on the host.
- Containers started with the cloned directory mounted. No further updates happened.
How git-sync works
- git-sync runs inside the pod with the pod’s user, group and security context.
- It fetches the repository into
--rootwithout checking out over existing files. - It creates a new worktree for each new commit.
- It atomically repoints the
--linksymlink to the new worktree, named after the commit hash. - It optionally calls a webhook or exec hook, then waits for
--periodbefore polling again.

Comparing the options
| Characteristic | gitRepo (removed) | Init container | git-sync sidecar | Baked into image |
|---|---|---|---|---|
| Runs as | Root on node | Pod user | Pod user | n/a |
| Private repos | No | Yes | Yes | Yes (in CI) |
| Updates while running | No | No | Yes | No |
| Atomic updates | n/a | n/a | Yes (symlink swap) | n/a |
| Extra container | No | Short-lived | Long-running | No |
| Supply-chain control | Weak | Medium | Medium | Strong (signed image) |
| Works on 1.36+ | No | Yes | Yes | Yes |
Real-World Use Cases & Enterprise Examples
Scenario 1: Static documentation site
A team served a docs site from Nginx with a gitRepo volume pinned to a tag. After upgrading staging to 1.36, the pods sat in ContainerCreating with volume errors.
They switched to the init-container pattern with git-sync --one-time. Releases now bump the --ref value, and the site rolls out like any other Deployment.
Scenario 2: Workflow DAGs that change hourly
A data platform loaded pipeline definitions from a repository. Their gitRepo setup only refreshed on restart, so engineers restarted pods manually after merges.
The git-sync sidecar with a 60-second period removed the restarts entirely. The scheduler reads DAGs from the current symlink, and a readiness probe on git-sync’s health port keeps new pods out of rotation until the first sync completes.
Scenario 3: Multi-tenant platform security review
A platform team running shared clusters for several business units found three namespaces using gitRepo during a security review prompted by CVE-2024-10220.
They migrated those workloads, then enabled the admission policy in Deny mode across all clusters, closing the door on node-level code execution through volumes.
Scenario 4: Configuration bundles moved into the image
An internal service cloned a small configuration repository at startup. During the migration, the team realised the configuration only changed with releases.
They moved the files into the container image build and signed the image. The gitRepo volume replacement removed a runtime dependency on the Git host entirely.
Troubleshooting, Edge Cases & Best Practices
Common gitRepo volume replacement errors and fixes
Pod stuck in ContainerCreating with a gitRepo error
The kubelet on 1.36+ refuses gitRepo volumes. Migrate the workload; the gate cannot be re-enabled.
git-sync fails with “Host key verification failed”
Mount a known_hosts file and pass --ssh-known-hosts-file, or the SSH client cannot verify the Git server.
Permission denied reading synced files
The app runs as a different user from git-sync. Set a shared fsGroup in the pod security context, or use git-sync’s --group-write option.
Application sees an empty directory
It is reading --root instead of the --link symlink. Point the app at /content/current, not /content.
Content never updates in the app container
The app mounts the volume with subPath: current, which resolves the symlink only once. Mount the whole volume and read through the symlink for live updates.
git-sync cannot reach the Git host
Pods may not have the egress that nodes had. Update NetworkPolicies, proxies or firewall rules for the Git host.
gitRepo volume replacement best practices
- Search controllers and Git, not just running pods.
- Prefer baking content into images when it only changes per release.
- Use git-sync for live content and always read through the symlink.
- Pin git-sync image tags and update them deliberately.
- Use read-only, single-repository credentials.
- Run as non-root with a shared
fsGroup. - Block gitRepo at admission so the problem cannot return.
- Finish before upgrading to 1.36, and pair it with the rest of our Kubernetes 1.37 upgrade checklist.
FAQ
Is the Kubernetes gitRepo volume removed?
The gitRepo volume driver is disabled. It has been off by default since Kubernetes 1.33, the GitRepoVolumeDriver feature gate is locked off from 1.36, and the driver code is planned for removal in 1.39. The API server still accepts gitRepo volumes, but the kubelet refuses to run pods that use them.
What should I use instead of a gitRepo volume?
Use an init container that clones the repository into an emptyDir volume when the content is only needed at startup, or a git-sync sidecar when the content must stay up to date. If the content only changes with releases, building it into the container image or using a ConfigMap is often simpler.
Why was the gitRepo volume removed?
The kubelet performed the clone as root on the node, which created security problems. CVE-2024-10220 allowed arbitrary command execution on the node through crafted repositories, and CVE-2025-1767 allowed access to other pods’ local repositories. The driver was long deprecated and unmaintained.
Can I re-enable gitRepo volumes on Kubernetes 1.36?
No. From Kubernetes 1.36 the GitRepoVolumeDriver feature gate is locked to false, so it cannot be turned back on. On 1.33 to 1.35 it could be re-enabled as a temporary stopgap, but that was never recommended.
How does git-sync avoid serving half-updated files?
git-sync checks out each new commit into a separate worktree and then atomically switches a symlink to point at it. Applications that read through the symlink, such as /content/current, always see a complete checkout, never a partial update.
Summary & Key Takeaways
- gitRepo volumes are locked off since Kubernetes 1.36, off by default since 1.33, and the driver is planned for removal in 1.39.
- The API still accepts them, so failures appear only when the kubelet refuses the pod.
- Security drove the removal: CVE-2024-10220 allowed root command execution on nodes, and CVE-2025-1767 was never patched.
- Replace with an init container + emptyDir for clone-once content, or a git-sync sidecar for live content.
- Consider baking content into images or using ConfigMaps when runtime cloning is unnecessary.
- Block gitRepo with a ValidatingAdmissionPolicy after migrating.
A gitRepo volume replacement is one of the quickest wins on any Kubernetes upgrade list. A few manifest changes remove a node-level security risk and make your workloads compatible with every release from 1.36 onward.
For the other node and runtime changes in the same release window, see our guides to the cgroup v2 migration and containerd 2.0.
Editorial note: The timeline and recommended replacements come from KEP-5040: Remove gitRepo volume driver. git-sync behaviour and flags follow the official git-sync project. Vulnerability details refer to CVE-2024-10220 and CVE-2025-1767. Check the git-sync release notes for the current image tag before deploying.
