網站首頁 編程語言 正文
有兩種情況:
1.做為volumes使用時,subPath代表存儲卷的子路徑:
apiVersion: v1 kind: Pod metadata: name: testpod0 spec: containers: - name: testc image: busybox command: ["/bin/sleep","10000"] volumeMounts: - name: data mountPath: /opt/data # 掛載的路徑 subPath: data # volume的子路徑 mountPath: /opt/model subPath: model volumes: - name: data persistentVolumeClaim: claimName: test-data
2.作為configmap/secret使用時,subPath代表configmap/secret的子路徑:
apiVersion: v1 kind: ConfigMap metadata: name: config-test data: config.ini: "hello" config.conf: "nihao"
單獨掛載一個key為文件
apiVersion: v1 kind: Pod metadata: name: testpod spec: containers: - name: testc image: busybox command: ["/bin/sleep","10000"] volumeMounts: - name: config-test mountPath: /etc/config.ini # 最終在容器中的文件名 subPath: config.ini #要掛載的confmap中的key的名稱 volumes: - name: config-test configMap: name: config-test
掛載多個key為文件:
apiVersion: v1 kind: Pod metadata: name: testpod2 spec: containers: - name: testc image: busybox command: ["/bin/sleep","10000"] volumeMounts: - name: config-test mountPath: /etc/config.ini # 最終在容器中的文件名 subPath: config.ini #要掛載的confmap中的key的名稱 mountPath: /etc/config.conf # 最終在容器中的文件名 subPath: config.conf #要掛載的confmap中的key的名稱 volumes: - name: config-test configMap: name: config-test
多個container掛載不同的key:
apiVersion: v1 kind: Pod metadata: name: testpod1 spec: containers: - name: testc imagePullPolicy: Never image: busybox command: ["/bin/sleep","10000"] volumeMounts: - name: config-test mountPath: /etc/config/config.ini subPath: config.ini - name: testc1 imagePullPolicy: Never image: busybox command: ["/bin/sleep","10000"] volumeMounts: - name: config-test mountPath: /etc/config/config.conf subPath: config.conf volumes: - name: config-test configMap: name: config-test items: - key: config.ini path: config.ini - key: config.conf path: config.conf
摘自
https://soulchild.cn/1911.html
原文鏈接:https://www.cnblogs.com/fengjian2016/p/15935985.html
相關推薦
- 2022-09-24 ASP.NET?MVC實現多選下拉框_實用技巧
- 2022-08-11 python使用prettytable內置庫美化輸出表格_python
- 2022-05-11 spring cloud alibaba nacos搭建最小可運行微服務
- 2022-10-30 Python?Pandas學習之series的二元運算詳解_python
- 2022-04-08 一起來看看五條Python中的隱含特性_python
- 2022-11-20 RC4加密關鍵變量及算法特點原理詳解_腳本加解密
- 2022-11-02 Android?shape標簽使用方法介紹_Android
- 2022-08-28 強制緩存和協商緩存的區別是什么?對稱、非對稱加密的區別是什么?
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支