gitRepo is a convenient volume type that clones your existing Git repository into a container:
// an example of how to use gitRepo volume type
# cat 2-6-6_gitRepo.yaml
apiVersion: v1
kind: Pod
metadata:
name: gitrepo
spec:
containers:
- image: ubuntu
name: ubuntu
command:
- sleep
- "3600"
volumeMounts:
- mountPath: /app
name: app-git
volumes:
- name: app-git
gitRepo:
repository: "https://github.com/kubernetes-cookbook/second-edition.git"
revision: "9d8e845e2f55a5c65da01ac4235da6d88ef6bcd0"
# kubectl create -f 2-6-6_gitRepo.yaml
pod "gitrepo" created
In the preceding example, the volume plugin mounts an empty directory and runs the git clone <gitRepo.repolist> to clone the repository into it. Then the Ubuntu container will be able to access it.