GithubHelp home page GithubHelp logo

bur8787 / kotlin-gke-example Goto Github PK

View Code? Open in Web Editor NEW
1.0 4.0 2.0 616 KB

Microservice with Spring Boot in Google Kubernetes Engine

Kotlin 11.59% Java 52.67% TypeScript 4.06% HTML 3.17% CSS 2.85% JavaScript 25.67%
spring-boot kotlin jooq grpc google-kubernetes-engine cloud-sql circleci k8s

kotlin-gke-example's Introduction

Microservice with Spring Boot in Google Kubernetes Engine

Building an application using the following technology stack.

Spring Boot / Kotlin / k8s (Google Kubernetes Engine) / CircleCI / RDB (Cloud SQL) / Cloud Endpoints / Firebase / gRPC

Architecture

diagram

Build locally

There are two ways to build development environment locally.

  1. Use kubenetes (Recommend)
  2. Not use kubenetes

Use Kubenetes

Comming soon.

Not use Kubenetes

Start worker service

$ cd worker-service
$ ./gradlew bootRun -Dspring.profiles.active=h2

Start gRPC Web Proxy

$ docker run -p 8080:8080 --rm -it jfyne/docker-grpcwebproxy /grpcwebproxy --backend_addr=host.docker.internal:6565 --run_tls_server=false

Start web client

$ cd web-client
$ ionic serve

Now, you can access http://localhost:8100 .

Build on Google Cloud Platform with CircleCI

Google Kubernetes Engine

$ gcloud container clusters create demo-cluster --num-nodes=1 --machine-type=n1-standard-2 --service-account=gke-sample-app@possible-enoch.iam.gserviceaccount.com 
$ gcloud container clusters get-credentials demo-cluster

Cloud SQL

$ gcloud sql users create proxyuser cloudsqlproxy~% --instance=[INSTANCE_NAME] --password=[PASSWORD]
$ kubectl create secret generic cloudsql-instance-credentials \
    --from-file=$[CREDENTIAL_FILE]
$ kubectl create secret generic cloudsql-db-credentials \
     --from-literal=username=proxyuser --from-literal=password=[PASSWORD]

Appendix

IDE

IntelliJ IDEA 2017.3.5 (Ultimate Edition)
Build #IU-173.4674.33, built on March 6, 2018
Licensed to Takahiro Suzuki
Subscription is active until April 15, 2018
JRE: 1.8.0_152-release-1024-b15 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.13.3

Spring Boot / Kotlin

Use example project
https://github.com/JetBrains/kotlin-examples/tree/master/tutorials/spring-boot-restful

Document
https://kotlinlang.org/docs/tutorials/spring-boot-restful.html

k8s (Google Kubernetes Engine)

Run a Kotlin Spring Boot application on Google Kubernetes Engine
https://cloud.google.com/community/tutorials/kotlin-springboot-container-engine

CircleCI

Creating and Managing Service Account Keys https://cloud.google.com/iam/docs/creating-managing-service-account-keys?hl=ja

Add the following roles to service account TODO: minimize roles

  • Cloud Container Builder
  • Kubernetes Engine Admin
  • Storage Admin
  • Viewer

Deploying to Google Kubernetes Engine
https://circleci.com/docs/2.0/google-container-engine/

Add the following environment variables in CircleCI

  • GCLOUD_SERVICE_KEY
  • GOOGLE_CLUSTER_NAME
  • GOOGLE_COMPUTE_ZONE
  • GOOGLE_PROJECT_ID

Auth0

Spring Security Java API Authorization
https://auth0.com/docs/quickstart/backend/java-spring-security/01-authorization

Exposed

Sample project
https://github.com/sdeleuze/geospatial-messenger

Blog
https://spring.io/blog/2016/03/20/a-geospatial-messenger-with-kotlin-spring-boot-and-postgresql

jOOQ

You can exclude the generated code from version control. But this project is including that.

generate source code

$ ./gradlew generateWorkerJooqSchemaSource

etiennestuder/gradle-jooq-plugin https://github.com/etiennestuder/gradle-jooq-plugin

Generate Kotlin data classes #6345 jOOQ/jOOQ#6345

gRPC

LogNet/grpc-spring-boot-starter https://github.com/LogNet/grpc-spring-boot-starter

Cloud SQL

Connect Kubernetes Engine https://cloud.google.com/sql/docs/mysql/connect-kubernetes-engine

Appendix

kotlin-gke-example's People

Contributors

bur8787 avatar keitaro1020 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

kotlin-gke-example's Issues

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.