<p>I have a Golang application running in Kubernetes which needs to persist a single string value outside of it's memory. In other words, if the application is redeployed or the pod is restarted - the value is not lost. I also need to be able to read and write this from golang regularly.</p>
<p>What is a good way to do this?</p>
<p>So far I've thought about:</p>
<ol>
<li>ConfigMap: Would this be considered misuse to utilize a config map, and are they even persistent?</li>
<li>PersistentVolume: This seems appropriate, but can I store a single value or a file with this, rather than setting up an entire database?</li>
</ol>
<p>Thank you!</p>

<p>In Kubernetes, you have the following options to store data outside the POD (or actually to share data between PODs).</p>
<ol>
<li><strong>Persistent Volume</strong>: a shared filesystem, you share data as files</li>
<li><strong>ConfigMap/Secret</strong>: Kubernetes-based shared objects, you use Kubernetes API to store data; Kubernetes uses etcd under the hood and the consensus algorithm is applied to every data change, so the size of data needs to be small and the performance is not great</li>
<li><strong>3rd-party tool</strong>: Hazelcast, Redis, TiKV; you use their client (or REST API) to store your values</li>
</ol>
<hr />
<p>I'm not sure about your exact use case, but I'd start from a 3-rd party software. They are very simple to deploy with Helm Chart of Operators. Another option is Persistent Volume. ConfigMap/Secret, I'd treat it as last resort.</p>
