Serving assets using nginx, kubernetes and docker

10/8/2018

There is a need to serve assets such as images/video/blobs that are going to be used in a website and a set of mobile apps. I am thinking of running following setup:

  1. Run nginx in a docker container to serve assets
  2. Run a side car container with a custom app which will pull these assets from a remote location and put in to a 'local storage'. Nginx gets assets from this local storage. Custom app will keep local storage up to date.

To run this setup I need to make sure that the pods that runs these two containers have a local storage which is accessible from both containers. To achieve this, I am thinking of restricting these pods to a set of nodes in the kubernetes cluster and provision local persisted volumes in these nodes. Does this make sense?

-- simon johnson
docker
kubernetes
nginx

2 Answers

10/8/2018

From the description of your issue, it looks like distributed file systems might be what you are looking for.

For example CephFS and Glusterfs are supported in Kubernetes ( Volumes, PersistentVolumes ) and have a good set of capabilities like concurrent access ( both ) and PVC expanding ( Glusterfs ):

cephfs

A cephfs volume allows an existing CephFS volume to be mounted into your Pod. Unlike emptyDir, which is erased when a Pod is removed, the contents of a cephfs volume are preserved and the volume is merely unmounted. This means that a CephFS volume can be pre-populated with data, and that data can be “handed off” between Pods. CephFS can be mounted by multiple writers simultaneously.

Important: You must have your own Ceph server running with the share exported before you can use it.

See the CephFS example for more details.

glusterfs

A glusterfs volume allows a Glusterfs (an open source networked filesystem) volume to be mounted into your Pod. Unlike emptyDir, which is erased when a Pod is removed, the contents of a glusterfs volume are preserved and the volume is merely unmounted. This means that a glusterfs volume can be pre-populated with data, and that data can be “handed off” between Pods. GlusterFS can be mounted by multiple writers simultaneously.

Important: You must have your own GlusterFS installation running before you can use it.

See the GlusterFS example for more details.

For more information about these topics check out the following links:

-- VAS
Source: StackOverflow

10/8/2018

To achieve this, I am thinking of restricting these pods to a set of nodes in the kubernetes cluster and provision local persisted volumes in these nodes.

Why go for a Persistent Volume when the Sidecar container can pull the assets at any time from the remote location. Create a volume with EmptyDirVolumeSource and mount it on both the containers in the Pod. The Sidecar container has Write permissions on the volume and the main container has a Read permission.

-- Praveen Sripati
Source: StackOverflow