Kubernetes volumes with gitRepo for specific file

11/25/2015

I know how to mount git repo when I start pod. See:

apiVersion: v1
kind: Pod
metadata:
  name: server
spec:
  containers:
  - image: nginx
    name: nginx
    volumeMounts:
    - mountPath: /mypath
      name: git-volume
  volumes:
  - name: git-volume
    gitRepo:
      repository: "git@somewhere:me/my-git-repository.git"
      revision: "22f1d8406d464b0c0874075539c1f2e96c253775"  

That's perfect, but it means that I need to clone whole repository. What I need is to obtain "clone" only one file.

  - name: git-volume
        gitRepo:
          repository: "git@somewhere:me/my-git-repository.git/some/long/path/to/specific/file/configuration.cfg"

Is it possible?

Or can I mount some volume and execute some command in it? Something like:

...
  containers:
  - image: nginx
    name: nginx
    volumeMounts:
    - mountPath: /mypath
      name: git-volume
      command: wget htttp://gitrepo/path/to/file/config.conf

Thanks.

-- jiri463
kubernetes

1 Answer

11/25/2015

You can't clone only one file. gitRepo executes git clone which only allows you to clone the entire repository.

volumeMounts doesn't support executing command in it.

-- janetkuo
Source: StackOverflow