Git Product home page Git Product logo

hands-on-microservices-with-spring-boot-and-spring-cloud's Introduction

Hands on microservices

Start all microservices locally with spring boot

Config server environnement variable

SPRING_PROFILES_ACTIVE=native;
ENCRYPT_KEY=my-very-secure-encrypt-key;
SPRING_SECURITY_USER_NAME=dev-usr;
SPRING_SECURITY_USER_PASSWORD=dev-pwd;
CONFIG_PATH=<PROJECT_PATH>/local;

Eureka environnement variable

CONFIG_SERVER_USR=dev-usr;
CONFIG_SERVER_PWD=dev-pwd;

Gateway environnement variable

CONFIG_SERVER_USR=dev-usr;
CONFIG_SERVER_PWD=dev-pwd;

OAuth environnement variable

SPRING_PROFILES_ACTIVE=local, config;
CONFIG_SERVER_USR=dev-usr;
CONFIG_SERVER_PWD=dev-pwd;

All micocroservices environnement variable

SPRING_PROFILES_ACTIVE=local, config;
CONFIG_SERVER_USR=dev-usr;
CONFIG_SERVER_PWD=dev-pwd;

Test that works

You must launch mongodb mysql rabbitmq zipkin

cd local
docker-compose up -d mongodb mysql rabbitmq zipkin

Start all microservice on this order : After you lanch all services :

  • eureka-server

  • config-server

  • gateway

  • oauth-authorization-server

  • all other micorservices

Take a look of eureka http://localhost:8761/ with user 'u' and password 'p'

to encrypt you need to use config-server

curl --user dev-usr:dev-pwd localhost:8888/encrypt -d p
78a8c226ba5f1c4425981b723118be57de56c05bdd78ecef48f25df8cdfc5de1

to decrypt you need to use config-server. For example eureka-password: '{cipher}bf298f6d5f878b342f9e44bec08cb9ac00b4ce57e98316f030194a225fac89fb'

curl --user dev-usr:dev-pwd localhost:8888/decrypt -d bf298f6d5f878b342f9e44bec08cb9ac00b4ce57e98316f030194a225fac89fb
p

Test your microservice with swagger

obtain un token jwt

curl -k https://writer:secret@localhost:8443/oauth/token -d grant_type=password -d username=dkahn -d password=password
{"access_token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJka2FobiIsImV4cCI6MjIwNzA2OTE3NSwiYXV0aG9yaXRpZXMiOlsiUk9MRV9VU0VSIl0sImp0aSI6IjNiNGNhMGViLTJhM2ItNDA3Ny1hMmMzLWI3ZDUzMTRkNTY0OCIsImNsaWVudF9pZCI6IndyaXRlciIsInNjb3BlIjpbInByb2R1Y3Q6cmVhZCIsInByb2R1Y3Q6d3JpdGUiXX0.K93IgO7kD6V-GqtXyF6S-jhxh2HHjzSV_z0rlYiZ4BiH4CfVY7FqswRJDzQIGsifCSe8HKheMhLbvrlMYV1yBv9_Jkn-7XDMYuHwNcDtQIcItabcQlb0o9ft4QsJp4qq3ASAbnuB3ZLIA0HiTmkGdmf9H0X8qcFXEfCrdIO-d-ppdiYTi3ppMD-ZUikTve_vmmdzVVqXbbWeZY_B1G-WcRyIVSE8U2pXijD1CUbEm6XOmr1WB9XtWNsHHae_pL93gYbv3Tobq-R45KqKEyi0rFyRM_x6Feu8_hKtMsVUZNBwHd4vPSDYYTvHY_M0gb_oUrjhzTKI5ghusLiW1S9A-g","token_type":"bearer","expires_in":599999999,"scope":"product:read product:write","jti":"3b4ca0eb-2a3b-4077-a2c3-b7d5314d5648"}%

access to swagger (http://localhost:7000/swagger-ui.html) and copy access_token and test microservice

You can use a script for test all microservices

cd local
./test-em-all.bash

Start all microservices locally with docker

gradle build
cd local
docker-compose build
docker-compose up -d
./test-em-all.bash docker

Test that works

./test-em-all.bash docker

debugging on kubernetes

install plugins code cloud et kubernetes plugins on intellij

Create docker from gradle with jib

gradle jibDockerBuild

Debug with code cloud

Install code cloud plugin on Intellij. Then debug on a Kubernetes cluster like a local application.

hands-on-microservices-with-spring-boot-and-spring-cloud's People

Contributors

edjaz 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.