title: How to serve static contents in a kubernetes application
body: <p>I have a small <strong>java</strong> webapp comprising of three microservices - <strong>api-service</strong>,<strong>book-service</strong> and <strong>db-service</strong> all of which are deployed on a kubernetes cluster locally using minikube.</p>
  
  <p>I am planning to keep separate UIs for <strong>api-service</strong> and <strong>book-service</strong> , with the common static files served from a separate pod, probably an <code>nginx:alpine</code> image.</p>
  
  <p>I was able to create a front end that serves the static files from <code>nginx:alpine</code> referring to this <a href="https://www.linkedin.com/pulse/serve-static-files-from-docker-via-nginx-basic-example-arun-kumar" rel="noreferrer">tutorial.</a> </p>
  
  <p>I would like to use <a href="https://github.com/kubernetes/ingress-nginx" rel="noreferrer"><code>ingress-nginx</code></a> controller for routing requests to the two services.</p>
  
  <p>The below diagram crudely shows where I am now.</p>
  
  <p>I am confused as to where I should place the pod that serves the static content, and how to connect it to the ingress resource.I guess that keeping a front end pod before ingress defeats the purpose of ingress-nginx controller. What is the best practice to serve static files. Appreciate any help. Thanks.</p>
  
  <p><a href="https://i.stack.imgur.com/i86IZ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/i86IZ.png" alt="enter image description here"></a> </p>