gitRepo
Last updated
Was this helpful?
Last updated
Was this helpful?
gitRepo卷的生命周期与Pod的生命周期一致。
gitRepo卷通过克隆Git仓库中的内容至卷中,再将卷挂载至容器中。
缺点:当仓库中有更新时,gitRepo卷中的内容并不会被自动同步,需要手动同步。
gitRepo卷在使用时的情况如下:
gitRepo卷的定义和挂载分为下面两步:
定义卷:在Pod的spec.volumes
中定义卷,并且在spec.volumes.gitRepo
中定义该卷相关的配置;
挂载卷:在Pod的spec.containers.volumeMounts
中指定挂载点和挂载的卷名;
下面举一个例子,创建一个名为gitrepo-volume-pod
的Pod,其在内部的名为web-server
的容器在/usr/share/nginx/html
下挂载一个名为html
的gitRepo卷,该卷中的内容是从https://github.com/yangsijie666/kubia-website-example.git
仓库中克隆下来,分支为master
,并且克隆到该卷的根目录: