<p>I have a deployment of jenkins in kubernetes with 2 replicas, exposed as a service under the nginx-ingress. After creating a project, the next refresh would yield no result for it, as if it was never created, the third refresh would show the created project again.</p>

<p>New to jenkins and kubernetes so not really sure what is happening.</p>

<p>Maybe each time the service is routing to different pods and so just one of the have the project created and other none. If this is the case how could i fix it??</p>

<p>PD: I reduce the replica to 1 and it work as intended but I am trying to make this a failure tolerant project.  </p>

Diego Ramirez
<p>To my knowledge Jenkins doesn't support HA by design. You can't scale it up just by adding more replicas. <a href="https://stackoverflow.com/questions/36173214/how-to-setup-jenkins-with-ha">Here is simmilar question to yours on stack overflow</a>.</p>

<p>Nginx is load balancing between two replicas of jenkins instances you created.
These two instances are not aware of each other and have separate data so you alternate between two totally separate jenkins instances.</p>

<p>One way you can try solving this is by setting <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#session-affinity" rel="nofollow noreferrer">session affinity</a> on the ingress object:</p>

<pre><code>nginx.ingress.kubernetes.io/affinity-mode: cookie
</code></pre>

<p>so in this way your browser session sticks to one pod.</p>

<p>Also remember to share <code>$JENKINS_HOME</code> dir between these pods e.g. using NFS volumes.</p>

<p>And let me know if you find this helpful.</p>
