Projects:Kubernetes: verschil tussen versies

Naar navigatie springen Naar zoeken springen
1.644 bytes toegevoegd ,  27 mrt 2019
Regel 392: Regel 392:


Note that we asked for only 2 GB, but since the volume provides 10 GB, we got the lowest capacity volume that could be bound.
Note that we asked for only 2 GB, but since the volume provides 10 GB, we got the lowest capacity volume that could be bound.
And let's create a Pod to use it:
<pre>
$ cat bash-pvc.yaml
apiVersion: v1
kind: Pod
metadata:
  name: bash
spec:
  volumes:
  - name: testing-volume
    persistentVolumeClaim:
      claimName: testing-pvc
  containers:
  - name: bash
    image: ubuntu:bionic
    stdin: true
    stdinOnce: true
    tty: true
    volumeMounts:
    - mountPath: /foo
      name: testing-volume
$ kubectl create -f bash.yaml
pod/bash created
$ kubectl attach -ti bash -c bash
If you don't see a command prompt, try pressing enter.
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)
root@bash:/# cat /foo/helloworld.txt
Hello world!
</pre>
This might seem like an insignificant victory, since we're getting the same end result, but it's a crucial step forward: our Pods, Jobs and Deployments don't need to care anymore where their storage comes from, only that it is persistent.
There's some more benefits of Persistent Volume Claims:
* If a PVC is deleted while there is still a Pod using it, it will switch state to <code>Terminating</code> but will not disappear until the Pods are gone, too.
* PVCs have a reclaim policy that can be set to <code>Delete</code> or <code>Recycle</code>, allowing the PV's contents to be deleted as well.
* When StorageClasses are used, PV's can be automatically created when a PVC exists that cannot be Bound yet. This is called [https://kubernetes.io/docs/concepts/storage/persistent-volumes/#provisioning Dynamic provisioning].


== Running a Deployment using this volume ==
== Running a Deployment using this volume ==

Navigatiemenu