k8s-16-k8s基础存储
生活随笔
收集整理的這篇文章主要介紹了
k8s-16-k8s基础存储
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.emptyDir
? pod刪除的時候,volume也就不存在了,生命周期和pod同樣
apiVersion:?v1 kind:?Pod metadata:name:?redis-pod spec:containers:-?image:?redisname:?redisvolumeMounts:-?mountPath:?/cachename:?cache-volumevolumes:-?name:?cache-volumeemptyDir:?{}2.hostpath
? 宿主機上面的目錄,一旦宿主機宕機文件就不存在,不是分布式的
apiVersion:?v1 kind:?Pod metadata:name:?test-host-pd spec:containers:-?image:?nginxname:?test-containervolumeMounts:-?mountPath:?/tmp-testname:?test-volumevolumes:-?name:?test-volumehostPath:path:?/opt/data/type:?Directory3.nfs分布式的但是 nfs本身為單電
192.168.56.12?部署了nfsserver端???所有node節點需要安裝?nfs-utils [root@k8s-node2?nginx]#?cat?/etc/exports /opt/nginx??192.168.56.0/24(rw,no_root_squash) [root@k8s-node2?nginx]#? [root@k8s-node2?nginx]#?cat?/opt/nginx/index.html? nginx-indexapiVersion:?extensions/v1beta1 kind:?Deployment metadata:name:?nginx-deployment spec:replicas:?2template:metadata:labels:app:?nginx-nfsspec:containers:-?name:?nginx-nfsimage:?nginxvolumeMounts:-?name:?nginxdatamountPath:?/usr/share/nginx/htmlports:-?containerPort:?80volumes:-?name:?nginxdatanfs:server:?192.168.56.12path:?/opt/nginx4.glusterfs
192.168.56.11?192.168.56.12安裝glusterfs制作復制卷yum?install?centos-release-gluster??-yyum?install?glusterfs-server?-ysystemctl?start???glusterfsdsystemctl?start????glusterd.servicesystemctl?enable???glusterfsd.servicesystemctl?enable???glusterd.servicegluster?peer??probe??192.168.56.12?#在192.168.56.11上面 gluster?volume?create?nginx-volume?replica?2?192.168.56.11:/opt/data???192.168.56.12:/opt/data??forceglusterfs???volume?start??nginx-volume? gluster?volume?info?nginx-volume創建endpoint? ?kubectl create -f? ed.yaml
{"kind":?"Endpoints","apiVersion":?"v1","metadata":?{"name":?"glusterfs-cluster"},"subsets":?[{"addresses":?[{"ip":?"192.168.56.11"}],"ports":?[{"port":?1}]},{"addresses":?[{"ip":?"192.168.56.12"}],"ports":?[{"port":?1}]}] }??kubectl?create?-f??service.yaml{"kind":?"Service","apiVersion":?"v1","metadata":?{"name":?"glusterfs-cluster"},"spec":?{"ports":?[{"port":?1}]} }apiVersion:?extensions/v1beta1 kind:?Deployment metadata:name:?nginx-deployment-glusterfs spec:replicas:?3template:metadata:labels:app:?nginx-gfspec:containers:-?name:?nginx-gfimage:?nginxvolumeMounts:-?name:?glusterfsvolmountPath:?/usr/share/nginx/htmlports:-?containerPort:?80volumes:-?name:?glusterfsvolglusterfs:endpoints:?glusterfs-clusterpath:?nginx-volumereadOnly:?false---apiVersion:?v1 kind:?Service metadata:name:?nginx-service-gf spec:selector:app:?nginx-gfports:-?name:?httpport:?80protocol:?TCPtargetPort:?80type:?NodePort[root@k8s-master?volume]#?kubectl??get??svc?-o?wide? NAME????????????????TYPE????????CLUSTER-IP?????EXTERNAL-IP???PORT(S)??????????AGE???????SELECTOR glusterfs-cluster???ClusterIP???10.10.10.42????<none>????????1/TCP????????????16m???????<none> httpd???????????????ClusterIP???10.10.10.113???<none>????????80/TCP???????????6d????????run=httpd kubernetes??????????ClusterIP???10.10.10.1?????<none>????????443/TCP??????????14d???????<none> my-service??????????ClusterIP???10.10.10.120???<none>????????80/TCP,443/TCP???7d????????app=nginx nginx???????????????ClusterIP???10.10.10.164???<none>????????80/TCP???????????6d????????run=nginx nginx-service???????NodePort????10.10.10.84????<none>????????88:36741/TCP?????14d???????run=nginx nginx-service-gf????NodePort????10.10.10.23????<none>????????80:34973/TCP?????13m???????app=nginx-gfhttps://github.com/kubernetes/kubernetes/tree/8fd414537b5143ab039cb910590237cabf4af783/examples/volumes/glusterfs
6.ceph
轉載于:https://blog.51cto.com/wsxxsl/2306762
總結
以上是生活随笔為你收集整理的k8s-16-k8s基础存储的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: thinkphp5每周学习总结1019
- 下一篇: 2018-2019-1 20165324