Skip to content
Spring Boot Microservices with Kubernetes
Branch: master
Clone or download
Pull request Compare This branch is 3 commits ahead of moksamedia:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
gradle/wrapper initial Feb 17, 2019
src
.gitignore initial Feb 17, 2019
Dockerfile initial Feb 17, 2019
LICENSE
README.md
build.gradle
deployment-mongo.yml
deployment.yml
gradlew
gradlew.bat
istio-gateway.yml
settings.gradle initial Feb 17, 2019

README.md

Spring Boot Microservices with Kubernetes

This example shows how to create a microservices architecture and deploy it with Kubernetes.

Please see Build a Microservice Architecture with Spring Boot and Kubernetes for a tutorial that shows you how to build this example.

Prerequisites: Java 8.

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.

Getting Started

To install this example application, run the following commands:

git clone https://github.com/oktadeveloper/okta-spring-boot-microservice-kubernetes.git
cd okta-spring-boot-microservice-kubernetes

Create an Okta Developer Account

If you don't have one, create an Okta Developer account. After you've completed the setup process, log in to your account and navigate to Applications > Add Application. Click Web and Next. On the next page, enter a name for your app (e.g., "Spring Boot GKE"), add https://oidcdebugger.com/debug as a Login redirect URI, select Implicit (hybrid) under Grant types, and click Done.

Copy your issuer (found under API > Authorization Servers) into src/main/resources/application.properties.

spring.security.oauth2.resourceserver.jwt.issuer-uri=https://{yourOktaDomain}/oauth2/default

Start the Spring Boot app using the following command:

./gradlew bootRun

Go to the OIDC Debugger. You'll need your Client ID from your Okta OIDC application.

  • Fill in the Authorize URI: https://{yourOktaDomain}/oauth2/default/v1/authorize
  • Fill in your Client ID.
  • Put abcdef for the state.
  • At the bottom, click Send Request.

Copy the generated token, and store it in a shell variable for convenience:

TOKEN=eyJraWQiOiI4UlE5REJGVUJOTnJER0VGaEExekd6bWJqREp...

Run a GET on the /kayaks endpoint with the token:

http :8080/kayaks Authorization:"Bearer $TOKEN"

NOTE the double quotes! Single quotes won’t work because the variable won’t be expanded in the string.

You should get:

HTTP/1.1 200 OK
cache-control: no-cache, no-store, max-age=0, must-revalidate
content-type: application/json;charset=UTF-8
...
[
  {
    "makeModel": "NDK",
    "name": "sea",
    "owner": "Andrew",
    "value": 300.12
  },
  {
    "makeModel": "Piranha",
    "name": "creek",
    "owner": "Andrew",
    "value": 100.75
  },
  {
    "makeModel": "Necky",
    "name": "loaner",
    "owner": "Andrew",
    "value": 75
  }
]

Links

This example uses the following open source projects:

Help

Please post any questions as comments on this repo's blog post, or visit our Okta Developer Forums.

License

Apache 2.0, see LICENSE.

You can’t perform that action at this time.