Kubernetes section Volume type Introduction and YAML sample--NFS (network data volume)

Source: Internet
Author: User


Kubernetes section Volume type Introduction and YAML sample--NFS (network data volume)

persistent volume kubernetes




  1. kubernetes persistent volume
  2. Description
    NFS volumes allow existing NFS (network file system) shares to be mounted in your container. Unlike Emptydir, when the Pod is deleted, kubernetes persistent volumes example the contents of the NFS volume are retained and the volume is simply unloaded. This means that the NFS volume can pre-populate the data, kubernetes volumes and it can "toggle" the data between the pods. NFS can be mounted simultaneously by multiple writers.

  3. kubernetes volume mounts
  4. Deploying Server for NFS
    For deployment of NFS, kubernetes volume mount refer to NFS Deployment and optimization (i)persistent volume claim
  5. File sharing in the actual pod
    #创建yaml文件cat >> nginx_volume.yaml << EOFapiVersion: v1kind: Podmetadata:    name: nginx-test    namespace: test    labels:        app: nginxspec:    containers:    - name: nginx        image: nginx:1.7.9        ports:        - containerPort: 80        volumeMounts:        #Mount the path to the container        - mountPath: "/tmp/"            name: pv0003    volumes:    - name: pv0003        nfs:          #fixed:This ip is the address of the nfs server            server: 192.168.246.169            #fixed:This path is shared externally by the nfs server            path: "/data"
    
    
    #查看Pod运行状态kubectl get po -n testNAME                         READY     STATUS    RESTARTS   AGEnginx-test                   1/1       Running   0          29s
    #进入容器查看共享卷volumekubectl exec -it nginx-test  /bin/bash --namespace=test[email protected]:/# cd tmp[email protected]:/tmp# lslost+found  sys##我们可以看到NFS服务器共享卷/data已经挂载进来了
  6. Multi-container sharing between multiple pods in real combat
    #创建deploymentcat >> deploy_volume.yaml << EOFapiVersion: extensions/v1beta1kind: Deploymentmetadata:    name: nginx-wtf    namespace: testspec:    replicas: 2    template:        metadata:            labels:                app: wtf        spec:            containers:            - name: nginx-wtf                image: nginx:1.7.9                ports:                - containerPort: 81                volumeMounts:                 - name: pv0003                     mountPath: /tmp/            volumes:            - name: pv0003                nfs:                    server: 192.168.246.169                    path: "/data/"
    #启动deploymentkubectl create -f ./deploy_volume.yaml
    #查看Pods的运行状态NAME                         READY     STATUS    RESTARTS   AGEnginx-wtf-5774b87bdc-n97gr   1/1       Running   0          32mnginx-wtf-5774b87bdc-xpsnr   1/1       Running   0          32m
    #进入容器查看共享卷volumekubectl exec -it nginx-wtf-5774b87bdc-n97gr  /bin/bash --namespace=test[email protected]:/# cd tmp[email protected]:/tmp# lslost+found  sys
  7. Operation of the actual volume
    #查看下当前命名空间运行有挂载NFS卷的Podskubectl get po -n testNAME                         READY     STATUS    RESTARTS   AGEnginx-test                   1/1       Running   0          2mnginx-wtf-5774b87bdc-n97gr   1/1       Running   0          36mnginx-wtf-5774b87bdc-xpsnr   1/1       Running   0          36m##在命名空间test里运行有三个Pods
    #在NFS服务端对共享卷进行操作##创建目录datagrandmkdir /data/datagrand
    #查看各Pod中容器内卷的变化##nginx-testkubectl exec -it nginx-test  /bin/bash --namespace=test[email protected]:/# cd tmp[email protected]:/tmp# lsdatagrand  lost+found  sys##nginx-wtf-5774b87bdc-n97grkubectl exec -it nginx-wtf-5774b87bdc-n97gr  /bin/bash --namespace=test[email protected]:/# cd tmp[email protected]:/tmp# lsdatagrand  lost+found  sys##nginx-wtf-5774b87bdc-xpsnrkubectl exec -it nginx-wtf-5774b87bdc-xpsnr  /bin/bash --namespace=test[email protected]:/# cd tmp[email protected]:/tmp# lsdatagrand  lost+found  sys##说明:我们可以看到各Pod中容器内卷已有datagrand


Kubernetes section Volume type Introduction and YAML sample--NFS (network data volume)

volume mount kubernetes


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.