Git Product home page Git Product logo

shiny777 / jhipster-microservices-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from oktadev/jhipster-microservices-example

0.0 2.0 0.0 24.08 MB

JHipster Microservices Example using Spring Cloud, Spring Boot, Angular, Docker, and Kubernetes

Home Page: https://developer.okta.com/blog/2017/06/20/develop-microservices-with-jhipster

License: Apache License 2.0

Shell 1.44% Batchfile 1.02% JavaScript 2.19% Java 42.80% HTML 15.36% TypeScript 25.55% CSS 10.74% Scala 0.90%

jhipster-microservices-example's Introduction

JHipster Microservices Example

A microservice architecture created with JHipster. Uses Spring Cloud, Spring Boot, Angular, and MongoDB for a simple blog/store applications.

To run this app, you'll need to install Java 8, Node.js 6.11, Yarn, and Docker.

NOTE: If you're not on Mac or Windows, you may need to install Docker Compose as well.

  1. Start the registry by running ./mvnw in the registry directory.

  2. Install dependencies in the blog directory, build the UI, and run the Spring Boot app.

    yarn
    ./mvnw 
    
  3. Start MongoDB using Docker Compose in the store directory.

    docker-compose -f src/main/docker/mongodb.yml up
  4. Install dependencies in the store directory, build the UI, and run the Spring Boot app.

    yarn
    ./mvnw 
    

You should be able to see the blog app at http://localhost:8080 and edit products (from the store app)

Run with Docker Compose

You can use Docker Compose to start everything if you don't want to start applications manually with Maven.

  1. Make sure Docker is running.

  2. Build Docker images for the blog and store applications by running the following command in both directories.

    ./mvnw package -Pprod docker:build
    
  3. Open a terminal, navigate to the docker directory of this project, and run the following command. If you have a lot of RAM on your machine, you might want to adjust Docker's default setting (2 GB).

    docker-compose up -d
    

    TIP: Remove -d from the end of the command above if you want to see logs from all containers in the current window.

  4. Use Kitematic to view the ports and logs for the services deployed.

To create activity in JHipster Console's charts, you run the Gatling tests in the blog and store projects.

./mvnw gatling:execute

To remove all Docker containers, run the following commands or do it manually using Kitematic.

docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)

To find what's running on a port on macOS, use sudo lsof -i :9092 # checks port 9092.

Run with Kubernetes and Minikube

  1. Install kubectl, VirtualBox, and Minikube.

  2. Start Minikube using minikube start.

  3. To be able to work with the docker daemon, make sure Docker is running, then run the following command in your terminal:

    eval $(minikube docker-env)
  4. Create Docker images of the blog and store applications:

    ./mvnw package -Pprod docker:build
  5. Run the following commands in the kubernetes directory to deploy to Minikube.

    kubectl apply -f registry
    kubectl apply -f blog
    kubectl apply -f store
    

    The deployment process can take several minutes to complete. Run minikube dashboard to see the deployed containers. You can also run kubectl get po -o wide --watch to see the status of each pod.

  6. Run minikube service blog to view the blog application. You should be able to login and add blogs, entries, and products.

To remove all deployed containers, run the following command:

kubectl delete deployment --all

To stop Minikube, run minikube stop.

NOTE: If you run minikube delete and have trouble running minikube start afterward, run rm -rf ~/.minikube. See this issue for more information.

Google Cloud

  1. Create a Google Cloud project at console.cloud.google.com.

  2. Navigate to https://console.cloud.google.com/kubernetes/list to initialize the Container Engine for your project.

  3. Install Google Cloud SDK and set project using:

    gcloud config set project <project-name>
    
  4. Create a cluster:

    gcloud container clusters create <cluster-name> --machine-type=n1-standard-2 --scopes cloud-platform --zone us-west1-a
    

    To see a list of possible zones, run gcloud compute zones list.

  5. Push the blog and store docker images to Docker Hub. You will need to create an account and run docker login to push your images. The images can be run from any directory.

    docker image tag blog mraible/blog
    docker push mraible/blog
    docker image tag store mraible/store
    docker push mraible/store
  6. Run kubectl commands to deploy.

    kubectl apply -f registry
    kubectl apply -f blog
    kubectl apply -f store
  7. Use port-forwarding to see the registry app locally.

    kubectl port-forward jhipster-registry-0 8761:8761
    
  8. Run kubectl svc blog to view the blog application on Google Cloud.

  9. Scale microservice apps as needed with kubectl:

    kubectl scale --replicas=3 deployment/store
    

To see a screencast of this process, watch this YouTube video.

AWS

If you know how to deploy this architecture to AWS, I'd love to hear about it! I tried in anger, but ultimately failed.

jhipster-microservices-example's People

Contributors

mraible avatar lindsayb610 avatar

Watchers

James Cloos avatar Berna avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.