关于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使用内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
您可能感兴趣的文章:
相关文章
Istio 自动注入 sidecar 失败导致无法访问webhook服务的解决方法
最近工作中在部署Istio环境的过程中发现官方示例启动的pod不能访问不到Istio的webhook,这个问题也是困扰了我一天,我把他归类到sidecar注入失败的情况下,本文给大家分享问题解决方法,感兴趣的朋友跟随小编一起看看吧2023-10-10
Rainbond部署组件Statefulset的使用官方文档
这篇文章主要为大家介绍了官方文档Rainbond部署组件Statefulset的使用,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪2022-04-04
K8S部署Kafka界面管理工具(kafkamanager)方法详解
这篇文章主要介绍了K8S部署Kafka界面管理工具(kafkamanager)方法详解,需要的朋友可以参考下2022-01-01
Kubernetes(k8s 1.23))安装与卸载详细教程
这篇文章主要介绍了Kubernetes(k8s 1.23))安装与卸载,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下2022-07-07


最新评论