Projects:Kubernetes: verschil tussen versies

Naar navigatie springen Naar zoeken springen
708 bytes verwijderd ,  10 mrt 2019
Regel 287: Regel 287:


Make sure the other nodes can access it, by checking that <code>mkdir /persistent && mount -t nfs <ipaddress>:/persistent /persistent</code> works.
Make sure the other nodes can access it, by checking that <code>mkdir /persistent && mount -t nfs <ipaddress>:/persistent /persistent</code> works.
Now, we can create a PersistentVolume for this NFS mount using the following YAML file:
<pre>
apiVersion: v1
kind: PersistentVolume
metadata:
  name: mypersistentvolume
spec:
  capacity:
    storage: 5Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  storageClassName: slow
  mountOptions:
    - hard
    - nfsvers=4.1
  nfs:
    path: /persistent
    server: <ipaddress>
</pre>
And we'll need to make a PersistentVolumeClaim to claim the volume for our node:
<pre>
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: myclaim
spec:
  accessModes:
    - ReadWriteMany
  volumeMode: Filesystem
  resources:
    requests:
      storage: 5Gi
  storageClassName: slow
  selector:
    matchLabels:
      release: "stable"
    matchExpressions:
      - {key: environment, operator: In, values: [dev]}
</pre>


Now we can go ahead and create our pod with this volume:
Now we can go ahead and create our pod with this volume:


<pre>
<pre>
$ kubectl apply -f persistentvolume.yaml
$ kubectl apply -f volumeclaim.yaml
$ cat bash.yaml
$ cat bash.yaml
apiVersion: v1
apiVersion: v1
Regel 346: Regel 299:
   volumes:
   volumes:
   - name: testing-volume
   - name: testing-volume
     persistentVolumeClaim:
     nfs:
       claimName: myclaim
       path: /persistent
      server: <ipaddress>
   containers:
   containers:
   - name: bash
   - name: bash
Regel 361: Regel 315:
$ kubectl attach -ti bash -c bash
$ kubectl attach -ti bash -c bash
If you don't see a command prompt, try pressing enter.
If you don't see a command prompt, try pressing enter.
root@bash:/#
root@bash:/# mount | grep foo
145.131.6.179:/persistent on /foo type nfs4 (rw,relatime,vers=4.0,rsize=524288,wsize=524288,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=145.131.6.179,local_lock=none,addr=145.131.6.179)
</pre>
</pre>


Navigatiemenu