Kubernetes: how to use gitRepo volume?

8/30/2015

Can someone give an example of how to use the gitRepo type of volume in Kubernetes?

The doc says it's a plugin, not sure what that means. Could not find an example anywhere and i don't know the proper syntax.

especially is there parameters to pull a specific branch, use credentials (username, password, or SSH key) etc...

EDIT: Going through the Kubernetes code this is what I figured so far:

- name: data
  gitRepo:
    repository: "git repo url"
    revision:   "hash of the commit to use"

But can't seen to make it work, and not sure how to troubleshoot this issue

-- MrE
docker
kubernetes

2 Answers

8/30/2015

This is a sample application I used:

{
  "kind": "ReplicationController",
  "apiVersion": "v1",
  "metadata": {
    "name": "tess.io",
    "labels": {
      "name": "tess.io"
    }
  },
  "spec": {
    "replicas": 3,
    "selector": {
      "name": "tess.io"
    },
    "template": {
      "metadata": {
        "labels": {
          "name": "tess.io"
        }
      },
      "spec": {
        "containers": [
          {
            "image": "tess/tessio:0.0.3",
            "name": "tessio",
            "ports": [
              {
                "containerPort": 80,
                "protocol": "TCP"
              }
            ],
            "volumeMounts": [
              {
                "mountPath": "/tess",
                "name": "tess"
              }
            ]
          }
        ],
        "volumes": [
          {
            "name": "tess",
            "gitRepo": {
              "repository": "https://<TOKEN>:x-oauth-basic@github.com/tess/tess.io"
            }
          }
        ]
      }
    }
  }
}

And you can use the revision too.

PS: The repo above does not exist anymore.

-- Uday
Source: StackOverflow

8/30/2015

UPDATE:

gitRepo is now deprecated

https://github.com/kubernetes/kubernetes/issues/60999

ORIGINAL ANSWER:

going through the code this is what i figured:

- name: data
  gitRepo:
    repository: "git repo url"
    revision:   "hash of the commit to use"

after fixing typos in my mountPath, it works fine.

-- MrE
Source: StackOverflow