A chapter of the courses that I give demonstrates how easy it is to implement a multi-tier application on Rancher / Kubernetes (thanks to the Rancher Catalog). The recipe is the same, whether you are on Rancher 1.x or 2.0! The exercise also uses a storage driver that allows application deployment with persistent storage.
My application is on Github, it is simply an application in Node.js with a MongoDB backend, which displays “Hello MyApp from MongoDB!” in the browser when it is called on the route /myapp. To familiarize yourself a bit with Kubernetes, I decided to deploy this application directly on a cluster, with CLI.
You can use any K8s cluster, a deployed with Rancher, or with kubeadm (see my previous blog), or do it locally with kinikube. This is the last option that I chose because it allows to test our deployment locally. For the installation of minikube and kubectl, I invite you to read this tutorial.
If I consider that my application is a MongoDB backend and a Node.js frontend, what will I need in K8s? First of all a volume for persistence. With minikube, I use local storage. A volume claim, to make this volume available to MongoDB. A MongoDB deployment. One service, to make MongoDB available to other third parties. Another deployment for Node.js, as well as its service. And finally an ingress rule to access my application outside my cluster. I will even push the vice a little further by using a configMap for my Node.js environment varaibles (MongoDB URI). Ready?