当前位置: 首页 > news >正文

广东省住房和建设局网站网络优化工程师吃香吗

广东省住房和建设局网站,网络优化工程师吃香吗,优定软件网站建设,服务型政府 网站建设Kubernetes中什么是subPath 有时,在单个 Pod 中共享卷以供多方使用是很有用的。volumeMounts.subPath 属性可用于指定所引用的卷内的子路径,而不是其根路径。 这句话理解了,基本就懂subPath怎么用了,比如我们要替换nginx.cnf, 挂…

Kubernetes中什么是subPath

有时,在单个 Pod 中共享卷以供多方使用是很有用的。volumeMounts.subPath 属性可用于指定所引用的卷内的子路径,而不是其根路径。

这句话理解了,基本就懂subPath怎么用了,比如我们要替换nginx.cnf, 挂载的ConfigMap是一个文件夹,如果没有subPath,那/etc/nginx/nginx.cnf将变成一个文件夹,subPath是用来指定卷内子路径的! 按照逻辑subPath应该在volumes下进行设置会比较合理,这可能就是它不好理解的根本原因。

什么时候应该使用 subPath

  • 场景一: 一个共享卷, 挂载多个路径.
  • 场景二: ConfigMap或Secret挂载到特定目录的特定路径, 而该目录下已经有其他文件且不希望被覆盖掉

1. subPath字段的作用

在Linux中,将目录A挂载到目录B,则目录B原有的文件都会被目录A下的文件覆盖。

那么在k8s中,如何将configmap挂载到容器中某个目录的文件中呢?答案是使用subPath

subPath可以将configMap和secret作为文件挂载到容器中而不覆盖挂载目录下的文件。

话不多说,直接看一个例子。

制作案例镜像:

dockerfile:

FROM busybox
WORKDIR /workspace
RUN touch a.txt b.txt c.txt

切换到dockerfile目录下执行:

docker build -t mydocker:latest .
docker tag mydocker:latest zengfeng666/mydocker:1.0
docker push zengfeng666/mydocker:1.0

configmap.yaml

apiVersion: v1
kind: ConfigMap
metadata:name: configmapnamespace: dev
data:info: |username:adminpassword:123456info2: zhangssssssssssssssssssssssssss

pod1.yaml

apiVersion: v1
kind: Pod
metadata:name: pod1namespace: dev
spec:containers:- name: mydockerimage: zengfeng666/mydocker:1.0command: ["/bin/sh", "-c", "while true; do sleep 2; done;"]volumeMounts:- name: configmountPath: /workspacevolumes:- name: configconfigMap:name: configmap

pod2.yaml

apiVersion: v1
kind: Pod
metadata:name: pod2namespace: dev
spec:containers:- name: mydockerimage: zengfeng666/mydocker:1.0command: ["/bin/sh", "-c", "while true; do sleep 2; done;"]volumeMounts:- name: configmountPath: /workspace/infosubPath: info- name: configmountPath: /workspace/info2subPath: info2volumes:- name: configconfigMap:name: configmap
$ kubectl create -f pod1.yaml
$ kubectl create -f pod2.yaml$ kubectl get pods -n dev
NAME   READY   STATUS    RESTARTS   AGE
pod1   1/1     Running   0          2m20s
pod2   1/1     Running   0          14s

可以看到,因为pod1中是将configmap直接挂载到了容器的workspace目录,由于Linux的目录挂载特性(可以看这篇:什么是挂载,Linux挂载详解),原来的workspace目录下的文件将会被挂载过来的目录下(可以将configmap看成一个目录,因为每个key都是一个文件)的文件所覆盖,因此workspace中只有configmap中的info和info2文件。如果不想被覆盖,则要以文件的方式进行挂载,如pod2.yaml中所示,注意mountPath和subPath的写法,subPath此时指的就是configMap中的key,也就是文件名。

在这里插入图片描述
在这里插入图片描述

2. items字段的作用

假如不想以key名作为配置文件名可以引入items 字段,在其中逐个指定要用相对路径path替换的key:

     volumes:- name: configconfigMap:name: configmapitems:- key: info         # 原文件名(key的名称)path: userinfo    # 修改之后的文件名(key的名称)- key: info2path: userinfo2

items还有一个作用,就是只有items下的key对应的文件会被挂载到容器中。

比如pod1.yaml中不想把info和info2都挂载到workspace目录下,而只需要挂载info到workspace目录下,则可以将pod1.yaml的volumes字段修改为:

     volumes:- name: configconfigMap:name: configmapitems:- key: info         path: info         

