【问题标题】:Kubernetes: how to use gitRepo volume?Kubernetes:如何使用 gitRepo 卷?
【发布时间】:2015-08-30 21:07:51
【问题描述】:

谁能举例说明如何在 Kubernetes 中使用 gitRepo 类型的卷?

文档说它是一个插件,不知道这意味着什么。在任何地方都找不到示例,我不知道正确的语法。

特别是是否有参数可以拉出特定分支、使用凭据(用户名、密码或 SSH 密钥)等...

编辑: 浏览 Kubernetes 代码,这是我目前的想法:

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

但看不到让它工作,不知道如何解决这个问题

【问题讨论】:

标签: docker kubernetes


【解决方案1】:

这是我使用的示例应用程序:

{
  "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"
            }
          }
        ]
      }
    }
  }
}

您也可以使用修订版。

PS:上面的 repo 已经不存在了。

【讨论】:

    【解决方案2】:

    更新

    gitRepo 现已弃用

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

    原始答案

    通过代码,这是我的想法:

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

    在我的 mountPath 中修正错别字后,它工作正常。

    【讨论】:

      猜你喜欢
      • 2018-09-04
      • 1970-01-01
      • 2020-01-02
      • 2020-03-17
      • 2022-10-24
      • 2018-12-02
      • 1970-01-01
      • 2016-01-10
      • 2023-03-18
      相关资源
      最近更新 更多