<p><strong>TL;DR</strong><br />
How can I setup a light-weight web server to execute external programs to handle REST requests?</p>
<p><strong>The long version</strong>:<br />
We have a set of services and databases deployed in Kubernetes via Helm. There are some executables that perform maintenance, cleanup, backup, restore etc that I need to execute (some on-demand &amp; some periodically).<br />
I want to park a small, light-weight web server somewhere mounted with access to the binaries and execute them when REST requests are handled.</p>
<ul>
<li>server needs to have a small memory footprint</li>
<li>traffic will be really light (like minutes between each request)</li>
<li>security is not super important (it will run inside our trusted zone)</li>
<li>server needs to handle GET and POST (i.e. passing binary content TO &amp; FROM external program)</li>
</ul>
<p>I've glanced at lighttpd or nginx with CGI modules but I'm not experienced with those.<br />
What do you recommend? Do you have a small example to show how to do it?</p>

<p>Here's k8s native approach:</p>
<p><code>... a set of services and databases deployed in Kubernetes... some executables that perform maintenance, cleanup, backup, restore etc...some on-demand &amp; some periodically</code></p>
<p>If you can bake those &quot;executables&quot; into an image, you can run these programs on-demand as <a href="https://kubernetes.io/docs/concepts/workloads/controllers/job/" rel="nofollow noreferrer">k8s job</a>, and schedule repeating job as <a href="https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/" rel="nofollow noreferrer">k8s cronjob</a>. If this is possible in your context then you can create a k8s role that has just enough right to call job/cronjob api, and bind this role to a dedicated k8s service account.</p>
<p>Then you build a mini web application using any language/framework of your choice, run this web application on k8s using the dedicated service account, expose your pod as service using NodePort/LoadBalancer to receive GET/POST requests. Finally you <a href="https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-api/#directly-accessing-the-rest-api" rel="nofollow noreferrer">make direct api call to k8s api-server</a> to run jobs according to your logic.</p>
