Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes: how to use gitRepo volume?

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

like image 255
MrE Avatar asked Aug 30 '15 21:08

MrE


People also ask

How do volume mounts work in Kubernetes?

A Volume in Kubernetes represents a directory with data that is accessible across multiple containers in a Pod. The container data in a Pod is deleted or lost when a container crashes or restarts, but when you use a volume, the new container can pick up the data at the state before the container crashes.


2 Answers

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>:[email protected]/tess/tess.io"
            }
          }
        ]
      }
    }
  }
}

And you can use the revision too.

PS: The repo above does not exist anymore.

like image 151
Uday Avatar answered Sep 19 '22 00:09

Uday


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.

like image 36
MrE Avatar answered Sep 22 '22 00:09

MrE