A microservice architecture created with JHipster. Uses Spring Cloud, Spring Boot, Angular, and MongoDB for a simple blog/store applications.
Please read Develop and Deploy Microservices with JHipster to see how this example was created.
Prerequisites: 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.
Okta has Authentication and User Management APIs that reduce development time with instant-on, scalable user infrastructure. Okta's intuitive API and expert support make it easy for developers to authenticate, manage and secure users and roles in any application.
To install this example application, run the following commands:
git clone https://github.com/oktadeveloper/jhipster-microservices-example.git
cd jhipster-microservices-example-
Start the registry by running
./mvnw -Pprodin theregistrydirectory. -
Install dependencies in the
blogdirectory, build the UI, and run the Spring Boot app.yarn ./mvnw -
Start MongoDB using Docker Compose in the
storedirectory.docker-compose -f src/main/docker/mongodb.yml up
-
Install dependencies in the
storedirectory, 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)
You can use Docker Compose to start everything if you don't want to start applications manually with Maven.
-
Make sure Docker is running.
-
Build Docker images for the
blogandstoreapplications by running the following command in both directories../mvnw package -Pprod docker:build -
Open a terminal, navigate to the
dockerdirectory 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 -dTIP: Remove
-dfrom the end of the command above if you want to see logs from all containers in the current window. -
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:executeTo 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.
-
Install kubectl, VirtualBox, and Minikube.
-
Start Minikube using
minikube start. -
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)
-
Create Docker images of the
blogandstoreapplications:./mvnw package -Pprod docker:build
-
Navigate to the
kubernetesdirectory in your terminal and re-generate the files so they match your Docker repository name.jhipster kubernetesFollow the instructions for tagging and pushing the Docker images.
docker image tag blog {yourRepoName}/blog docker push {yourRepoName}/blog docker image tag store {yourRepoName}/store docker push {yourRepoName}/store -
Use
kubectlto deploy to Minikube.kubectl apply -f registry kubectl apply -f blog kubectl apply -f storeThe deployment process can take several minutes to complete. Run
minikube dashboardto see the deployed containers. You can also runkubectl get po -o wide --watchto see the status of each pod. -
Run
minikube service blogto 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.
-
Create a Google Cloud project at console.cloud.google.com.
-
Navigate to https://console.cloud.google.com/kubernetes/list to initialize the Container Engine for your project.
-
Install Google Cloud SDK and set project using:
gcloud config set project <project-name> -
Create a cluster:
gcloud container clusters create <cluster-name> --machine-type=n1-standard-2 --scopes cloud-platform --zone us-west1-aTo see a list of possible zones, run
gcloud compute zones list. -
Push the
blogandstoredocker images to Docker Hub. You will need to create an account and rundocker loginto 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
-
Run
kubectlcommands to deploy.kubectl apply -f registry kubectl apply -f blog kubectl apply -f store
-
Use port-forwarding to see the registry app locally.
kubectl port-forward jhipster-registry-0 8761:8761 -
Run
kubectl svc blogto view the blog application on Google Cloud. -
Scale microservice apps as needed with
kubectl:kubectl scale --replicas=3 deployment/store
To see a screencast of this process, watch this YouTube video.
If you know how to deploy this architecture to AWS, I'd love to hear about it! I tried in anger, but ultimately failed.
This example uses JHipster, and awesome project that allows you to generate a microservices architecture with Spring Boot. See Develop a Microservices Architecture with OAuth 2.0 and JHipster for an example that uses OAuth and Okta.
Please post any questions as comments on the blog post, or visit our Okta Developer Forums. You can also email developers@okta.com if would like to create a support ticket.
Apache 2.0, see LICENSE.