Receiving and serving static files in kubernetes

4/23/2017

In the pre-k8s, pre-container world, I have a cloud VM that runs nginx and lets an authorized user scp new content into the webroot.

I'd like to build a similar setup in a k8s cluster to host static files, with the goal that:

  1. An authorized user can scp new files in
  2. These files are statically served on the web
  3. These files are kept in a persistent volume so they don't disappear when things restart

I can't seem to figure out a viable combination of storage class + containers to make this work. I'd definitely appreciate any advice!


Update

What I didn't realize is that two containers running in the same pod can both have the same gcePersistentDisk mounted as read/write. So my solution in the end looks like one nginx container running in the same pod as an sshd container that can write to the nginx webroot. It's been working great so far.

-- Bosh
kubernetes
nginx
scp

1 Answer

4/23/2017

I think you're trying to fit a square peg into a round hole here.

Essentially, you're building an FTP server (albeit with scp rather than FTP).

Kubernetes is designed to orchestrate containers.

The two don't really overlap at all.

Now, if you're really intent on doing this, you could hack something together by creating a docker container running an ssh daemon, plus nginx running under supervisor. The layer you need to be concentrating on is getting your existing VM setup replicated in a docker container. You can then run it on Kubernetes and attach a persistent volume.

-- jaxxstorm
Source: StackOverflow