Slide 1

Slide 1 text

Efficient DevOps Tooling with Java and GraalVM JCON2020 # www.jcon.one Mario-Leander Reimer Principal Software Architect, QAware GmbH Our Partners 2020:

Slide 2

Slide 2 text

Mario-Leander Reimer Principal Software Architect @LeanderReimer #cloudnativenerd #qaware

Slide 3

Slide 3 text

// JCON 2020 // Efficient DevOps Tooling with Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware #JCON2020 How do you organise and enable DevOps teams for fast flow and high productivity? 3

Slide 4

Slide 4 text

// JCON 2020 // Efficient DevOps Tooling with Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware #JCON2020 Too much cognitive load will become a bottleneck for fast flow and high productivity. • Instrinsic Cognitive Load - relates to fundamental aspects and knowledge in the problem space (e.g. used languages, APIs, frameworks) • Extraneous Cognitive Load - relates to the environment (e.g. deployment, configuration, console commands) • Germane Cognitive Load - relates to specific aspects of the business domain (aka. „value added“ thinking) 4 https://teamtopologies.com

Slide 5

Slide 5 text

// JCON 2020 // Efficient DevOps Tooling with Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware #JCON2020 Eliminate extraneous cognitive load Minimize intrinsic cognitive load 5

Slide 6

Slide 6 text

// JCON 2020 // Efficient DevOps Tooling with Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware #JCON2020 6

Slide 7

Slide 7 text

// JCON 2020 // Efficient DevOps Tooling with Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware #JCON2020 Use the right language for the job!? 7 Getty Images Liliboas Ansible Shell Scripts Ruby Python

Slide 8

Slide 8 text

// JCON 2020 // Efficient DevOps Tooling with Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware #JCON2020 8

Slide 9

Slide 9 text

// JCON 2020 // Efficient DevOps Tooling with Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware #JCON2020 GraalVM to the Rescue! 9

Slide 10

Slide 10 text

// JCON 2020 // Efficient DevOps Tooling with Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware #JCON2020 GraalVM in a Nutshell • Polyglot Runtime: runs all JVM languages, R, JavaScript, NodeJS, Ruby, Python, C/C++ via LLVM with full interop • Ahead-of-time (AOT) Compilation: memory management, thread scheduling via SubstrateVM • GraalVM as a Platform: embed and extend GraalVM with Truffle, implement your own language and tools 10

Slide 11

Slide 11 text

// JCON 2020 // Efficient DevOps Tooling with Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware #JCON2020 Polyglot Mayhem • The Graal Polyglot API allows you to embed and use different languages with full bidirectional interop. • This is not the same as with the Java Scripting API (JSR 223)! 11 private static void helloPython(PolyglotMessage message) { try (Context context = Context.newBuilder().allowAllAccess(true).build()) { context.getPolyglotBindings().putMember("message", message); context.eval("python", "import polyglot\n" + "message = polyglot.import_value('message')\n" + "message['invocations'] += 1\n" + "print(message['text'])"); } }

Slide 12

Slide 12 text

// JCON 2020 // Efficient DevOps Tooling with Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware #JCON2020 The Swiss Army Knife of Operations. 12 CLIs - The Swiss Army Knife of Operations

Slide 13

Slide 13 text

// JCON 2020 // Efficient DevOps Tooling with Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware #JCON2020 The basics of 12-factor CLI apps • Great help is essential. What version am I on? • Prefer flags to positional arguments. • Mind the streams. stdout is for output, stderr is for messaging. • Handle things going wrong: error code, title, how to fix, URL, … • Be fancy: use colours, have shell completion. • Prompt if you can. • Be speedy. CLIs need to start fast. • Be clear about subcommands. 13 For complete list and info, read https://medium.com/@jdxcode/12-factor-cli-apps-dd3c227a0e46

Slide 14

Slide 14 text

// JCON 2020 // Efficient DevOps Tooling with Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware #JCON2020 Build CLIs with Picocli and GraalVM • Native DevOps tools, CLIs or sidecar containers can now also be build using Java! Golang is still cool. • Picoli is a small framework to easily build JVM command line apps. • Support for ANSI colors, tab completion, sub commands and other 12-factor CLI app principles • In-built support for GraalVM AOT compilation to native images via the ReflectionConfigGenerator utility. 14

