Let's say that you wanted to create a Jenkins Deployment
. As Jenkins uses a local XML file for configuration and state, you would want to create a PersistentVolume
so that your data could be saved across Pod
evictions and Deployment
deletions. I know that the Retain
reclaimPolicy
will result in the data persisting on the detached PersistentVolume
, but the documentation says this is just so that you can manually reclaim the data on it later on, and seems to say nothing about the volume being automatically reused if its mounting Pod
s are ever brought back up.
It is difficult to articulate what I am even trying to ask, so forgive me if this seems like a nebulous question, but:
StatefulSet
? It seems like, in this case, Jenkins would be considered "stateful."PersistentVolumeClaim
the basis of a volume's "identity"? In other words, is the expectation for the PersistentVolumeClaim
to be the stable identifier by which an application can bind to a specific volume with specific data on it?you can use stateful sets. scaling down deletes the pod, leaving the claims alone. Persistent volume claims can be deleted only manually, in order to release the underlying PersistentVolume
a scale-up can reattach the same claim along with the bound Persistent Volume and its contents to the newly created pod instance.
If you have accidentally scaled down a StatefulSet, you can scale up again and the new pod will have the same persisted state again.
If you delete the Jenkins deployment, then later decide to recreate it where you left off, how do you get it to re-mount that exact PersistentVolume on which that specific XML configuration is still stored?
By using the PersistentVolumeClaim
that was bound to that PersistentVolume
, assuming the PersistentVolumeClaim
and its PersistentVolume
haven't been deleted. You should be able to try it :-)
Is this a case where you would want to use a StatefulSet? It seems like, in this case, Jenkins would be considered "stateful."
Yes, you could use StatefulSet
for its stable storage. With no need for persistent identities and stable hostnames, though, I'm not sure of the benefits compared to a master and dynamic slaves Deployment. Unless the idea is to partition the work (e.g. "areas" of the source control repo) across several Jenkins masters and their slaves...
Is the PersistentVolumeClaim the basis of a volume's "identity"? In other words, is the expectation for the PersistentVolumeClaim to be the stable identifier by which an application can bind to a specific volume with specific data on it?
Yes (see my answer to the first question) - the PersistentVolumeClaim
is like a stable identifier by which an application can mount the specific volume the claim is bound to.