Managing StatefulSet
To demonstrate how StatefulSet objects work, we will modify our nginx
deployment and adapt it to be a StatefulSet. A significant part of the StatefulSet specification is the same as for Deployments. As we would like to demonstrate how automatic management of PVCs works in StatefulSet objects, we will use volumeClaimTemplates
in the specification to create PVCs and PVs, which the Pods will consume. Each Pod will internally mount its assigned PV under the /usr/share/nginx/html
path in the container filesystem, which is the default location of nginx
files that are served over HTTP. In this way, we can demonstrate how the state is persisted, even if we forcefully restart Pods.
Important note
The example that we are going to use in this chapter is for demonstration purposes only and is meant to be as simple as possible. If you are interested in complex examples, such as deploying and managing distributed databases in StatefulSets, please take a look at the official...