Kubernetes - asymetric PODs with predefined addresses
Please read Kubernetes documentation (here) before continuing reading as this chapter is heavily using Kubernetes.
Short description
This configuration is using asymetric PODs and is built with some basic components. A basic component (single instance of JBrick) is a POD with defined ReplicaSet with desired amount of pod instances set to 1 and with service defined above this POD to access it with well known DNS address (as defined here). As you can see number of JBricks should be the same as number of pods and the same as number of services. All JBricks will be connected to each other and that's why configuration can be asymetric.
Install Kubernetes cluster
Please install kubernetes cluster for hosting you application (link).
Prepare docker images
Prepare docker images with your environment configuration. To do so you can use base images provided by JLupin. You only need to add your microservices (you can create multiple images with asymetric configuration). You should also change main server configuration file (main.yml
) and fill node peers with names you will use to create services for PODs. For service created with hostname set to foo
and subdomain set to bar
DNS address for accessing it should be foo.bar.my-namespace.svc.cluster.local
. The best option is to create dockerfile with rules for creating image. To do so create directory called docker
for example. Then inside create directory called microservices
and put inside all zip files with your microservices. Also create main-server
directory and put there your configured main-server.yml
. Finally create Dockerfile
file in docker
directory and put code from below:
FROM jlupin/jlupin-platform-ubuntu:1.6.1.0
USER root
COPY ./microservices/*.zip ${JLUPIN_HOME}/platform/application/
COPY ./main-server/main.yml ${JLUPIN_HOME}/platform/start/configuration/
RUN apt-get -qq update
RUN apt-get -y install unzip
RUN unzip ${JLUPIN_HOME}/platform/application/\*.zip -d ${JLUPIN_HOME}/platform/application/
RUN rm ${JLUPIN_HOME}/platform/application/*.zip
RUN chown -R jlapp:jlapp ${JLUPIN_HOME}/platform/application/*
Then build your image with command docker build -t your-image-name .
. Then push your image to repository so it will accessible for your kubernetes cluster.
Read more about building images here.
Prepare Deployment
For asymetric environment deployment should be configured to keep only one instances of POD. Prepare deployments with different names for every pod (dopeloyments may have same image for keeping mulitple instances of microservices) and make sure every set of PODs (which actually should have only one POD) have it's own service (you can use labels for this). Read more here.
Prepare Service
Prepare service which will group your PODs for every deployment set. To enable access to your application from outside create services which will use NodePort
configuration for routing external traffic into PODs to running Edge Balancers. Because PODs are connected with each other no matter to wchich instances it will be rotued. Read more here.
Deploy Deployments and Services
Deploy your created deployments and services to kubernetes cluster with kubectl tool.
Setup load balancers and DNS
Now you can setup your load balancers or DNS to allow users to access your application.