How to Deploying Micro services using Kubernetes in Java

Posted on Updated on

Technology: Kubernetes is the open source cluster management tool designed by Google, and donated to cloud native computing foundation. It mainly used to automate the deployment process, scaling of the application, operations on application hosted containers across the cluster nodes. It usually works with Docker container, co-ordinates with wide range of Docker running cluster hosts.

Kubernetes Concepts:

  • Cluster: A cluster is a set of virtual machines used by kubernetes to deploy/run our applications.
  • Pod: A pod is set of one or more containers (Docker containers) that share the storage and holds the options to how to run the containers. Pods are co-located and co-scheduled and run in the shared context.
  • Node: A Node is worker machine in kubernetes. It may be VM or a physical machine depending on the cluster. Each node must contain list of services like Docker, Kubelet and kube-proxy to run pods and managed by master components.
  • Label: Labels are key/value pairs attached to objects such as pods, which are used to identify the attributes of objects meaningful and relevant to users, but these will not directly imply core semantics. Labels can be used to organize and to select subsets of objects. These can be used to attach to objects at creation time, later can be modified at any time.
  • Selector: A selector is an expression that matches label to identify related resources such as which pods are targeted by a load balancer.
  • Replication Controller: A ReplicationController verifies that a defined number of pod “replicas” are operating at any time. It makes sure that a pod or similar set of pods are always up and available. If there are many pods available, it will kill some. If there are too less, the ReplicationController will start more. Unlike manually developed pods, the pods maintained by a ReplicationController are automatically replaced if they fail, get deleted, or are terminated.
  • Service: A service is middle layer between front-end and back end, service is an abstraction which defines a set logical pods, and policy by which to access them. Service will target a set of pods using label selector.
    Volume: Volume is directory on file system with some data in it, which is accessible to containers. As Kubernetes volumes are built on top of Docker Container volumes, and providing the additional features compared to Docker volumes.
  • Secrets: A Secret is an object that store the sensitive information like passwords, authentication tokens etc… this information can be put in either in image file or pod specific volume. A secret can be used at pod in two ways:
    • As files mounted one or more container volume.
    • Used by kubelet pulling image.
  • Name: All objects in the Kubernetes REST API are unambiguously identified by a Name and a UID. UID`s are generated by kubernetes internally.
  • Name Space: Name spaces will be used in environment with many users, multiple teams involved. If you are familiar with spring framework, it provides one separate name space for each of its module.
  • Annotation: A key/value pair that holds arbitrary non-identifying metadata for retrieval API by tools, libraries etc… This information may be human readable format, it may be structured, or unstructured, and it may include characters which are not allowed in labels. Efficient filtering by annotation value is not supported.

Installing Kubernetes:
Kubernetes and Java development in India on top of Docker, so we need to install Docker to run Kubernetes.

Installing Docker:

  1. Windows: we can download InstallDocker.msi ( and we can install msi file, by default it will create VM. We can run Docker Quick Start Terminal. We can verify the docker installation by running docker –version command.
  2. Ubuntu: we can install Docker in two ways:
    • We can download deb package, install it manually and we need to manage upgrades manually (sudo dpkg -i docker-engine.deb).
    • We can setup Docker repository and we can install from added repository.
      • Repository setup:
        • Execute the below commands in terminal to add the repository.
        • sudo apt-get install apt-transport-https ca-certificates
        • curl -fsSL | sudo apt-key add –
        • apt-key fingerprint 58118E89F3A912897C070ADBF76221572C52609D
        • sudo add-apt-repository “deb ubuntu-$(lsb_release -cs) main”
      • Installing:
      • Execute the below commands to install docker:
      • sudo apt-get update
      • sudo apt-get -y install docker-engine
      • By default it will always install latest version from repository, if we want to install specific version then we can execute the below command instead of above command.
      • To get the list of versions in repository we can run the below command:
      • apt-cache madison docker-engine

Minikube is the tool, using which kubernetes will run locally, and also it will setup the single node cluster in our dev machines.
Minikube supports Kubernetes features such as:

  1. DNS
  2. NodePorts
  3. ConfigMaps and Secrets
  4. Dashboards
  5. Container Runtime: Docker, and rkt
  6. Enabling CNI (Container Network Interface).

Installing MiniKube in windows:

Download the minikube from

And go to saved folder and invoke command in command prompt to install minikukbe.

minikube-windows-amd64 start

And we need to download kubectl.exe from

And add to path (environment variable).

Creating Docker image for our application:

Build tools like Maven, Gradle provides plugin for creating docker image.

If we are using maven as build tool then we need to add the below docker plugin:

dockerDirectory refers to folder where docker file present.
directory: refers to build directory.
We can run mvn clean package docker: build to create docker image.
If we are using continuous integration tools like Jenkins we need to push image after the build successful, we can push the image using docker:push goal.
We can also tag the image using imageTags in configuration.
Pushing Docker images to private repository:
We can use registry docker image to start the private repository.
docker run -d -p 5000:5000 –restart=always –name registry registry:2
and change image name specified in docker maven plugin to “<imageName>localhost:5000/hello-world</imageName>”.

And run the mvn clean package docker:build it will build the image file.
Deploying docker image into Kubernetes:
We need to push the above docker image into registry, and we need to execute the below command:
kubectl run hello-world –image=localhost:5000/hello-world:v1 –port=8080
It will deploy our docker image into kubectl cluster, we can also configure under which port our application want to run using port parameter.
We can run the kubectl get deployments to know the deployment status of our application.
View our app: by default all our application will also accessible in kubectl cluster.
For accessing our application we can do in two ways:

  1. We can create kubectl proxy between terminal and kubectl cluster.
    For this we need to run kubctl proxy command to create proxy.
  2. We can expose our application using kubectl expose command.
    kubectl expose deployment/hello-world –type=”NodePort” –port 8080
    We can run kubectl services to check the service is exposed to public or not.
    To get the details about our application service we can run the below command:
    kubectl describe services/hello-world
    Describe output will provide nodePort of the service, we need to use this port for accessing our application.

Updating Docker Image:
We can build latest docker image and we can update deployment path for application to update the application in kubernates.
kubectl set image deployments/hello-world hello-world=localhost:5000/hello-world:v2

Conclusion: Kubernetes is the tool for creating cluster for docker like containers, we can easily scale the cluster size, and we can easily deploy our docker image in all of the configured cluster using kubernets easily.

Java outsourcing services provider introducing command pattern for Java development

Posted on Updated on

In this post, java outsourcing experts explain the use of command pattern for app development. Understand command pattern well and implement a call back functionality in java app. Code shared in this post are for reference purpose only


In Java, to make the code more reliable we should design our code efficiently that can be done by applying design methodologies such as OOPs, OOAD, design principles and patterns into applications.

Command pattern is a behavioral design pattern which actually help us to implement a call back functionality in Java. I.e. it encapsulate the request and sends to invoker who holds the command that is need to be executed.
GOF states that – “Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations”


Command – Interface to executing a command
Concrete Command – Holds a receiver, Implements command interface and execute the operation on the receiver and it actually creates the link between receiver and the action.
Receiver – Has the knowledge of the command and knows how to perform the operation
Invoker – has a command to execute.
Client – uses invoker thru concrete commands

java.lang.Runnable is implemented followed by command pattern
In the real world, we can think of any examples

Buying or Selling a share in ShareMarket

  • Command
  • ConcreteCommand – BuyCommand, SellCommand (executes the command on the receiver)
  • Receiver – Share Market (has the knowledge of shares that companies(ICICI, SBI, TATA, etc.) holding and knows how to perform all the share operations will execute shares)
  • Invoker – Broker or Agent who holds the command
  • Client – creates either buy or sell command basis on their requirement and invokes it thru invoker

Commanding/Operating a TV(Television)

  • Command
  • ConcreteCommand – SwichOn, SwitchOff, ChangeChannel, MuteSound etc.,
  • Receiver – TV (knowledge of how to execute the command operations)
  • Invoker – TVRemote (holds the commands to be executed)
  • Client – Creates the command either switchon or off or change channel and invokes it thru invoker

//Command interface
public interface TVCommand {
void execute();

//Concrete Command class SwitchOn
public class SwitchOn implements TVCommand {

// holds a receiver who knows how to perform command operations
private TV tv;

public void execute() {

//Concrete Command class SwitchOff
public class SwitchOff implements TVCommand {

// holds a receiver who knows how to perform command operations
private TV tv;

public void execute() {

//Receiver – who knows how to perform operations
public class TV {

public void switchOn() {} // switch on operation

public void switchOff() {} // switch off operation

// more methods or operations like muteSound, changeChannel etc.,
//Invoker class TVRemote
public class TVRemote {

// holds a command that needs to be executed
private TVCommand tvCommand;

public void setTVCommand(TVCommand tvCommand) {
this.tvCommand = tvCommand;

public void pressButton() {

public class Client {

// creates commands and invoke the commands thru an invoker TVRemote
TVCommand on = new SwitchOn();
TVCommand off = new SwitchOn();

TVRemote tvRemote = new TVRemote();

tvRemote.setCommand(on); // on command

tvRemote.setCommand(off); //off command


Java outsourcing services providers have explained the command pattern use for app development. If you think you need assistance of professionals to perform this project, outsource java development services today.


It actually help us to implement a call back functionality and command supports to do undo and redo operations since it is maintaining state with the receiver. And it makes the code more maintainable and adaptable i.e. we can add a new command like change-channel, mute-sound etc. without affecting the existing implementation

Why to use for complex business projects – Quick discuss by Developers India

Posted on Updated on has become widely popular during last few years and most complex applications are based on .net framework. The main reason for popularity of framework is open source code. Today, it is considered most amazing platform to create complex business projects in define time frame only. Here, we will discuss why can always be used to build apps and computer software programs.

Where should you use

One of the best things about framework is flexibility and it helps in designing most beautiful frameworks than you have ever imagined earlier. This is just wonderful from hardware and software point of view. There are .net wizards or IDEs that help you in writing better software programs as you needed.

Which type of applications can be made with .net?

Web apps are best implementation of .net framework. They just work great for different type of projects from designing internal simulation system to internal systems for car. Initially it was not possible to write or execute .net apps on Linux or OS X platform. Today with the invention of .net core, .net apps can be run over almost on any operation system. is across development platform compatible with multiple programming languages and interactive IDE Visual Studio has become integral tool for developers in India and worldwide. Performance and scalability

Generally, developers take time when they have to decide on right technology. The final decision is based on either performance of programming language or scalability. Initially, .net was not so popular due to its performance but .net core is making waves.

Today, .net is outperforming and complete package to design most complex business apps in your budget only. It helps you in processing millions of requests together almost every second as per project needs or requirements

Open Source

.net was close source for plenty of years and Java was ruling the programming world due to open sourcing parts. Now .net core has also become open source and this is easy to make modifications in final code. They are able to work with user requests, pull requests or discussing issues etc. The .net core is wonderful example how open source framework works actually.

One of the best things about .net framework is its documentation capabilities and how it helps in managing multiple e-books or content together. You can also use the framework for blogs, tutorials etc. You are free to create your own games with .net core framework.

Best tools or techniques for 

.Net core has best tools available to use. You can use any of the tools and develop apps on different framework using multiple programming languages like C sharp, C++, VB, F# etc. Dot Net framework is compatible with more than 35 languages and you can create or design apps using your favorite programming language.

Additionally, Microsoft invests heavily to innovative .net services and attracts more users worldwide. To take most benefits from language, hire programmers or developers in India and get your complex project requirements completed right away.

How to get the most out of website development with the help of Java J2ee technology

Posted on Updated on

Developing a website involves loads of planning and technical expertise. Web designers use digital media, interactive elements, images and various texts to make a page that we see when we browse the sites. The web design services consist of the planning, conceptualization, post-production, producing, advertising and research. Web development refers to the work that develops a website. The website can provide information about an individual, company or any other institution. The Java J2ee Development company can be managed by a small group or even by a large group of professionals.

Read the rest of this entry »

Display Bold, Italic, Strike out fonts in SWT table/tree

Posted on Updated on

SWT(Software Widget toolkit). It’s a java based framework to develop GUI(standalone) applications. This framework is like Java Swings, AWT. SWT has rich set of widgets like tree, tables, groups, sahsforms, composites etc.

Read the rest of this entry »