Kotless Kotlin Serverless Framework Vladislav Tankov @vdtankov - - PowerPoint PPT Presentation

kotless kotlin serverless framework vladislav tankov
SMART_READER_LITE
LIVE PREVIEW

Kotless Kotlin Serverless Framework Vladislav Tankov @vdtankov - - PowerPoint PPT Presentation

Kotlin 1.4 Online Event Kotless Kotlin Serverless Framework Vladislav Tankov @vdtankov October 15, 2020 Introduction to serverless A few words on the hottest topic Serverless is a cloud-computing execution model in which the cloud


slide-1
SLIDE 1

Kotlin 1.4 Online Event October 15, 2020 @vdtankov

Kotless Kotlin Serverless Framework Vladislav Tankov

slide-2
SLIDE 2

Introduction to serverless

A few words on the hottest topic

slide-3
SLIDE 3

Serverless is a cloud-computing execution model in which the cloud provider runs the server and dynamically manages the allocation of machine resources

Wikipedia

slide-4
SLIDE 4

Basically, it means

1. Take small elements – stateless functions 2. Combine them with events to make an application 3. Run the application in the cloud

slide-5
SLIDE 5

Async Use Sync Rest API /b

/a

/b

/a

slide-6
SLIDE 6

Why?

slide-7
SLIDE 7

Pros of serverless

  • Pay per request
  • Scale up to thousands of CPUs
  • Fault-tolerant
slide-8
SLIDE 8

No cons?

slide-9
SLIDE 9

### API route: GET /long variable "_long_envvars" { type = "map" default = { KOTLESS_PACKAGES = "kotless" } } resource "aws_lambda_function" "_long" { function_name = "Handler__long" s3_bucket = "${aws_s3_bucket.ktltst_lambda_s3.bucket}" s3_key = "${aws_s3_bucket_object.ktltst_bucket_object.key}" source_code_hash = "${base64sha256(file("../build/libs/kotless-dsl-1.0-all.jar"))}" handler = "kotless.Lambda::handleRequest" runtime = "java8" timeout = 30 role = "${aws_iam_role.ktltst_lambda_role.arn}" memory_size = 256 environment = { variables = "${var._long_envvars}" } } resource "aws_lambda_permission" "_long" { statement_id = "AllowAPIGatewayInvoke" action = "lambda:InvokeFunction" function_name = "${aws_lambda_function._long.arn}" principal = "apigateway.amazonaws.com" source_arn = "${aws_api_gateway_deployment.ktltst_example_deployment.execution_arn}/*/*" } resource "aws_api_gateway_resource" "_long" { parent_id = "${aws_api_gateway_rest_api.ktltst_example_rest_api.root_resource_id}" rest_api_id = "${aws_api_gateway_rest_api.ktltst_example_rest_api.id}" path_part = "long" } resource "aws_api_gateway_method" "_long" { rest_api_id = "${aws_api_gateway_rest_api.ktltst_example_rest_api.id}" resource_id = "${aws_api_gateway_resource._long.id}" http_method = "ANY" authorization = "NONE" } resource "aws_api_gateway_integration" "_long" { rest_api_id = "${aws_api_gateway_rest_api.ktltst_example_rest_api.id}" resource_id = "${aws_api_gateway_method._long.resource_id}" http_method = "${aws_api_gateway_method._long.http_method}" depends_on = [ "aws_api_gateway_method._long" ] integration_http_method = "POST" type = "AWS_PROXY" uri = "${aws_lambda_function._long.invoke_arn}" }

Tons of configuration!

slide-10
SLIDE 10

Could it be simpler?

slide-11
SLIDE 11

Kotlin Serverless Framework

Let’s change the game (at least for the Web)

slide-12
SLIDE 12

@Get("/hello-world") fun helloWorld(): String { return "Hello World" }

slide-13
SLIDE 13

Deduce configuration from code

slide-14
SLIDE 14
slide-15
SLIDE 15

Infrastructure in Code

  • Write the code with the framework of your choice
  • Choose a Cloud platform to use
  • Let Kotless do the deployment for you
slide-16
SLIDE 16

@Get("/hello-world") fun helloWorld(): String { return "Hello World" }

Code only

slide-17
SLIDE 17

What is in the box?

Current state of the project

slide-18
SLIDE 18

What is in the box?

  • Number of supported frameworks
  • Each of them can be deployed to the cloud
  • With the target runtime of your choice
slide-19
SLIDE 19

Supported frameworks

  • Ktor
  • Spring Framework
  • Kotless’s own DSL
slide-20
SLIDE 20

Supported clouds

  • Amazon Web Services
  • In development

○ Google Cloud Platform ○ Microsoft Azure

slide-21
SLIDE 21

Supported runtimes

  • Kotlin/JVM
  • GraalVM
  • In development

○ Kotlin/JS

slide-22
SLIDE 22

Runtimes Clouds Frameworks

slide-23
SLIDE 23

And even local starts!

slide-24
SLIDE 24

Local development

  • Local emulation of Cloud services
  • Ability to debug serverless applications
  • No cloud account required to try it
slide-25
SLIDE 25

Summing it up

  • Choose the runtime that best meets your needs
  • Write an application with your favorite framework
  • Test and debug it locally
  • Deploy an application to your pr
slide-26
SLIDE 26

How does it work?

A bit of internals

slide-27
SLIDE 27

Under the hood

  • Parse an application
  • Generate a cloud-agnostic Schema
  • Transpile the Schema to a Terraform
  • Perform the deployment

Application Terraform Cloud Schema Parser Engine

slide-28
SLIDE 28

@DynamoDBTable("table", ReadWrite)

  • bject URLStorage {

fun getByCode(code: String): String { ... } }

Cloud integration

  • Permissions are granted via

Cloud-specific annotations

  • Events also work via annotations
slide-29
SLIDE 29

Demo

Better than a thousand words

slide-30
SLIDE 30

What is next?

Future plans

slide-31
SLIDE 31

In development

  • Cloud Platforms

○ Google Cloud Platform ○ Microsoft Azure

  • Runtimes

○ GraalVM ○ Kotlin/JS

slide-32
SLIDE 32

Future plans

  • IntelliJ IDEA plugin

○ Remote logs tailing ○ Debugging

  • Cloud-specific extensions

○ Authentication ○ Events

  • And lots more!
slide-33
SLIDE 33

Thanks! Have a nice Kotlin

@vdtankov