Slide 1

Slide 1 text

Hands-On Lab: Modernizing Monolith to Microservices Applications on Google Cloud with Cloud Run Surabaya Ananda Dwi Rahmawati

Slide 2

Slide 2 text

Ananda Dwi Rahmawati - Cloud and DevOps Engineer @ Singapore - Google Developer Expert Cloud - Modern Architecture - https://linktr.ee/misskecupbung Surabaya

Slide 3

Slide 3 text

Containerize a Spring Boot Kotlin App and Deploy it to Cloud Run

Slide 4

Slide 4 text

Containerize Application Google’s Jib Tool: ● A powerful image build tool. ● Easily builds and publishes optimized Docker images for Java apps. ● No need for Docker or a Dockerfile. ● Link: https://github.com/GoogleContainerTools/jib

Slide 5

Slide 5 text

Cloud Run ● Serverless container platform by Google Cloud. ● Automatically scales stateless containers. ● Supports a fully managed, containerized infrastructure. ● Link: https://cloud.google.com/run/

Slide 6

Slide 6 text

Surabaya Containerizing Java Apps with Google Cloud

Slide 7

Slide 7 text

Prerequisites Familiarity with Java programming language and tools Knowledge of standard Linux text editors, such as Vim, Emacs, and nano

Slide 8

Slide 8 text

Set up a Spring Boot Kotlin app. Build an optimized Docker image. Publish the image to Container Registry. Run the containerized app on Cloud Run. What you will do

Slide 9

Slide 9 text

A Google Cloud project A browser, such as Google Chrome What you will need

Slide 10

Slide 10 text

Architecture Diagram

Slide 11

Slide 11 text

Open this URL [REDACTED]

Slide 12

Slide 12 text

In this approach we create an anthemic opener showing real people using A.I. to do amazing things. This can be everyday people You will need to be signed in Click on “Sign in with Google” button

Slide 13

Slide 13 text

In this approach we create an anthemic opener showing real people using A.I. to do amazing things. This can be everyday people You will need to be signed in You should see a similar page. Click on this button

Slide 14

Slide 14 text

In this approach we create an anthemic opener showing real people using A.I. to do amazing things. This can be everyday people cloud-dev@gmail.com Click on “Accept and Continue” to proceed Make sure that you are applying for the correct account

Slide 15

Slide 15 text

Claim credits Step 1 Create a Google Cloud project Step2

Slide 16

Slide 16 text

www.googlecloud.com Click on “Create or select a project” Go to: console.cloud.google.com

Slide 17

Slide 17 text

In this approach we create an anthemic opener showing real people using A.I. to do amazing things. This can be everyday people Click on “New Project” Creating a new project

Slide 18

Slide 18 text

In this approach we create an anthemic opener showing real people using A.I. to do amazing things. This can be everyday people Name your project Creating a new project IF you see a billing account, make sure to select the “Trial Billing Account”. If NOT, still create the project and go to next slide Click “CREATE”

Slide 19

Slide 19 text

If you don’t see a billing account in the previous step: 1) Go to Billing from Google Cloud Console and 2) Set your project’s billing account to Google Cloud Platform Trial Billing Account

Slide 20

Slide 20 text

Proprietary + Confidential Learn more about Google Cloud at goo.gle/clouddevs

Slide 21

Slide 21 text

Surabaya https://codelabs.developers.goo gle.com/codelabs/cloud-kotlin-ji b-cloud-run

Slide 22

Slide 22 text

Generate a new Spring Boot app with Spring Initializr. Step 1 Initialize a Spring Boot App curl https://start.spring.io/starter.tgz \ -d type=maven-project \ -d language=java \ -d dependencies=web \ -d baseDir=maven-cloud-run | tar -xzvf - cd maven-cloud-run/

Slide 23

Slide 23 text

Change to the directory of the template app and build and run the app using Maven. Step 1 Initialize a Spring Boot App cd maven-jib-cloud-run ./mvnw -DskipTests spring-boot:run

Slide 24

Slide 24 text

nano src/main/java/com/example/demo/DemoApplication.java Step 2 Add a web controller package com.example.demo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @SpringBootApplication @RestController public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } @GetMapping("/") public String saySomething() { return "Java app on Cloud Run, containerized by Jib!"; } }

Slide 25

Slide 25 text

Run command below Step 3 Rebuild and run the app. ./mvnw spring-boot:run

Slide 26

Slide 26 text

Activate the Container Registry API. Step 4 Containerize your app and publish to Container Registry gcloud services enable containerregistry.googleapis.com

Slide 27

Slide 27 text

Run Jib to build a Docker image and publish to Container Registry. Step 5 Containerize your app and publish to Container Registry ./mvnw com.google.cloud.tools:jib-maven-plugin:3.3.1:build \ -Dimage=gcr.io/$GOOGLE_CLOUD_PROJECT/kotlin-jib-cloud-run \ -Djib.from.image=eclipse-temurin:17-jre

Slide 28

Slide 28 text

Step 6 Run the containerized app on Cloud Run

Slide 29

Slide 29 text

Step 6 Run the containerized app on Cloud Run

Slide 30

Slide 30 text

References ● https://codelabs.developers.google.com/codelabs/cloud-kotlin-jib-cloud -run ● https://codelabs.developers.google.com/codelabs/cloud-run-hello-pyth on3?hl=en#0 ● https://codelabs.developers.google.com/codelabs/getting-started-with- cloud-run-functions-http?hl=en#0 ● https://cloud.google.com/architecture/serverless-blueprint ● https://cloud.google.com/run/docs/resource-model ● https://github.com/GoogleCloudPlatform/microservices-demo

Slide 31

Slide 31 text

Thank you Jakarta