Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Efficient Ops Tooling with Java and GraalVM

Efficient Ops Tooling with Java and GraalVM

Ops tooling has so far been the domain of shell scripts, interpreted languages like Python or statically compiled languages like Go. But with Java and GraalVM this situation changes significantly.

So behold: it is now possible to apply the power of the Java language and its ecosystem to your Ops tooling problems and yet get performance and efficiency by using GraalVM native images. In this session we will show that native CLI tools and K8s operators can be implemented in Java quite easily in no time.

M.-Leander Reimer

January 29, 2020
Tweet

More Decks by M.-Leander Reimer

Other Decks in Programming

Transcript

  1. Efficient DevOps Tooling with Java Cloud Native Night Munich, January

    2020 Edition @LeanderReimer #cloudnativenerd #qaware
  2. // Cloud Native Night Munich // Efficient DevOps Tooling with

    Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware #whoami 2 Mario-Leander Reimer Chief Software Architect QAware GmbH
  3. // Cloud Native Night Munich // Efficient DevOps Tooling with

    Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware How do you organise and enable technology teams for fast flow and high productivity? 3
  4. // Cloud Native Night Munich // Efficient DevOps Tooling with

    Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware 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
  5. // Cloud Native Night Munich // Efficient DevOps Tooling with

    Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware Eliminate extraneous cognitive load 
 Minimize intrinsic cognitive load 5
  6. // Cloud Native Night Munich // Efficient DevOps Tooling with

    Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware 6
  7. // Cloud Native Night Munich // Efficient DevOps Tooling with

    Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware Use the right language for the job!? 7 Getty Images Liliboas
  8. // Cloud Native Night Munich // Efficient DevOps Tooling with

    Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware GraalVM to the Rescue! 8
  9. // Cloud Native Night Munich // Efficient DevOps Tooling with

    Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware 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 9
  10. // Cloud Native Night Munich // Efficient DevOps Tooling with

    Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware 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)! 10 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'])"); } }
  11. // Cloud Native Night Munich // Efficient DevOps Tooling with

    Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware 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. 11
  12. // Cloud Native Night Munich // Efficient DevOps Tooling with

    Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware 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. 12 For complete list and info, read https://medium.com/@jdxcode/12-factor-cli-apps-dd3c227a0e46
  13. // Cloud Native Night Munich // Efficient DevOps Tooling with

    Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware 13 Code & Demos https://github.com/lreimer/microj-jakartaee8-payara5 https://github.com/lreimer/microj-cli https://github.com/lreimer/hands-on-graalvm
  14. // Cloud Native Night Munich // Efficient DevOps Tooling with

    Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware 14 Operator. - Do stuff to my Kubernetes.
  15. // Cloud Native Night Munich // Efficient DevOps Tooling with

    Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware The Kill Pod Operator 15 • 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: ...
  16. // Cloud Native Night Munich // Efficient DevOps Tooling with

    Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware The Super Secret Operator 16 • 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==
  17. // Cloud Native Night Munich // Efficient DevOps Tooling with

    Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware The Microservice Operator 17 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
  18. // Cloud Native Night Munich // Efficient DevOps Tooling with

    Java and GraalVM // @LeanderReimer #cloudnativenerd #qaware 18 Code & Demos https://github.com/lreimer/graal-operators