jueves, 5 de mayo de 2016

Spring cloud netflix + Kubernetes + Docker. Part II

Spring cloud netflix + Kubernetes + Docker



1º) We download rabbitmq image using the next command:

docker pull rabbitmq:3-management

2º) We download the code:

git clone https://github.com/davsuapas/KubernetesMicroservices.git

3º) We build the docker images of our services from project:

gradle clean build distDocker

4º) Checking that the docker images has been created:

docker images

5º) Launching the kubernetes cluster (from folder where we download kubernete repository), executing the next command into a new terminal:

sudo hack/local-up-cluster.sh

6º) We create all pods executing the next command from kubernete-config (into project repository) folder.


7º) Checking that all pods and kubernete service have been created correctly:

kubectl get pods, services

We can see that all have been created with running state. We can also see that both order and order line have a random name. This is because these pods can have multiple instances.

8º) Checking that the discovery service is working. So, we must find out the IP address assigned by kubernetes. We do this, running the command:

kubectl get -o json pod discovery

Once we get the result we seek the "podIP" word and get the address that we will use in the broswer.

We write in the browse and checking the services:

9º) We call order service using curl:

curl -s | jq .

We get the address of the previous figure in the eureka viewer. We look for the address assigned to edge. Edge will be the dispatcher to our order service.


10º) We simulate a shutdown OrderLine service, and we will see while the instance is shudown, the order service is still working correctly. It is possible, because hystrix manage the states of services and if there is error it will redirect the call to a method to work. In our case "defaultOrder" method.


Before we can see the state of services into monitor, we must get the address so monitor service as turbine service. We use the same way to get address, that we saw in the 8º) point.

kubectl get -o json pod monitor

kubectl get -o json pod turbine

We write in browse and the page we write and click "monitor stream" button. :  monitor address :  turbine address

We can see that the circuit for order service is closed. This means that the circuit supports requests.

Now we going to drop orderline pod using the next command:

kubectl delete pod orderline-47fhv

orderline-47fhv: Depend of the name gaven by kubernetes.