You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+166-7Lines changed: 166 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,28 +1,30 @@
1
-
2
1
# Java Microservices with Spring Boot & Spring Cloud 🍃☁️
3
2
4
3
This repository contains examples of how to build a Java microservices architecture with Spring Boot, Spring Cloud, and Netflix Eureka.
5
4
6
-
This repository has four examples in it:
5
+
This repository has five examples in it:
7
6
8
7
1. The first is a bare-bones microservices architecture with Spring Boot, Spring Cloud, Eureka Server, and Zuul.
9
8
2. The second is one that's built with JHipster and configured centrally with Spring Cloud Config.
10
9
3. The third uses Spring Cloud Gateway and Spring WebFlux to show reactive microservices.
11
10
4. The fourth uses JHipster 7 to generate a reactive microservices architecture with Spring Cloud Gateway and Spring WebFlux.
11
+
5. The fifth uses JHipster 7 + Kubernetes and deploys to Google Cloud with sealed secrets.
12
12
13
13
We think you'll enjoy them all!
14
14
15
-
* See [Java Microservices with Spring Boot and Spring Cloud](https://developer.okta.com/blog/2019/05/22/java-microservices-spring-boot-spring-cloud) for an overview of the first example.
16
-
* Read [Java Microservices with Spring Cloud Config and JHipster](https://developer.okta.com/blog/2019/05/23/java-microservices-spring-cloud-config) to learn about microservices with JHipster.
17
-
* Refer to [Secure Reactive Microservices with Spring Cloud Gateway](https://developer.okta.com/blog/2019/08/28/reactive-microservices-spring-cloud-gateway) to learn about Spring Cloud Gateway and reactive microservices.
18
-
* Refer to [Reactive Java Microservices with Spring Boot and JHipster](https://developer.okta.com/blog/2021/01/20/reactive-java-microservices) to see how JHipster makes reactive microservices a breeze.
15
+
* See [Java Microservices with Spring Boot and Spring Cloud][blog-spring-boot-spring-cloud] for an overview of the first example.
16
+
* Read [Java Microservices with Spring Cloud Config and JHipster][blog-spring-cloud-config] to learn about microservices with JHipster.
17
+
* Refer to [Secure Reactive Microservices with Spring Cloud Gateway][blog-spring-cloud-gateway] to learn about Spring Cloud Gateway and reactive microservices.
18
+
* Refer to [Reactive Java Microservices with Spring Boot and JHipster][blog-reactive-jhipster] to see how JHipster makes reactive microservices a breeze.
19
+
* Peruse to [Kubernetes to the Cloud with Spring Boot and JHipster][blog-k8s] to see how JHipster simplifies Kubernetes deployments.
19
20
20
21
**Prerequisites:**[Java 11](https://sdkman.io/sdks#java) and an internet connection.
21
22
22
23
*[Spring Boot + Spring Cloud Example](#spring-boot--spring-cloud-example)
23
24
*[JHipster + Spring Cloud Config Example](#jhipster--spring-cloud-config-example)
*[Reactive Microservices with JHipster Example](#reactive-microservices-with-jhipster-example)
27
+
*[Kubernetes to the Cloud Example](#kubernetes--reactive-java-with-jhipster-example)
26
28
*[Links](#links)
27
29
*[Help](#help)
28
30
*[License](#license)
@@ -235,9 +237,159 @@ Now, open a new incognito browser window, go to `http://localhost:8080`, and sig
235
237
236
238
**TIP**: You can also run everything using Docker Compose. See the [blog post](https://developer.okta.com/blog/2021/01/20/reactive-java-microservices#run-your-microservices-stack-with-docker-compose) for how to do that.
237
239
240
+
## Kubernetes + Reactive Java with JHipster Example
241
+
242
+
To install this example, run the following commands:
Run JHipster's [Kubernetes sub-generator](https://www.jhipster.tech/kubernetes/).
256
+
257
+
```shell
258
+
jhipster k8s
259
+
```
260
+
261
+
You will be prompted with several questions. The answers will be pre-populated from choices I made when creating this app. Answer as follows, changing the Docker repository name to yours, or leaving it blank if you don't have one.
262
+
263
+
- Type of application: **Microservice application**
264
+
- Root directory: **../**
265
+
- Which applications? <select all>
266
+
- Set up monitoring? **No**
267
+
- Which applications with clustered databases? select **store**
268
+
- Admin password for JHipster Registry: <generate one>
If you have Docker installed, you can run Kubernetes locally with Minikube. Run `minikube start` to begin.
280
+
281
+
```shell
282
+
minikube --memory 8g --cpus 8 start
283
+
```
284
+
285
+
Now, you need to build Docker images for each app. In the {`gateway`, `blog`, `store` } directories, run the following Gradle command (where `<image-name>` is `gateway`, `store`, or `blog`).
> You can also build your images locally and publish them to your Docker daemon. This is the default if you didn't specify a base Docker repository name.
292
+
>
293
+
> ```shell
294
+
> # this command exposes Docker images to minikube
295
+
> eval $(minikube docker-env)
296
+
> ./gradlew -Pprod bootJar jibDockerBuild
297
+
> ```
298
+
>
299
+
> Because this publishes your images locally to Docker, you'll need to make modifications to your Kubernetes deployment files to use `imagePullPolicy: IfNotPresent`.
300
+
>
301
+
> ```yaml
302
+
> - name: gateway-app
303
+
> image: gateway
304
+
> imagePullPolicy: IfNotPresent
305
+
> ```
306
+
>
307
+
> Make sure to add this `imagePullPolicy` to the following files:
308
+
>
309
+
> - `k8s/gateway-k8s/gateway-deployment.yml`
310
+
> - `k8s/blog-k8s/blog-deployment.yml`
311
+
> - `k8s/store-k8s/store-deployment.yml`
312
+
313
+
### Register an OIDC App for Auth
314
+
315
+
Install the Okta CLI using the instructions on [cli.okta.com](https://cli.okta.com) and come back here when you're done. If you don't have an Okta developer account, run `okta register`.
316
+
317
+
**NOTE**: You can also use your browser and Okta's developer console to register an app. See [JHipster's security documentation](https://www.jhipster.tech/security/#okta) for those instructions.
318
+
319
+
From the gateway project's directory, run `okta apps create jhipster`. Accept the default redirect URIs.
320
+
321
+
This process does several things:
322
+
323
+
1. Registers an OIDC app in Okta with JHipster's configured redirect URIs.
324
+
2. Creates `ROLE_ADMIN` and `ROLE_USER` groups and adds your user to both.
325
+
3. Creates a `groups` claim and adds it to ID tokens.
326
+
4. Creates a `.okta.env` file with the values you'll need to talk to Okta.
327
+
328
+
Update `k8s/registry-k8s/application-configmap.yml` to contain your OIDC settings from the `.okta.env` file the Okta CLI just created. The Spring Cloud Config server reads from this file and shares the values with the gateway and microservices.
0 commit comments