首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用哪个Kubernetes configmap符号链接?

使用哪个Kubernetes configmap符号链接?
EN

Server Fault用户
提问于 2021-05-04 00:17:18
回答 1查看 1.9K关注 0票数 2

摘要

应该通过K8s符号链接或普通路径访问..data配置映射吗?

详细信息

我们将一个configmap附加到一个吊舱上

代码语言:javascript
复制
...
        volumeMounts:
        - mountPath: /var/opt/app_configs
          name: app-config
          readOnly: true
...
      volumes:
      - name: app-config
        configMap:
          name: app-kubernetes-configmap

然后,似乎在吊舱内,我们可以通过以下任何一种方式访问配置文件

  • 使用Kubernetes符号链接- /var/opt/app_configs/..data/app-config.yaml
  • 配置文件的“正常”路径- /var/opt/app_configs/app-config.yaml

推荐什么?

EN

回答 1

Server Fault用户

回答已采纳

发布于 2021-05-04 09:38:17

这里要寻找的主要区别是:

  • 如果ConfigMap是用subPath挂载的,则在pod重新启动之前,<#>it不会更新。
  • 如果您将其挂载为一个目录(没有subPath),则<#>your容器将连续获得一个最新配置文件,而不需要重新启动。

使用subPath的示例:

代码语言:javascript
复制
$ kubectl -n production exec go-conf-example-6b4cb86569-22vqv -- ls -lha /app/configfiles 
total 20K    
drwxr-xr-x    1 root     root        4.0K Mar  3 19:34 .
drwxr-xr-x    1 app      app         4.0K Mar  3 19:34 ..
-rw-r--r--    1 root     root          42 Mar  3 19:34 config.json
-rw-r--r--    1 root     root          47 Mar  3 19:34 database.yml

使用目录的示例:

代码语言:javascript
复制
$ kubectl -n production exec go-conf-example-67c768c6fc-ccpwl -- ls -lha /app/configfiles 
total 12K    
drwxrwxrwx    3 root     root        4.0K Mar  3 19:40 .
drwxr-xr-x    1 app      app         4.0K Mar  3 19:34 ..
drwxr-xr-x    2 root     root        4.0K Mar  3 19:40 ..2020_03_03_16_40_36.675612011
lrwxrwxrwx    1 root     root          31 Mar  3 19:40 ..data -> ..2020_03_03_16_40_36.675612011
lrwxrwxrwx    1 root     root          18 Mar  3 19:40 config.json -> ..data/config.json
lrwxrwxrwx    1 root     root          19 Mar  3 19:40 database.yml -> ..data/database.yml

注意,容器中的文件实际上是一个symlink__。

所以,要回答你的问题:

应该通过K8s符号链接或普通路径访问..data配置映射吗?

在您的用例中,您可以在挂载目录时进行双向操作。

我的朋友Vitalii也分享了一些关于用他的回答这个话题的观点。

票数 0
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/1062463

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档