關于k8s中subpath的使用詳解
更新時間:2022年02月25日 15:13:15 作者:fengjian1585
這篇文章主要介紹了k8s中subpath的使用,文章介紹分為兩種情況給大家詳細講解,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
有兩種情況:
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-data2.作為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
到此這篇關于關于k8s中subpath的使用詳解的文章就介紹到這了,更多相關k8s subpath使用內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
您可能感興趣的文章:
相關文章
Istio 自動注入 sidecar 失敗導致無法訪問webhook服務的解決方法
最近工作中在部署Istio環(huán)境的過程中發(fā)現(xiàn)官方示例啟動的pod不能訪問不到Istio的webhook,這個問題也是困擾了我一天,我把他歸類到sidecar注入失敗的情況下,本文給大家分享問題解決方法,感興趣的朋友跟隨小編一起看看吧2023-10-10
Rainbond部署組件Statefulset的使用官方文檔
這篇文章主要為大家介紹了官方文檔Rainbond部署組件Statefulset的使用,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-04-04
K8S?實用工具之合并多個kubeconfig實現(xiàn)詳解
這篇文章主要為大家介紹了K8S?實用工具之合并多個kubeconfig實現(xiàn)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-03-03
K8S部署Kafka界面管理工具(kafkamanager)方法詳解
這篇文章主要介紹了K8S部署Kafka界面管理工具(kafkamanager)方法詳解,需要的朋友可以參考下2022-01-01
Kubernetes(k8s?1.23))安裝與卸載詳細教程
這篇文章主要介紹了Kubernetes(k8s?1.23))安裝與卸載,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-07-07
云原生技術kubernetes調(diào)度單位pod的使用詳解
這篇文章主要介紹了云原生技術kubernetes調(diào)度單位pod的使用詳解,幫助大家更好的理解和學習使用K8S,感興趣的朋友可以了解下2021-03-03

