關(guān)于k8s中subpath的使用詳解
有兩種情況:
1.做為volumes使用時(shí),subPath代表存儲(chǔ)卷的子路徑:
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使用時(shí),subPath代表configmap/secret的子路徑:
apiVersion: v1 kind: ConfigMap metadata: name: config-test data: config.ini: "hello" config.conf: "nihao"
單獨(dú)掛載一個(gè)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
掛載多個(gè)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
多個(gè)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
到此這篇關(guān)于關(guān)于k8s中subpath的使用詳解的文章就介紹到這了,更多相關(guān)k8s subpath使用內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
CentOS?8.2?k8s?基礎(chǔ)環(huán)境配置
這篇文章主要介紹了CentOS?8.2?k8s?基礎(chǔ)環(huán)境配置,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-10-10k8s編排之DaemonSet知識(shí)點(diǎn)詳解
這篇文章主要為大家介紹了k8s編排之DaemonSet知識(shí)點(diǎn)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-01-01詳解Rainbond內(nèi)置ServiceMesh微服務(wù)架構(gòu)
這篇文章主要為大家介紹了詳解Rainbond內(nèi)置ServiceMesh微服務(wù)架構(gòu),有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-04-04Rainbond的ServiceMesh架構(gòu)組件端口沖突處理解決
這篇文章主要大家介紹了Rainbond?ServiceMesh架構(gòu)組件端口沖突處理方式,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-04-04kubernetes日志備份解決ELK中日志丟失問(wèn)題
這篇文章主要為大家介紹了kubernetes日志備份方案的細(xì)節(jié)探究分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-10-10帶你學(xué)會(huì)k8s?更高級(jí)的對(duì)象Deployment
這篇文章主要為大家介紹了k8s還有更高級(jí)的"對(duì)象"Deployment使用示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-04-04IPVS下CoreDNS滾動(dòng)更新解析失敗原理探究
這篇文章主要為大家介紹了IPVS下CoreDNS滾動(dòng)更新解析失敗原理探究,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-03-03Kubernetes訪問(wèn)控制之鑒權(quán)方法詳解
這篇文章主要為大家介紹了Kubernetes訪問(wèn)控制之鑒權(quán)方法詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-09-09