Thursday, May 17, 2018

MIcroservice Case study

Microservices could be implemented in several way. In this case below is the stack used.


  • Django
  • Flask
  • Node.js
  • mysql
  • mongo
  • docker
  • kubernetes
  • ubuntu 


In this usecase API searches keyword "search_term" in the available public repositories and displays top 5 active repositories
There are 3 app services here i.e., Django (DAPP) service, FLASK(FAPP) service, NODE.JS(Nodeapp) service
There are 2 database services Mysql(ms-mysql)service and Mongo(ms-mongo)service.

All five docker images are available at location Docker Hub

Preparing the environment

Install docker and kubernetes as mentioned in the location 

Checkout and start kubernetes files from github location

Starting and Stopping services

Start the kubernetes services/pods/deployments with below steps with the files located in dhub
sh ./start0.sh
sh ./start.sh

For stopping kubernetes services/pods/deployments use below step
sh ./stop.sh

Consuming APIs

DAPP consumes FAPP, MySql services and exposes API
http://<HOST-IP>:8000/search/?search_term=flask

FAPP consumes Mongo service and exposed API
http://<HOST-IP>:9000/api/v1/githubsearch/?search_term=kubernetes&employee=nexi_user3

Nodeapp consumes Mongo service
http://<HOST-IP>:8081/



Friday, February 16, 2018

Deployin django in nginx & uwsgi environment

1. Install uwsgi , nginx 
apt-get install uwsgi, nginx

2. Clone django helloworld program
git clone https://github.com/Jadatravu/Tutorials/

3. Copy the helloworld program into /opt folder
cp -r Tutorials/dj_nx_wsgi  /opt

sudo chown -R www-data:www-data /opt/dj_nx_wsgi

4. Create a python virtual environment and install django
cd /opt
virtualenv env
source /opt/env/bin/activate
pip install django

5. Test uwsgi
(env) osboxes@ubuntu:/opt$ uwsgi --http  :8001 --wsgi-file /opt/dj_ng_wsgi/dj_ng_wsgi/wsgi.py  --virtualenv /opt/env --chdir /opt/dj_ng_wsgi/

6. Access from browser
http://192.168.91.129:8001/hello/

7. Configure nginx
copy nginx.conf from dj_nj_wsgi folder to /etc/nginx/sites-available
make soft link
ln -s /etc/nginx/sites-available/nginx.conf /etc/nginx/sites-enabled/nginx.conf

8.restart nginx
service nginx restart

9. start wsgi
(env) osboxes@ubuntu:/opt$ uwsgi --socket :8001 --wsgi-file /opt/dj_ng_wsgi/dj_ng_wsgi/wsgi.py  --virtualenv /opt/env --chdir /opt/dj_ng_wsgi/

10.from browser access the url.
http://192.168.91.129:8000/hello/