VerteilteSystemeOGs / hska-vis-legacy

This project is the quick setup of the legacy webshop of the masters course 'Distributed Information Systems' at the University of Applied Sciences (Karlsruhe).
https://manuel-vogel.de/projects/2017-02-01-from-monolith-to-microservices/
MIT License
0 stars 0 forks source link

MIT license Travis Build Status

Distributed Information Systems Laboratory aka vis-lab

This project is the quick setup of the legacy webshop of the masters course 'Distributed Information Systems' at the University of Applied Sciences (Karlsruhe).

Table of Contents

Prerequisites

Usage

You can run the images from docker hub which is preferred or built it on your own. First: Start Docker daemon and check with docker ps

Quick Start (docker-hub)

Built it on your own

Database Cleanup

If you change the user and password of the MySQL database, you should run

$ docker-compose rm -v
$ rm -rf .data

Details can be found here

Setup in Kubernetes

Prerequisites

Make sure to have minikube, kubectl and istioctl installed. These commands will be used throughout the setup process.

Setup minikube cluster

Start minikube cluster with at least 3 cpu cores allocated. Fewer cores can lead to deployments not starting because of to little computing ressources.

minikube start --cpus 3

Start the kubernetes dashboard:

minikube dashboard

Setup ingress

To access the deployed services, an ingress needs to be setup. The nginx-minikube addon will be used in this case.

minikube addons enable ingress

You may have to start the minikube cluster directly with the ingress addon enabled. In this case recreate the minikube cluster:

minikube delete
minikube start --cpus 3 --addons ingress

Start the kubernetes dashboard

minikube dashboard

Deploy services

Deploy all containers and services as well as the database using kubectl. All used images are public, so no authentication is required.

kubectl apply -f kubernetes/kubernetes.yaml

In the dashboard you can see the deployments created, which will start the necessary pods and configure the services and ingress.

Access services

Using the ingress, the services can be reached on their respective paths /user, /category and /product. The base ip can be retrieved with minikube.

minikube ip

Show load balancing

The load balancing can be demonstrated using a special endpoint built into the user service. The endpoint /user/v1/pod/ returns the hostname -- and thus the pod name.

Istio

Installation

To install Istio, issue the following command:

istioctl install

Confirm the question with y and wait for the processing to complete.

Add Istio to kubernetes deployments

kubectl label namespace default istio-injection=enabled

This commands instructs Istio to install the sidecar next to the deployments of the EShop. However, this only takes affect on new deployments. So redeploy using the following commands:

kubectl delete -f kubernetes/kubernetes.yaml
kubectl apply -f kubernetes/kubernetes.yaml

After deployment is finished, you should see two containers per pod in the Kubernetes Dashboard.

Istio addons

Kiali, Prometheus and Grafana are already provided as addons by Istio. These addons are preconfigured, so only the deployment using the provided files is necessary.

Kiali

kubectl apply -f samples/addons/kiali.yaml

To access Kiali, set up a port forwarding:

kubectl port-forward svc/kiali -n istio-system 20001:20001

Prometheus

kubectl apply -f samples/addons/prometheus.yaml

Grafana

Grafana uses the prometheus metrics to display statistics. The endpoints as well as the Grafana Dashboard are already configured by default.

kubectl apply -f samples/addons/grafana.yaml
kubectl port-forward svc/grafana -n istio-system 3000:3000

Show data in the monitoring systems

To issue multiple requests to the services, a bash script may be used.

./call_every_service.sh

License

Copyright (c) 2017-2018 Manuel Vogel Source code is open source and released under the MIT license.