Continuous Delivery Pipeline for Deploying Microservices Based Scala Application on Kubernetes

by Gursimran | December 22, 2017 |  Categories -  Docker, Kubernetes, Microservices, Containers, Scala

Blog Single Post Image




Running Containers at any real-world scale requires container orchestration, and scheduling platform like Docker SwarmApache MesosAWS ECS but the most popular out of it is Kubernetes. Kubernetes is an open source system for automating deployment and management of containerised applications. 


In this post, We’ll share the process how you can Develop and Deploy Microservices based PHP Laravel Application on the Container Environment -  Docker and Kubernetes and adopt DevOps in existing PHP Applications.



Prerequisites For Deploying Laravel Application on Kubernetes


To follow this guide you need -



  • Kubernetes


It is an open source platform that automates container operations, and Minikube is best for testing Kubernetes.


  • Kubectl


Kubectl is command line interface to manage Kubernetes cluster either remotely or locally. To configure kubectl on your machine follow this link.


  • Shared Persistent Storage


Shared Persistent Storage is permanent storage that we can attach to the Kubernetes container so that we don`t lose our data even when container dies. We will be using GlusterFS as the persistent data store for Kubernetes container applications.


  • Scala Application Source Code


Scala Application Source Code is source code that we want to run inside a Kubernetes container.


  • DockerFile


Dockerfile contains a bunch of commands to build PHP Laravel application.


  • Container Registry


The Registry is an online image store for container images.


Below mentioned options are few most popular registries.




Writing a Dockerfile


At the time of writing this blog, I haven`t got any official image of Scala sbt so I decided to build a base image for Scala sbt. In this image, we are using OpenJDK 8 as a development environment and Scala sbt 0.13.



You May also Love to Read Deploying Microservices Based Java Application on Docker & Kubernetes



Building Scala Base Image


The Below mentioned command will build your scala base container image.




Dockerfile (Application)


As Scala sbt don't have any official image of Docker container so we will be using above created image of Scala sbt as a base image for Scala applications.




Building Scala Application Image


The below-mentioned command will build your application container image.




Publishing Scala Application Container Image


Now we publish our Scala application container image on Private Docker Registry.


  • Login to Container Registry



  • Retag Container Images



  • Push Application container Images



Reference Link for Pull and Push to docker registry.


Similarly, we can push or pull any container image to any of below-mentioned container registry like Docker Hub, AWS ECR, Private Docker Registry, Google Container Registry etc.



Creating Deployment files for Kubernetes


Deploying application on kubernetes with ease using deployment and service files either in JSON or YAML format.


  • Deployment File


Following Content is for “<name of application>.deployment.yml” file of python container application.



  • Service File


Following Content is for “<name of application>.service.yml” file of python container application.




Deploying Scala Application on Kubernetes


Scala Container Application can be deployed either by kubernetes Dashboard or Kubectl (Command line).


I`m explaining command line that you can use in production kubernetes cluster.



Now we have successfully deployed Scala Application on Kubernetes.





We can verify application deployment either by using Kubectl or Kubernetes Dashboard.


Below mentioned command will show you running pods of your application with status running/terminated/stop/created.



Result of above command


Result of Deploying Scala on Kubernetes




Get the External Node Port using the below mentioned command.External Node Port is in the range from 30000 to 65000.



Launch web Browser and open any of the below-mentioned URLs.


  • http://<kubernetes master ip address >: <application service port number>

  • http://<cluster ip address >: <application port number>


You May also Love to Read Deploying Python Application on Docker & Kubernetes





  • Check Status of Pods.

  • Check Logs of Pods/Containers.

  • Check Service Port Status.

  • Check requirements/dependencies of application.



How Can XenonStack Help You?


Our DevOps Consulting Services provides DevOps Assessment and Audit of your existing Infrastructure, Development Environment and Integration.


Our DevOps Professional Services includes -


Continuous Integration & Continuous Deployment


Enable Secure Continuous Integration and Continuous Delivery Pipeline with Jenkins/Bamboo/TeamCity for delivery, automation, self-service environment, and On-demand. Deploy PHP Laravel Application to production by decreasing the time by the automation of entire delivery pipeline comprising build, deploy, test, and release.


Continuous Deployment Cloud Hosting


XenonStack Continuous Deployment Cloud Hosting Services lets you clone your production to staging cluster in less than a minute. Develop, Deploy and Manage your PHP Laravel Application on leading Cloud Service Providers - AWSMicrosoft AzureGoogle Cloud, and Container Environment - Kubernetes and Docker.


Application Modernization Services


Application Modernization Services enable the migration of monolithic applications to new Microservices architecture with Native Cloud Support including the integration of new functionality to create new value from existing application.


Ready To Discuss Your Requirements Request Free Consultation