Kubernetes pour des développeurs Java

A presentation at MarsJUG in March 2020 in Marseille, France by Horacio Gonzalez

Slide 1

Slide 1

Kubernetes for Java Developers Horacio Gonzalez @LostInBrittany

Slide 2

Slide 2

Who are we? Introducing myself and introducing OVH OVHcloud

Slide 3

Slide 3

Horacio Gonzalez @LostInBrittany Spaniard lost in Brittany, developer, dreamer and all-around geek Flutter

Slide 4

Slide 4

OVHcloud: A Global Leader 200k Private cloud VMs running 1 Dedicated IaaS Europe 30 Datacenters Own 20Tbps Hosting capacity : 1.3M Physical Servers 360k Servers already deployed Netwok with 35 PoPs

1.3M Customers in 138 Countries

Slide 5

Slide 5

OVHcloud: Our solutions Cloud Web Hosting Mobile Hosting Telecom VPS Containers ▪ Dedicated Server Domain names VoIP Public Cloud Compute ▪ Data Storage Email SMS/Fax Private Cloud ▪ Network and Database CDN Virtual desktop Serveur dédié Security Object Storage Web hosting Cloud Storage Over the Box ▪ Licences Cloud Desktop Securities MS Office Hybrid Cloud Messaging MS solutions

Slide 6

Slide 6

Orchestrating containers Like herding cats… but in hard mode!

Slide 7

Slide 7

From bare metal to containers Another paradigm shift

Slide 8

Slide 8

Containers are easy… For developers

Slide 9

Slide 9

Less simple if you must operate them Like in a production context

Slide 10

Slide 10

And what about microservices? Are you sure you want to operate them by hand?

Slide 11

Slide 11

Taming microservices with Kubernetes

Slide 12

Slide 12

Kubernetes is modular

Slide 13

Slide 13

Kubernetes Way more than a buzzword!

Slide 14

Slide 14

Masters and nodes

Slide 15

Slide 15

Some more details

Slide 16

Slide 16

Desired State Management

Slide 17

Slide 17

Multi-environment made easy Dev, staging, prod, multi-cloud…

Slide 18

Slide 18

Declarative infrastructure Multi-environment made easy

Slide 19

Slide 19

Having identical, software defined envs

Slide 20

Slide 20

I have deployed on Minikube, woah! A great fastlane into Kubernetes

Slide 21

Slide 21

Running a full K8s in your laptop A great learning tool

Slide 22

Slide 22

Your laptop isn’t a true cluster Don’t expect real performances

Slide 23

Slide 23

Beyond the first deployment So I have deployed my distributed architecture on K8s, everything is good now, isn’t it?

Slide 24

Slide 24

Minikube is only the beginning

Slide 25

Slide 25

GraalVM An alternative JVM with a twist

Slide 26

Slide 26

A long time ago, when the JVM was young HotSpot becomes the offical JVM in Java 1.3

Slide 27

Slide 27

HotSpot has tiered compilation It starts in interpreter mode, then C1 JIT and, if needed, C2 JIT

Slide 28

Slide 28

Really powerful, really complex Last big addition: JVM Intrinsics

Slide 29

Slide 29

It worked really well, but its getting old… C++ stack, old code base, difficult to maintain

Slide 30

Slide 30

The Java platform to the rescue JVM Compiler Interface (JVMCI) - JEP 243 Ahead of Time (AoT) Compilation - JEP 295

Slide 31

Slide 31

Graal project An Oracle project to rethink the JVM

Slide 32

Slide 32

Graal compiler ● A Java compiler written in Java ○ Capable of compiling itself! ● Independent of HotSpot ○ Can be used in HotSpot with JVMCI ● Can do either JIT or AOT compilations

Slide 33

Slide 33

What’s GraalVM? A standalone Java Development Kit to execute: ● JVM-based languages ● Dynamic languages ● LLVM-based languages

Slide 34

Slide 34

What’s GraalVM?

Slide 35

Slide 35

What’s GraalVM?

Slide 36

Slide 36

GraalVM Features GraalVM lets you: ● Run your code faster and more efficiently ● Interoperate directly with most modern programming languages ● Embed languages with the GraalVM SDK ● Create compiled native images ● Use a single set of tools to monitor, debug, and profile all your code

Slide 37

Slide 37

