<p>I am in the process of deploying ActiveMQ 5.15 in HA on Kubernetes. Previously I was using a deployment and a <code>clusterIP</code> Service. And it was working fine. The master will boot up and the slave will wait for the lock to be acquired. If I delete the pod which is the master one, the slave picks up and becomes the master.</p>
<p>Now I want to try with <code>statefulset</code> basing myself on <a href="https://stackoverflow.com/questions/57289381/activemq-on-kuberenetes-with-shared-storage">this thread</a>.
Deployment is done successfully and two pods were created with <code>id0</code> and <code>id1</code>. But what I noticed is that both pods were master. They were both started. I noticed also that two PVC were created <code>id0</code> and <code>id1</code> in the case of <code>Statefulset</code> compared to <code>deployment</code> which had only 1 PVC. Could that be the issue since it is no more a shared storage? Can we still achieve a master/slave setup with <code>Statefulset</code>?</p>

ashley
<blockquote>
<p>I noticed also that two PVC were created id0 and id1 in the case of statefulset compared to deployment which had only 1 PVC. Could that be the issue since it is no more a shared storage?</p>
</blockquote>
<p>You are right. When using k8s StatefulSets each Pod gets its own persistent storage (dedicated PVC and PV), and this persistent storage is not shared.</p>
<p>When a Pod gets terminated and is rescheduled on a different Node, the Kubernetes controller will ensure that the Pod is associated with the same PVC which will guarantee that the state is intact.</p>
<p>In your case, to achieve a master/slave setup, consider using a <strong>shared network location / filesystem for persistent storage</strong> like:</p>
<ul>
<li><a href="https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner" rel="nofollow noreferrer">NFS storage</a> for on-premise k8s cluster.</li>
<li><a href="https://aws.amazon.com/premiumsupport/knowledge-center/eks-persistent-storage/" rel="nofollow noreferrer">AWS EFS</a> for EKS.</li>
<li>or <a href="https://learn.microsoft.com/en-us/azure/aks/azure-files-volume" rel="nofollow noreferrer">Azure Files</a> for AKS.</li>
</ul>
<p>Check the <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#types-of-persistent-volumes" rel="nofollow noreferrer">complete list of PersistentVolume types currently supported by Kubernetes</a> (implemented as plugins).</p>
