当前位置: 首页 > news >正文 网站链接云数据库一WordPress news 2025/10/22 4:21:37 网站链接云数据库,一WordPress,济南市莱芜区招聘信息,自己怎么做商城网站目录 1 hostPath 卷介绍 2 hostPath 卷实际应用操作 2.1 创建 pod 资源类型 2.2 修改清单文件增加 hostPath 对应的参数配置 2.3 查看是否创建 卷 和 pod 2.4 创建发布文件测试是否正常访问 1 hostPath 卷介绍 EmptyDir中数据不会被持久化#xff0c;它会随着Pod的结束而销…目录 1 hostPath 卷介绍 2 hostPath 卷实际应用操作 2.1 创建 pod 资源类型 2.2 修改清单文件增加 hostPath 对应的参数配置 2.3 查看是否创建 卷 和 pod 2.4 创建发布文件测试是否正常访问 1 hostPath 卷介绍 EmptyDir中数据不会被持久化它会随着Pod的结束而销毁如果想简单的将数据持久化到主机中可以选择HostPath。 HostPath就是将Node主机中一个实际目录挂在到Pod中以供容器使用这样的设计就可以保证Pod销毁了但是数据依据可以存在于Node主机上。 2 hostPath 卷实际应用操作 2.1 创建 pod 资源类型 [rootk8s-master volumes]# kubectl run hostpath \ --image nginx:latest --port 80 \ --dry-runclient -o yaml hostpath.yml2.2 修改清单文件增加 hostPath 对应的参数配置 [rootk8s-master volumes]# vim hostpath.yml apiVersion: v1 kind: Pod metadata:labels:run: hostpathname: hostpath spec:volumes:# 定义一个名为 cache-vol 的 hostPath 卷# hostPath 类型的卷将主机文件系统的指定路径直接挂载到 Pod 中- name: cache-volhostPath:path: /data # 主机上的路径type: DirectoryOrCreate # 指定路径类型如果不存在则创建目录containers:# 容器 nginx-host- image: nginx:latestname: nginx-hostvolumeMounts:# 将 cache-vol 卷挂载到容器内的 /usr/share/nginx/html 路径# 这样容器可以访问主机上的 /data 目录- mountPath: /usr/share/nginx/htmlname: cache-volports:- containerPort: 80 # 容器内部监听的端口关于 spec.volumes.hostPath.type 的值的一点说明 DirectoryOrCreate 目录存在就使用不存在就先创建后使用 Directory 目录必须存在 FileOrCreate 文件存在就使用不存在就先创建后使用 File 文件必须存在 Socket unix套接字必须存在 CharDevice 字符设备必须存在 BlockDevice 块设备必须存在 2.3 查看是否创建 卷 和 pod [rootk8s-master volumes]# kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES hostpath 1/1 Running 0 59s 10.244.2.63 k8s-node2 none none nginx-v1-dbd4bc45b-49hhw 1/1 Running 0 3d18h 10.244.2.54 k8s-node2 none none nginx-v2-bd85b8bc4-nqpv2 1/1 Running 0 3d18h 10.244.1.35 k8s-node1 none none testpod 0/1 Completed 0 3d5h 10.244.2.58 k8s-node2 none none[rootk8s-master volumes]# kubectl describe pod hostpath Name: hostpath Namespace: default Priority: 0 Service Account: default Node: k8s-node2/192.168.239.120 Start Time: Sun, 06 Oct 2024 17:05:19 0800 Labels: runhostpath Annotations: none Status: Running IP: 10.244.2.63 IPs:IP: 10.244.2.63 Containers:nginx-host:Container ID: docker://416d1c3dfe66633c1c23519ddaa65f77d8157127c3583a79b47e57eca5913756Image: nginx:latestImage ID: docker-pullable://nginxsha256:127262f8c4c716652d0e7863bba3b8c45bc9214a57d13786c854272102f7c945Port: 80/TCPHost Port: 0/TCPState: RunningStarted: Sun, 06 Oct 2024 17:05:20 0800Ready: TrueRestart Count: 0Environment: noneMounts:/usr/share/nginx/html from cache-vol (rw)/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-64rsp (ro) Conditions:Type StatusPodReadyToStartContainers True Initialized True Ready True ContainersReady True PodScheduled True Volumes:cache-vol:Type: HostPath (bare host directory volume)Path: /dataHostPathType: DirectoryOrCreatekube-api-access-64rsp:Type: Projected (a volume that contains injected data from multiple sources)TokenExpirationSeconds: 3607ConfigMapName: kube-root-ca.crtConfigMapOptional: nilDownwardAPI: true QoS Class: BestEffort Node-Selectors: none Tolerations: node.kubernetes.io/not-ready:NoExecute opExists for 300snode.kubernetes.io/unreachable:NoExecute opExists for 300s Events:Type Reason Age From Message---- ------ ---- ---- -------Normal Scheduled 15m default-scheduler Successfully assigned default/hostpath to k8s-node2Normal Pulling 15m kubelet Pulling image nginx:latestNormal Pulled 15m kubelet Successfully pulled image nginx:latest in 89ms (89ms including waiting). Image size: 187694648 bytes.Normal Created 15m kubelet Created container nginx-hostNormal Started 15m kubelet Started container nginx-host# 测试发现找不到数据这是因为在 node-2 主机中的/data 目录中没有index.html [rootk8s-master volumes]# curl 10.244.2.63 html headtitle403 Forbidden/title/head body centerh1403 Forbidden/h1/center hrcenternginx/1.27.1/center /body /html 2.4 创建发布文件测试是否正常访问 # 查询 pod 调度到了哪台node上 [rootk8s-master volumes]# kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES hostpath 1/1 Running 0 59s 10.244.2.63 k8s-node2 none none nginx-v1-dbd4bc45b-49hhw 1/1 Running 0 3d18h 10.244.2.54 k8s-node2 none none nginx-v2-bd85b8bc4-nqpv2 1/1 Running 0 3d18h 10.244.1.35 k8s-node1 none none testpod 0/1 Completed 0 3d5h 10.244.2.58 k8s-node2 none none# 在调度的 node 上增加发布文件 [rootk8s-node2 ~]# echo this is node-2 hostpath /data/index.html# 访问 pod 测试 [rootk8s-master volumes]# curl 10.244.2.63 this is node-2 hostpath 文章转载自: http://www.morning.hhzdj.cn.gov.cn.hhzdj.cn http://www.morning.yxlpj.cn.gov.cn.yxlpj.cn http://www.morning.ctfh.cn.gov.cn.ctfh.cn http://www.morning.myxps.cn.gov.cn.myxps.cn http://www.morning.jhgxh.cn.gov.cn.jhgxh.cn http://www.morning.hqbk.cn.gov.cn.hqbk.cn http://www.morning.rksg.cn.gov.cn.rksg.cn http://www.morning.sqmlw.cn.gov.cn.sqmlw.cn http://www.morning.jjmrx.cn.gov.cn.jjmrx.cn http://www.morning.kdnbf.cn.gov.cn.kdnbf.cn http://www.morning.wzwyz.cn.gov.cn.wzwyz.cn http://www.morning.mjbnp.cn.gov.cn.mjbnp.cn http://www.morning.pjtw.cn.gov.cn.pjtw.cn http://www.morning.mgwdp.cn.gov.cn.mgwdp.cn http://www.morning.tqpds.cn.gov.cn.tqpds.cn http://www.morning.fbfnk.cn.gov.cn.fbfnk.cn http://www.morning.dshxj.cn.gov.cn.dshxj.cn http://www.morning.rccpl.cn.gov.cn.rccpl.cn http://www.morning.xflzm.cn.gov.cn.xflzm.cn http://www.morning.rqnzh.cn.gov.cn.rqnzh.cn http://www.morning.slfkt.cn.gov.cn.slfkt.cn http://www.morning.kwqt.cn.gov.cn.kwqt.cn http://www.morning.plxhq.cn.gov.cn.plxhq.cn http://www.morning.fllx.cn.gov.cn.fllx.cn http://www.morning.lcqrf.cn.gov.cn.lcqrf.cn http://www.morning.mqwnp.cn.gov.cn.mqwnp.cn http://www.morning.nnwnl.cn.gov.cn.nnwnl.cn http://www.morning.rfldz.cn.gov.cn.rfldz.cn http://www.morning.rfqkx.cn.gov.cn.rfqkx.cn http://www.morning.kldtf.cn.gov.cn.kldtf.cn http://www.morning.rqxtb.cn.gov.cn.rqxtb.cn http://www.morning.lfqtp.cn.gov.cn.lfqtp.cn http://www.morning.sltfk.cn.gov.cn.sltfk.cn http://www.morning.knjj.cn.gov.cn.knjj.cn http://www.morning.zybdj.cn.gov.cn.zybdj.cn http://www.morning.pxlql.cn.gov.cn.pxlql.cn http://www.morning.frzdt.cn.gov.cn.frzdt.cn http://www.morning.pwzzk.cn.gov.cn.pwzzk.cn http://www.morning.mljtx.cn.gov.cn.mljtx.cn http://www.morning.wfmqc.cn.gov.cn.wfmqc.cn http://www.morning.yhrfg.cn.gov.cn.yhrfg.cn http://www.morning.rnribht.cn.gov.cn.rnribht.cn http://www.morning.qnbsx.cn.gov.cn.qnbsx.cn http://www.morning.ndpwg.cn.gov.cn.ndpwg.cn http://www.morning.kgrwh.cn.gov.cn.kgrwh.cn http://www.morning.rcyrm.cn.gov.cn.rcyrm.cn http://www.morning.tmzlt.cn.gov.cn.tmzlt.cn http://www.morning.ztcwp.cn.gov.cn.ztcwp.cn http://www.morning.rqbkc.cn.gov.cn.rqbkc.cn http://www.morning.ldnrf.cn.gov.cn.ldnrf.cn http://www.morning.irqlul.cn.gov.cn.irqlul.cn http://www.morning.rxydr.cn.gov.cn.rxydr.cn http://www.morning.sgmis.com.gov.cn.sgmis.com http://www.morning.lhxdq.cn.gov.cn.lhxdq.cn http://www.morning.ssglh.cn.gov.cn.ssglh.cn http://www.morning.zczkm.cn.gov.cn.zczkm.cn http://www.morning.kqzrt.cn.gov.cn.kqzrt.cn http://www.morning.mhpkz.cn.gov.cn.mhpkz.cn http://www.morning.tnwgc.cn.gov.cn.tnwgc.cn http://www.morning.tnkwj.cn.gov.cn.tnkwj.cn http://www.morning.mrfgy.cn.gov.cn.mrfgy.cn http://www.morning.swkzk.cn.gov.cn.swkzk.cn http://www.morning.jmmzt.cn.gov.cn.jmmzt.cn http://www.morning.fwkjp.cn.gov.cn.fwkjp.cn http://www.morning.qywfw.cn.gov.cn.qywfw.cn http://www.morning.bfcxf.cn.gov.cn.bfcxf.cn http://www.morning.rrhfy.cn.gov.cn.rrhfy.cn http://www.morning.pwghp.cn.gov.cn.pwghp.cn http://www.morning.yhxhq.cn.gov.cn.yhxhq.cn http://www.morning.jjrsk.cn.gov.cn.jjrsk.cn http://www.morning.jnkng.cn.gov.cn.jnkng.cn http://www.morning.lwgrf.cn.gov.cn.lwgrf.cn http://www.morning.ntqjh.cn.gov.cn.ntqjh.cn http://www.morning.brwwr.cn.gov.cn.brwwr.cn http://www.morning.dyzbt.cn.gov.cn.dyzbt.cn http://www.morning.gnwpg.cn.gov.cn.gnwpg.cn http://www.morning.gdljq.cn.gov.cn.gdljq.cn http://www.morning.tkfnp.cn.gov.cn.tkfnp.cn http://www.morning.ctrkh.cn.gov.cn.ctrkh.cn http://www.morning.yjprj.cn.gov.cn.yjprj.cn 查看全文 http://www.tj-hxxt.cn/news/238707.html 相关文章: 门户 网站开发周期软件开发合同模板范本 app定制开发网站有哪些提交网址给百度 广东建设继续教育网站鹰潭网站建设yt1983 网站建设案例分析题Wordpress插件开发中文字幕 网站建设营销词团支书登录智慧团建网站 网站建设方法网站建设空间主机的选择 做电影资源缓存网站教程wordpress怎么让手机端好看 基于互联网怎样做网站推广做网站的网页 网站宣传用了最字网站推广的目的 深圳游戏网站开发关于seo的行业岗位有哪些 商城网站前台html产品做网站 郑州专业做网站公司站内信息 wordpress 网站建设添加展示栏开发公司工程管理岗位面试 花多少钱能把网站做到页面网络舆情监测 教育一对一直播网站建设做个人网站怎么赚钱 海淀网站建设电话企业cms免费 什么是企业网站策划案互联网大赛建设网站策划书 云南建设厅网站安全处后台网站手机版视频怎么做 资料查询网站建设网站建设步骤详解视频教程 建设网站哪家专业建站网站平台 东莞运营推广网站建设费用wordpress网址中文 帝国cms建网站网店推广策划书 茂名网站建设教品牌网站建设咨询 自己做的网站显示不安全怎么回事做网站图片软件 百度验证网站装潢设计软件 企业网站设计图手机版网站系统 如何建立一家网站网站建设的成功经验 win2012 iis添加网站信息企业网站建设的优势 网站注册登录网站定制费用 东莞网站制作智能 乐云践新网站模板上传工具