日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

k8s1.5.4挂载volume之nfs

發(fā)布時間:2024/4/17 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 k8s1.5.4挂载volume之nfs 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

k8s1.5.4掛載volume之nfs

volume的例子集合

https://github.com/kubernetes/kubernetes/tree/master/examples/volumes http://www.dockerinfo.net/2926.html https://kubernetes.io/docs/user-guide/volumes/


其他相關(guān)文檔

k8s集群安裝部署 http://jerrymin.blog.51cto.com/3002256/1898243 k8s集群RC、SVC、POD部署 http://jerrymin.blog.51cto.com/3002256/1900260? k8s集群組件kubernetes-dashboard和kube-dns部署 http://jerrymin.blog.51cto.com/3002256/1900508 k8s集群監(jiān)控組件heapster部署 http://jerrymin.blog.51cto.com/3002256/1904460 k8s集群反向代理負載均衡組件部署 http://jerrymin.blog.51cto.com/3002256/1904463? k8s集群掛載volume之nfs http://jerrymin.blog.51cto.com/3002256/1906778 k8s集群掛載volume之glusterfs http://jerrymin.blog.51cto.com/3002256/1907274


參考github上的例子

[root@k8s-master nfs]# pwd

/usr/local/kubernetes/examples/volumes/nfs

[root@k8s-master nfs]# cat README.md?

##?Quickstart ```console $?kubectl?create?-f?examples/volumes/nfs/provisioner/nfs-server-gce-pv.yaml $?kubectl?create?-f?examples/volumes/nfs/nfs-server-rc.yaml $?kubectl?create?-f?examples/volumes/nfs/nfs-server-service.yaml #?get?the?cluster?IP?of?the?server?using?the?following?command $?kubectl?describe?services?nfs-server #?use?the?NFS?server?IP?to?update?nfs-pv.yaml?and?execute?the?following $?kubectl?create?-f?examples/volumes/nfs/nfs-pv.yaml $?kubectl?create?-f?examples/volumes/nfs/nfs-pvc.yaml #?run?a?fake?backend $?kubectl?create?-f?examples/volumes/nfs/nfs-busybox-rc.yaml #?get?pod?name?from?this?command $?kubectl?get?pod?-l?name=nfs-busybox #?use?the?pod?name?to?check?the?test?file $?kubectl?exec?nfs-busybox-jdhf3?--?cat?/mnt/index.html ```


具體操作

[root@k8s-master nfs]# kubectl create -f provisioner/nfs-server-gce-pv.yaml?

persistentvolumeclaim "nfs-pv-provisioning-demo" created

剛添加的PVC的狀態(tài)是Pending,如果有合適的PV,這個Pending狀態(tài)會立刻變?yōu)锽ound,同時相應(yīng)的PVC也會變?yōu)锽ound。 你也可以先添加PVC,后添加PV,這樣就能保證看到Pending狀態(tài)。


[root@k8s-master nfs]# kubectl create -f nfs-server-rc.yaml?

The ReplicationController "nfs-server" is invalid: spec.template.spec.containers[0].securityContext.privileged: Forbidden: disallowed by policy

查找參數(shù)--allow-privileged為true后k8s將允許在pod中運行擁有系統(tǒng)特權(quán)的容器應(yīng)用

修改/etc/kubernetes/config ?值KUBE_ALLOW_PRIV="--allow-privileged=true"后重啟所有組件

但是這種方式出現(xiàn)了錯誤,錯誤見https://github.com/kubernetes/kubernetes/issues/43120



后調(diào)整了方案:

nfs服務(wù)器不在容器里部署,直接在節(jié)點上部署,然后容器掛載的方式測試,畢竟生存環(huán)境中存儲一般也不會跑在容器里,開始圖方便直接用nfs容器了。nfs服務(wù)器搭建比較簡單,這里省略了。可以參考http://www.cnblogs.com/zhangmingcheng/p/6134210.html。

