Can we consider using containers (and kubernetes) for monolith, stateful web applications?


#1

I’m learning about Containers and Kubernetes and was evaluating if we can move our monolith, stateful appplication to kubernetes?

I was also looking at Principles of Container-based Application Design - Kubernetes and “Self-Containment” looks close. We can consider using “storage”.

Properties of my application: 1. Runs on a JVM 2. Does not have a database. Saves all its data/content to TAR files on the file-system 3. Should be able to backup and retain state if the container goes down.

In our current scenarios, we deploy the app to a VM and our IT teams generally take snapshots of these VM’s as backups and restore them if the app fails or they have to restore to a point where the app was working good. I wanted to avoid this.

Please advice.


#2

For your scenario, I think it would be fine. :slight_smile:
There are still a few questions you will want to consider before choosing a workload type / configuring it.

  • Can your application function with more than one running at a time pointing to the same TAR files? If so configuring multiple replicas and a rolling update for your shouldn’t be an issue. If not, you may want to consider creating it with .spec.strategy.type==Recreate.
  • Does it care about it’s own network identity? If so, a StatefulSet may be a better workload type than a deployment.
  • Depending on what version of the jvm you’re running, there will be some additional flags you’ll want to configure for it to work properly within a container. Redhat put out a great blog post called: Java inside docker: What you must know to not FAIL covering some of these idiosyncrasies.

Kris Nova has a great series on ‘breaking up the monolith’ that might be a good resource for you as well.

Hope that helps!


#3

Thanks for the insights @mrbobbytables

Unfortunately we cannot break the monolith… this is based on Apache Slinghttp://felix.apache.org/ / Felix / Jackrabbit Oak

  • Can your application function with more than one running at a time pointing to the same TAR files? No. Each install creates a folder and stores the app state and data within that. Another instance of the application has it’s own folder/oak-store
  • Does it care about it’s own network identity? No. In our application topology, there are IP’s that are hardcoded in for each application instance.
    For example, the author has the publishers IP’s hardcoded for replication.
  • Version of jvm? We use support java se 8

#4

Hm, if you’re running multiple instances of the application a deployment or statefulset could potentially work, replicas would just need to be set to 1 and your storage may need to be pre-provisioned.

You could also potentially turn it into a helm chart so you can just deploy a new instance for each customer and have the templated chart generate the volume, and service that you need.