0

I would like to do something like this, but all Kubernetes quickstart demos are just for deploying a simple applications and not multiple.

How would I create a yaml file that can deploy multiple applications like this with Minikube?

2

Welcome to the wonderful world of container orchestrators. It is considered bad practice to install many apps into a single container. The new way of working is not to install an application server that runs many WAR files. The new way of deploying is to have each app be a self-contained container where your build tool (eg maven) packaged the servlet container and your app together into a single file. Then each container can be deployed to Kubernetes and independently scaled up and restarted. They can also have memory leaks and crash without effecting each other.

One good example of that is springboot where in your pom.xml you can tell it to build an executable JAR. This will be large as it will include Tomcat into it. When you run the executable file it will launch java and Tomcat and bind to a port and run your app. You don't have to use springboot you can simply add the Tomcat or Jetty plugin to your maven project and have the container just launch "mvn jetty:run" or "mvn tomcat7:run".

I recommend you try minishift which is like minikube but the openshift distro of kubernetes that has more devops features. If you want to deploy Java Servlet apps you just use its built in catalog, select "Open JDK" supply it with your git repo, and it will checkout your code, build the app with maven, create a container image, and deploy the it, with a route and URL you can access it. Yet you can create things from scratch the catalog is just creating all the necessary YAML. Here is the sample code that you would use as your maven project that can be built and run by the "Open JDK" catalog. The pom.xml shows that when the code is built with mvn -P openshift package it puts the war file into a deployments folder and jboss will run it when the container is started. If you don't like jboss then you can add a .s2i/bin/run script that starts your compiled application another way (e.g. "mvn jetty:run" or "mvn tomcat 7:run")

Helm is a package manager for Kubernetes it works with openshift extensions also. Helm tracks what your have installed and lets you rollback. The official chart repos have ready made charts to install databases and redis etc. I made a generic chart that runs any container on openshift kubernetes and we use it to install all our apps whether mode.js or php or whatever. It uses the same YAML as the built in templates use.

When you want to install many charts then you can use Helmfile. Your Helmfile has all the yaml to install all your helm charts. The best feature is that it only modifies what changed. If you modify one setting in a Helmfile that configures many apps it will only update the one app. And let you see the prior versions of the k8s yaml of the apps store in k8s and lets you easily rollback to the last working state.

I am making open source the stuff we run a business with as “OCD” where you change the config in git and a webook will run Helmfile to update your Kubernetes env. Here is the minishift demo how-to.

0

As I understand you need to run and Application which is loading it Servlet container and using reverse proxy to serve the static content and you also want that your sample.war and other configuration remains there regardless of the container life cycle.

Here is an Example project which exactly what your are looking for. Please see this project on Github

Please let me know if you stuck somewhere around. I am glad to assist you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.