Slide 15

Slide 15 text

JCON2020 # www.jcon.one Code & Demos https://github.com/lreimer/hands-on-graalvm https://github.com/lreimer/microj-cli https://github.com/lreimer/microj-jakartaee8-payara5

Slide 16

Slide 16 text

// JCON 2020 // Efficient DevOps Tooling with Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware #JCON2020 Container Orchestration Patterns 16 Sidecar Container Extended Container Behaviour • Log Extraction / Reformatting (fluentd, file beat) • Scheduling (cron, quartz) Ambassador Container Proxy Communication • TLS Tunnel (ghostunnel, Istio) • Circuit Breaking (linked, Istio) • Request Monitoring (linked, Istio) Adapter Container Standardized Ops Interfaces • Monitoring (Prometheus) • Configuration (ConfigMaps, Secrets, …)

Slide 17

Slide 17 text

// JCON 2020 // Efficient DevOps Tooling with Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware #JCON2020 17 Operator. - Do stuff to my Kubernetes.

Slide 18

Slide 18 text

// JCON 2020 // Efficient DevOps Tooling with Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware #JCON2020 What are operators? • Operators are codified Ops procedures! • Operators are the path towards Zero-Ops. They enable auto-updating, self-monitoring and self-healing infrastructure and applications. • The concept was coined in the Kubernetes world. It’s now been adopted and used widespread in the cloud native world. • Examples: OKD, Sealed Secrets, Kube Monkey, Weave Flux 18

Slide 19

Slide 19 text

// JCON 2020 // Efficient DevOps Tooling with Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware #JCON2020 Kubernetes Operators in a Nutshell 19

Slide 20

Slide 20 text

// JCON 2020 // Efficient DevOps Tooling with Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware #JCON2020 The Kill Pod Operator 20 • Super simple Chaos monkey style operator inspired by Kubemonkey • Regularly kills pods of deployments that are killpod/enabled apiVersion: apps/v1 kind: Deployment metadata: name: nginx-killpod-enabled labels: killpod/enabled: "true" killpod/application: nginx-killpod-enabled killpod/delay: "30" killpod/amount: "2" spec: ...

Slide 21

Slide 21 text

// JCON 2020 // Efficient DevOps Tooling with Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware #JCON2020 The Super Secret Operator 21 • Apply asymmetrical encrypted secrets, the operator will decrypt and manage ordinary K8s secrets under the hood • Inspired by Sealed Secrets from Bitnami https://github.com/bitnami-labs/sealed-secrets apiVersion: operators.on.hands/v1alpha1 kind: SuperSecret metadata: name: supersecret-test spec: secretData: password: eV7YoQXyZlY+y51RWXEqyu0U44EPEPwEz+fZvGo+7McOTA4wQYCdxXMANtab3aW8 ... ywqpkHYtSLvrPgFnbcuSvD2UzuUNeE2qkh6SAM1z9Lpfwi+IUZjaY34Z+RjEL5OZFPYkQ==

Slide 22

Slide 22 text

// JCON 2020 // Efficient DevOps Tooling with Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware #JCON2020 The Microservice Operator 22 apiVersion: operators.on.hands/v1alpha1 kind: Microservice metadata: name: microservice-test labels: app: nginx spec: replicas: 2 image: nginx:1.17.6 ports: - containerPort: 80 serviceType: LoadBalancer • Abstracting the usual Deployment, Service and ConfigMap definitions using a simple and unified Microservice CRD

Slide 23

Slide 23 text

JCON2020 # www.jcon.one Code & Demos https://github.com/lreimer/graal-operators

Slide 24

Slide 24 text

Thank You ! JCON2020 # www.jcon.one Our Partners 2020: Mario-Leander Reimer Principal Software Architect, QAware GmbH [email protected] https://www.qaware.de https://speakerdeck.com/lreimer/ https://github.com/lreimer/

Slide 25

Slide 25 text

www.javapro.io Das kostenlose Profi-Magazin für Java Entwickler ! Powered by