Skip to content

Commit 41e5f71

Browse files
authored
Merge pull request #45501 from SaranBalaji90/GitRepoVolume
Add CEL Expression to restrict GitRepo volume usage
2 parents 1f95dc8 + ab0b655 commit 41e5f71

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

content/en/docs/concepts/storage/volumes.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,23 @@ third party storage driver instead.
311311
### gitRepo (deprecated) {#gitrepo}
312312

313313
{{< warning >}}
314-
The `gitRepo` volume type is deprecated. To provision a container with a git repo, mount an
315-
[EmptyDir](#emptydir) into an InitContainer that clones the repo using git, then mount the
314+
The `gitRepo` volume type is deprecated.
315+
316+
To provision a Pod that has a Git repository mounted, you can
317+
mount an
318+
[`emptyDir`](#emptydir) volume into an [init container](/docs/concepts/workloads/pods/init-containers/) that
319+
clones the repo using Git, then mount the
316320
[EmptyDir](#emptydir) into the Pod's container.
321+
322+
---
323+
324+
You can restrict the use of `gitRepo` volumes in your cluster using
325+
[policies](/docs/concepts/policy/) such as
326+
[ValidatingAdmissionPolicy](/docs/reference/access-authn-authz/validating-admission-policy/).
327+
You can use the following Common Expression Language (CEL) expression as
328+
part of a policy to reject use of `gitRepo` volumes:
329+
`!has(object.spec.volumes) || !object.spec.volumes.exists(v, has(v.gitRepo))`.
330+
317331
{{< /warning >}}
318332

319333
A `gitRepo` volume is an example of a volume plugin. This plugin

0 commit comments

Comments
 (0)