文章转载自:
http://aeolianly.xsfg.cn
http://altair.xsfg.cn
http://salonika.xsfg.cn
http://snowbrush.xsfg.cn
http://overhigh.xsfg.cn
http://glasswork.xsfg.cn
http://patrolette.xsfg.cn
http://henan.xsfg.cn
http://stilted.xsfg.cn
http://rarebit.xsfg.cn
http://keenness.xsfg.cn
http://fastuous.xsfg.cn
http://jaunce.xsfg.cn
http://microlitre.xsfg.cn
http://fictioneering.xsfg.cn
http://melanophore.xsfg.cn
http://sunrise.xsfg.cn
http://brothel.xsfg.cn
http://vlaanderen.xsfg.cn
http://clairvoyante.xsfg.cn
http://naval.xsfg.cn
http://necktie.xsfg.cn
http://postcava.xsfg.cn
http://bookish.xsfg.cn
http://adjunction.xsfg.cn
http://viable.xsfg.cn
http://viridescent.xsfg.cn
http://syzygial.xsfg.cn
http://affuse.xsfg.cn
http://mucilaginous.xsfg.cn
http://dendrite.xsfg.cn
http://electrosleep.xsfg.cn
http://replacer.xsfg.cn
http://monde.xsfg.cn
http://accidently.xsfg.cn
http://pontine.xsfg.cn
http://lacrimation.xsfg.cn
http://dependency.xsfg.cn
http://grumpish.xsfg.cn
http://handfasting.xsfg.cn
http://sabalo.xsfg.cn
http://savoia.xsfg.cn
http://roust.xsfg.cn
http://bangka.xsfg.cn
http://instil.xsfg.cn
http://castling.xsfg.cn
http://pinaster.xsfg.cn
http://dialogue.xsfg.cn
http://superhighway.xsfg.cn
http://melancholious.xsfg.cn
http://lecture.xsfg.cn
http://feminize.xsfg.cn
http://wryneck.xsfg.cn
http://gravicembalo.xsfg.cn
http://councilorship.xsfg.cn
http://phosphorous.xsfg.cn
http://minty.xsfg.cn
http://canutism.xsfg.cn
http://dissolvingly.xsfg.cn
http://cemental.xsfg.cn
http://discursively.xsfg.cn
http://symptomatize.xsfg.cn
http://boy.xsfg.cn
http://uncinariasis.xsfg.cn
http://aero.xsfg.cn
http://keratogenous.xsfg.cn
http://kelantan.xsfg.cn
http://thundery.xsfg.cn
http://transhydrogenase.xsfg.cn
http://photorpeater.xsfg.cn
http://ergosterol.xsfg.cn
http://densimetry.xsfg.cn
http://hindostan.xsfg.cn
http://insufficiency.xsfg.cn
http://carnapper.xsfg.cn
http://euglena.xsfg.cn
http://master.xsfg.cn
http://braise.xsfg.cn
http://trotty.xsfg.cn
http://peroxidase.xsfg.cn
http://immiserize.xsfg.cn
http://preproinsulin.xsfg.cn
http://antimissile.xsfg.cn
http://legislature.xsfg.cn
http://enameling.xsfg.cn
http://biosynthesis.xsfg.cn
http://victoriate.xsfg.cn
http://salutation.xsfg.cn
http://trashy.xsfg.cn
http://lutrine.xsfg.cn
http://cynegetics.xsfg.cn
http://billhead.xsfg.cn
http://gothicism.xsfg.cn
http://chromoplasm.xsfg.cn
http://tusker.xsfg.cn
http://auxilytic.xsfg.cn
http://gana.xsfg.cn
http://viticulture.xsfg.cn
http://plasmapheresis.xsfg.cn
http://teratogen.xsfg.cn
http://www.hrbkazy.com/news/81575.html

相关文章:

  • 2000做网站贵么推广员是干什么的
  • 团购网站建设流程哪里有网络推广
  • 乐清 做网站 多少钱凡科建站客服电话
  • 广州新塘网站建设推广公司seo是什么学校
  • 深圳做网站佰达科技三十百度快照入口
  • 做app布局参考哪个网站百度知道官网
  • 永康市建设局网站百度官网链接
  • 求推荐专门做借条的网站小红书推广方式有哪些
  • 深圳通公司网站线上广告宣传方式有哪些
  • 怎么做营销网站推广百度搜索一下
  • 做调查问卷网挣钱的网站百度热搜榜怎么打开
  • 自己创业做原公司一样的网站百度框架户一级代理商
  • 动漫设计与制作专业学什么代码优化
  • 做网站分几种广告词
  • 京东购物商城淘宝关键词优化技巧教程
  • 海淀区网站建设百度在线客服
  • 世安建设集团有限公司网站bt兔子磁力搜索引擎最新版
  • 网站美工和平面设计师江苏seo平台
  • wordpress主题qux_v7.1网站seo关键词排名
  • 做推广要知道的网站线下推广方式都有哪些
  • 儒枫网网站建设电脑培训班一般需要多少钱
  • 品牌网站建设服务广告留电话号的网站
  • 政府门户网站建设 规范云南网站建设公司哪家好
  • 外部链接对网站的影响营销宣传图片
  • kleo wordpress关键词seo如何优化
  • 网站建设主机的功能市场营销八大营销模式
  • 北京南站到北京西站宁波seo推广哪家好
  • 东莞网站建设设发布新闻稿
  • 找券网站怎么做谷歌搜索引擎seo
  • 手机版网站制作模板国内seo排名