GraalVM base package The base installation includes: ● The JVM ● The Graal compiler ● The LLVM bitcode interpreter ● The JavaScript runtime

Slide 38

Slide 38

Why GraalVM? For Java programs: ● Run Java faster ● Make Your Application Extensible ● Create a Native Image

Slide 39

Slide 39

Why GraalVM? For JavaScript programs: ● Reuse Libraries from Java, R, or Python ● Run with Large Heaps ● Define Data Structures in C/C++

Slide 40

Slide 40

Why GraalVM? GraalVM native images reduce: ● Runtime memory footprint ● Startup time

Slide 41

Slide 41

And how does it compile ? Dead code elimination Closed world assumption

Slide 42

Slide 42

Adding some limitations…

Slide 43

Slide 43

Two versions Community Edition & Enterprise Edition

Slide 44

Slide 44

Polyglot GraalVM Wasm, JS, Ruby, Python, R, C, C++, Rust…

Slide 45

Slide 45

Sulong and Truffle Lots of languages… and growing!

Slide 46

Slide 46

Running JavaScript code function sayHello() { console.log(‘Hello!’); } sayHello(); Using GraalVM js command $ ~/opt/graalvm/bin/js sayHello.js Hello!

Slide 47

Slide 47

Running NodeJS code const http = require(“http”); const span = require(“ansispan”); require(“colors”); http.createServer(function (request, response) { response.writeHead(200, {“Content-Type”: “text/html”}); response.end(span(“Hello Graal.js!”.green)); }).listen(8000, function() { console.log(“Graal.js server running at http://127.0.0.1:8000/”.red); }); Using GraalVM node and npm commands $ ~/opt/graalvm/bin/npm install colors ansispan […] + colors@1.4.0 + ansispan@0.0.4 added 2 packages from 3 contributors in 14.951s $ ~/opt/graalvm/bin/node helloNode.js Graal.js server running at http://127.0.0.1:8000/

Slide 48

Slide 48

Running WebAssembly Programs #include <stdio.h> int main() { int number = 1; int rows = 10; for (int i = 1; i <= rows; i++) { for (int j = 1; j <= i; j++) { printf(“%d “, number); ++number; } printf(“.\n”); } return 0; } Using wasm launcher graalvm/bin/wasm —Builtins=memory,env:emscripten your_module.wasm

Slide 49

Slide 49

Embedding WebAssembly Programs import org.graalvm.polyglot.*; import org.graalvm.polyglot.io.ByteSequence; // You need to load the .wasm contents into a byte array. byte[] binary = readBytes(“example.wasm”); Source.Builder sourceBuilder = Source.newBuilder(“wasm”, ByteSequence.create(binary), “example”); Source source = sourceBuilder.build(); Context.Builder contextBuilder = Context.newBuilder(“wasm”); Context context = contextBuilder.build(); context.eval(source); Value mainFunction = context.getBindings(“wasm”).getMember(“_main”); mainFunction.execute();

Slide 50

Slide 50

GraalVM 💗 Kubernetes Giving Java a place in a Cloud Native world

Slide 51

Slide 51

Containers didn’t love Java Big images, slow to start, memory hungry…

Slide 52

Slide 52

GraalVM change things Small images, fast start, low memory footprint

Slide 53

Slide 53

Java is now a real alternative in Cloud Native First class cloud player!

Slide 54

Slide 54

But what about old apps? Most of them difficult to compile in GraalVM

Slide 55

Slide 55

Enter Quarkus A new generation Java app stack

Slide 56

Slide 56

Quarkus Supersonic Subatomic Java

Slide 57

Slide 57

What’s Quarkus? ● A Kubernetes Native Java stack ● Tailored for OpenJDK HotSpot and GraalVM ● Crafted from the best of breed Java libraries and standards

Slide 58

Slide 58

Container first

Slide 59

Slide 59

Unifies imperative and reactive Combine imperative code and the non-blocking reactive style

Slide 60

Slide 60

By developers, for developers ● Unified configuration ● Zero config, live reload in the blink of an eye ● Streamlined code for the 80% common usages, flexible for the 20% ● No hassle native executable generation

Slide 61

Slide 61

Leveraging the ecosystem Over fifty best-of-breed libraries wired on a standard backbone

Slide 62

Slide 62

Conclusion That’s all, folks!