[root@k8s-master?nfs]#?vim?/etc/exports [root@k8s-master?nfs]#?systemctl?enable?rpcbind.service [root@k8s-master?nfs]#?systemctl?enable?nfs-server.service Created?symlink?from?/etc/systemd/system/multi-user.target.wants/nfs-server.service?to?/usr/lib/systemd/system/nfs-server.service. [root@k8s-master?nfs]#?systemctl?start?rpcbind.service [root@k8s-master?nfs]#?systemctl?start?nfs-server.service [root@k8s-master?nfs]#?rpcinfo?-pprogram?vers?proto???port??service100000????4???tcp????111??portmapper100000????3???tcp????111??portmapper100000????2???tcp????111??portmapper100000????4???udp????111??portmapper100000????3???udp????111??portmapper100000????2???udp????111??portmapper100024????1???udp??37284??status100024????1???tcp??57305??status100005????1???udp??20048??mountd100005????1???tcp??20048??mountd100005????2???udp??20048??mountd100005????2???tcp??20048??mountd100005????3???udp??20048??mountd100005????3???tcp??20048??mountd100003????3???tcp???2049??nfs100003????4???tcp???2049??nfs100227????3???tcp???2049??nfs_acl100003????3???udp???2049??nfs100003????4???udp???2049??nfs100227????3???udp???2049??nfs_acl100021????1???udp??36397??nlockmgr100021????3???udp??36397??nlockmgr100021????4???udp??36397??nlockmgr100021????1???tcp??40459??nlockmgr100021????3???tcp??40459??nlockmgr100021????4???tcp??40459??nlockmgr


主要node節(jié)點, flanneld,docker網(wǎng)絡(luò)都要有掛載權(quán)限才行

[root@k8s-master?nfs]#?exportfs /data/nfs?????10.1.0.0/16 /data/nfs?????10.254.0.0/16 /data/nfs?????172.17.3.0/24 [root@k8s-master?nfs]#?showmount?-e Export?list?for?k8s-master: /data/nfs?172.17.3.0/24,10.254.0.0/16,10.1.0.0/16 [root@k8s-master?nfs]#?vim?nfs-pv.yaml?nfs:#?FIXME:?use?the?right?IPserver:?172.17.3.20path:?"/data/nfs" [root@k8s-master?nfs]#?kubectl?create?-f?nfs-pv.yaml? persistentvolume?"nfs"?created [root@k8s-master?nfs]#?kubectl?create?-f?nfs-pvc.yaml? persistentvolumeclaim?"nfs"?created [root@k8s-master?nfs]#?kubectl?create?-f?nfs-web-rc.yaml? replicationcontroller?"nfs-web"?created [root@k8s-master?nfs]#?kubectl?create?-f?nfs-web-service.yaml? service?"nfs-web"?created

查看PV\PVC狀態(tài)

[root@k8s-master?nfs]#?kubectl?get?pv NAME?????????CAPACITY???ACCESSMODES???RECLAIMPOLICY???STATUS??????CLAIM?????????REASON????AGE nfs??????????100Mi??????RWX???????????Retain??????????Bound???????default/nfs?????????????25m[root@k8s-master?nfs]#?kubectl?get?pvc NAME??????STATUS????VOLUME????CAPACITY???ACCESSMODES???AGE nfs???????Bound?????nfs???????100Mi??????RWX???????????25m


進入容器驗證

[root@k8s-master?~]#?kubectl?get?pods?|grep?nfs-web nfs-web-gj1qr????????1/1???????Running???0??????????7m nfs-web-vrzh4????????1/1???????Running???0??????????8m root@nfs-web-vrzh4:/usr/share/nginx/html#?df?-h?|grep?nginx 172.17.3.20:/data/nfs???????????????????????????????????????????????????????????????????????????????422G??925M??421G???1%?/usr/share/nginx/html [root@k8s-master?~]#?cd?/data/nfs/ [root@k8s-master?nfs]#?echo?'hello?world!'?>?index.html root@nfs-web-vrzh4:/usr/share/nginx/html#?cat?index.html? hello?world! [root@k8s-master?nfs]#?kubectl?get?ep|grep?nfs-web nfs-web????????10.1.15.2:80,10.1.39.11:80???????????????15m [root@k8s-master?nfs]#?curl??10.1.15.2:80 hello?world! [root@k8s-master?nfs]#?curl?10.1.39.11:80 hello?world!


轉(zhuǎn)載于:https://blog.51cto.com/jerrymin/1906778

總結(jié)

以上是生活随笔為你收集整理的k8s1.5.4挂载volume之nfs的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。