Projects:Kubernetes: verschil tussen versies

Naar navigatie springen Naar zoeken springen
471 bytes toegevoegd ,  27 mrt 2019
Regel 270: Regel 270:
</pre>
</pre>


Of course, this volume isn't persistent just yet; restarts of the pod will cause it to be recreated (the Volume has the "lifetime of the Pod") so it actually doesn't serve our purpose.
Of course, this volume isn't really persistent just yet; restarts of the pod will cause it to be recreated (the Volume has the "lifetime of the Pod") so it actually doesn't serve our purpose.


For this, we need to create a PersistentVolume, that exists even outside our Pod, but is linked to it. Kubernetes supports [https://kubernetes.io/docs/concepts/storage/persistent-volumes/ a number of persistant volume types]. All of them use an external service for this, because all Nodes need to be able to access it (with the exception of "HostPath" persistent volumes, which only work on a single-node cluster. [https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/ Here's a tutorial for this if that's what you want].)
There's two ways to get around this:
 
* Instead of using an emptyDir volume, use a volume type that stores its contents somewhere
* Or, alternatively, make a PersistentVolume that exists outside our Pod, and then mount it.
 
== A volume type with persistency ==
 
As seen before, Kubernetes supports [https://kubernetes.io/docs/concepts/storage/volumes/#types-of-volumes many volume types], some of which are naturally persistent because they store the data on an external service.


The quickest way to set up persistent storage is to set up a NFS server:
The quickest way to set up persistent storage is to set up a NFS server:
Regel 319: Regel 326:
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)
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>
== Make a PersistentVolume with a claim ==
The Pod YAML file above has persistency, but with the downside that the definition describes where the files should be stored. Most of the time, definitions don't care about where the files are stored, but only what properties the storage has:
* How much storage can we use?
* Is it optimized for small files or for large files?
* Is it highly available?
* Is it backed up?
To more accurately implement this use-case, Kubernetes has two object types called PersistentVolume and PersistentVolumeClaim.


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

Navigatiemenu