SlideShare una empresa de Scribd logo
1 de 36
Descargar para leer sin conexión
Ó Adcubum AG
1
Master your Java applications in
Kubernetes Andy Moncsek
03.2019
Ó Adcubum AG
2
§ Andy Moncsek à Architect
§ Creator or… see my Github
§ Likes coffee & HiFi & cameras
§ Twitter: @AndyAHCP
About me
Ó Adcubum AG
3
Agenda
§ Choose your (Java) Runtime
§ Build & execute your applications
§ Create your image
§ Run your applications in Kubernetes
§ Final thoughts
Ó Adcubum AG
4
§ How to integrate?
You plan to move to Kubernetes?
Typical issues
§ Slow startup? § No more capacity?
Ó Adcubum AG
5
Choose your (Java) Runtime
Ó Adcubum AG
6
§ Support?
§ License & LTS?
§ Container aware?
§ since Java SE 8u131 & JDK 9
§ changes in JDK 8u191 & JDK 10
Choose your (Java) Runtime
Ó Adcubum AG
7
Hotspot + C1 & C2 Jit
Choose your (Java) Runtime
Many (possible) options, out there
+ Substrate VM
Hotspot
+
Ó Adcubum AG
8
§ Contributed by IBM to the Eclipse Foundation in 2017
§ It replaces HotSpot JVM in the OpenJDK build
§ Small memory footprint & fast startup
§ Optimization for virtualized environments
Choose your (Java) Runtime
OpenJ9
Ó Adcubum AG
9
§ Universal VM running various languages
§ Removes isolation & enables interoperability between programming languages
§ Can be integrated in various native & managed env. (OpenJDK, Node.js, OracleDB, MySQL,…)
Choose your (Java) Runtime
GraalVM
§ The Graal compiler
§ as JIT compiler since Java 10
§ as AOT compiler since Java 9
Ó Adcubum AG
10
Choose your (Java) Runtime
Relation to Containers / Kubernetes?
§ JVM needs to be aware of containers (CPU & memory)
§ Small memory/image footprint (run & deploy many containers)
§ Fast startup time (auto scaler, elastic)
Ó Adcubum AG
11
Build & execute your application
Ó Adcubum AG
12
§ -XX:[+|-]UseContainerSupport
§ Correct CPU count & total memory allocated to the container
§ -XX:InitialRAMPercentage
§ Set initial heap size as a percentage of total memory (-Xms)
§ -XX:MaxRAMPercentage & -XX:MinRAMPercentage
§ used to calculate maximum heap size (-Xmx)
Build & execute your application
“Basic” container specific flags
phys_mem * MinRAMPercentage / 100 (if this value is less than 96M)
MAX(phys_mem * MaxRAMPercentage / 100, 96M)
Ó Adcubum AG
13
§ -Xtune:virtualized
§ Tuning for containers
§ Reduction in footprint & startup time (but also in throughput)
§ Enables VM idle management
§ -Xquickstart
§ Designed for the fastest start-up
§ Ideal for short-lived tasks
§ May limit peak throughput
Build & execute your application
OpenJ9 specific container flags
Ó Adcubum AG
14
§ AOT compilation (since JDK9 / JEP 295)
§ Transforms Java bytecode to OS-specific machine code
§ Performs simple optimizations of Java bytecode
§ AOT vs. JIT compiled (rule of thumb)
§ Pro: better startup time
§ Cons: worse performance of long-running applications
Build & execute your application
Ahead-of-time (AOT)
> jaotc --output app.so --jar microservice.jar --module jdk.httpserver --module java.base
> java -XX:AOTLibrary=./app.so -jar microservice.jar
Ó Adcubum AG
15
§ Since JDK10 (JEP310)
§ Sharing of classes loaded by the application class loader
§ Still some limitations (since Java 11 support for module path)
§ Flag UseAppCDS (introduced in Java 10) removed in Java12
§ Automatically enabled in Java 12
§ Reduce memory footprint/startup time
§ Needs two preparation steps
Build & execute your application
AppCDS
Heap Objects
Shared String O.
Shared Classes
Class Metadata
JVM 1
Heap Objects
Shared String O.
Shared Classes
Class Metadata
JVM 2
Archive
File
Ó Adcubum AG
16
Build & execute your application
AppCDS Usage à DEMO
// step1: run the app & record all classes
java -XX:+UseAppCDS -XX:DumpLoadedClassList=classes.lst –jar 
app.jar
// step 2: create an archive
java -XX:+UseAppCDS -Xshare:dump -XX:SharedClassListFile=classes.lst 
-XX:SharedArchiveFile=cds.jsa --class-path app.jar
// step 3: start/use your application
java -XX:+UseAppCDS -Xshare:on -XX:SharedArchiveFile=cds.jsa –jar 
app.jar
Ó Adcubum AG
17
§ Enable class data sharing à AOT compilation is also enabled by default
§ dynamically compiles certain methods into AOT code at runtime
§ applicable to boot, extension, & application loaders & all URLClassloader-subclasses
§ -Xshareclasses option to enable class sharing & AOT
§ -Xshareclasses:cacheDir=/opt/shareclasses
Build & execute your application
CDS & AOT in OpenJ9
JVM 1 JVM 2 JVM 3
Shared classes
cache
Ó Adcubum AG
18
§ Native compilation (in a nutshell)
§ Based on Graal compiler & SubstrateVM
§ Still many limitations (class loading, reflection,… )
§ How to use
§ Download GraalVM & Build your (fat) jar
§ native-image –jar app.jar && ./app
§ Working frameworks?
§ Micronaut, Spark Java, Vert.x
Build & execute your application
Native compilation
Ó Adcubum AG
19
Build & execute your application
Some benchmarks ;-) from October 2018 / Java 10
https://www.slideshare.net/trivadis/techevent-graalvm-performance-interoperability
Always do you own tests!
Ó Adcubum AG
20
Create your images
Ó Adcubum AG
21
§ Shrink your image to a minimum
§ Works also with non-modular Java applications (like spring-boot)
Create your image
Usage of modular run-time images & multi-stage builds
FROM openjdk:12-ea-jdk-alpine3.8 as builder
RUN jlink  // works for spring-boot
--add-modules java.sql, java.naming, java.net.http, java.management,
java.instrument,java.security.jgss,java.desktop,jdk.unsupported 
--verbose --strip-debug --compress 2 --no-header-files 
--no-man-pages --output /opt/jre-minimal
FROM alpine:3.8
COPY --from=builder /opt/jre-minimal /opt/jre-minimal
PATH=${PATH}:/opt/jre-minimal/bin
. . .
CMD
Ó Adcubum AG
22
§ Use multistage builds, if needed
§ Split up layers, based on their potential for reuse
§ Put any components that will update very rarely at the top of the Dockerfile
§ Merge commands together, because each RUN line adds a layer to the image
§ Advantage: faster builds, less storage, pull faster
Create your image
Create lean images
# Do
RUN apt-get update && 
apt-get install package-bar
# Don’t
RUN apt-get update
RUN apt-get install package-bar
Ó Adcubum AG
23
Create your image
Create lean images
FROM adoptopenjdk/openjdk11-openj9:alpine-slim
RUN mkdir -p /usr/src/app && mkdir -p /usr/src/app/config
ARG APPLICATION=target/application
COPY ${APPLICATION}/BOOT-INF/lib /app/lib
COPY ${APPLICATION}/META-INF /app/META-INF
COPY ${APPLICATION}/BOOT-INF/classes /app
ENTRYPOINT ["java","-cp","app:app/lib/*:/usr/src/app/config",»com.*.KafkaAdapterMain"]
(reuse) dependencies
Ó Adcubum AG
24
§ Try to avoid “fat” jars & wars
§ Use skinny / thin
§ Different approaches for:
§ Tomcat, Open Liberty, WildFly, Spring
§ Spring
§ Maven dependency plugin
§ Open Liberty boost plugin
§ spring-boot-thin-launcher
Create your image
Think about your layers
https://openliberty.io/blog/2018/07/02/creating-dual-layer-docker-images-for-spring-boot-apps.html
Ó Adcubum AG
25
Be frugal
Choose your image
Image type Red Hat
Enterprise 7
Standard
Red Hat
Enterprise
Atomic
Debian Stable Alpine
C Library glibc glibc glibc musel c
Size on Disk 200MB 78MB 100MB 4MB
§ Look for vendor-specific (or official) images
§ Don’t use :latest or no tag!
§ Do you really need an application server?
Ó Adcubum AG
26
Run your application (in Kubernetes)
Ó Adcubum AG
27
Run your application
Share your CDS files in Kubernetes
apiVersion: v1
kind: Pod
metadata:
name: myApp
spec:
containers:
- image: myApp
name: myApp
volumeMounts:
- mountPath: /cdscache
name: cdscache
volumes:
- name: cdscache
hostPath:
path: /cdscache #location on host
type: Directory
CMD java -jar -Xshareclasses:cacheDir=/cdscache app.jar
Ó Adcubum AG
28
§ Each Container has a request
of 0.25 cpu and 64MB of
memory.
§ Each Container has a limit of
0.5 cpu and 128MB of
memory.
Run your application
Use resource request and limits
kind: Pod
metadata:
name: frontend
spec:
containers:
- name: wp
image: wordpress
resources:
requests:
memory: "64M"
cpu: "250m"
limits:
memory: "128M"
cpu: "500m"
....
Ó Adcubum AG
29
§ Apply quotas on Namespace level
§ Constraints on number of
objects, cpu & memory
§ When enabled, resource limits
must be set
Run your application
Quotas
kind: ResourceQuota
metadata:
name: quota
spec:
hard:
cpu: "2"
memory: 1G
pods: "10"
replicationcontrollers: " 5"
resourcequotas: "1"
services: "5"
Ó Adcubum AG
30
Run your application
ConfigMaps & Secrets to externalize your configuration
kind: ConfigMap
metadata:
name: spring-prop
data:
application.yml: |
server:
port: 8080
kind: Pod
spec:
volumes:
- name: config
configMap:
name: spring-prop
items:
- key: application.yml
path: application-kube.yml
containers:
- volumeMounts:
- name: config
mountPath: /usr/src/app/config
Ó Adcubum AG
31
Final thoughts
Ó Adcubum AG
32
§ Avoid infrastructure code in your applications
§ Service mesh with circuit breaker
§ Service Discovery (using DNS or Labels in Kubernetes)
§ Configuration via ConfigMap
§ Helm Charts to ship your application
§ Package manager like “apt” in Debian
§ Kubernetes Operators helps you to manage upgrades, lifecycle & insights
Be inventive
Final thoughts
Ó Adcubum AG
33
§ Don’t overlook Serverless!!
§ Better utilization of your cluster
§ Many measured run-times (AWS, Serverless,..)
§ Knative pushed to Kubernetes (by Google & Pivotal)
§ GraalVM and other projects focusing low footprint & fast startup
Be inventive
Final thoughts
Ó Adcubum AG
34
§ Why you should optimize your applications for containers & cloud?
§ Costs!!!!! à smaller footprint, CPU cycles, pay-per-use
§ The application life cycle has changed
§ no longer dominated by uptime
§ startup is now critical to your application
§ Expect to spend more and more time looking at resource usage,
performance and footprint.
Be inventive
Final thoughts
Ó Adcubum AG
35
Any questions?
Ó Adcubum AG
36
§ https://github.com/amoAHCP/JavaContainerTests
§ https://www.slideshare.net/DanHeidinga/j9-under-the-hood-of-the-next-open-source-jvm
§ https://github.com/eclipse/openj9-website/blob/master/benchmark/daytrader3.md
§ https://static.rainfocus.com/oracle/oow18/sess/1525896302003001DAHT/PF/CodeOne_2018_hw_154082375281200
1Nmsq.pdf
§ https://hub.docker.com/r/adoptopenjdk/openjdk10-openj9
§ https://www.eclipse.org/openj9/docs/xshareclasses/
Links

Más contenido relacionado

La actualidad más candente

Openstack Rally - Benchmark as a Service. Openstack Meetup India. Ananth/Rahul.
Openstack Rally - Benchmark as a Service. Openstack Meetup India. Ananth/Rahul.Openstack Rally - Benchmark as a Service. Openstack Meetup India. Ananth/Rahul.
Openstack Rally - Benchmark as a Service. Openstack Meetup India. Ananth/Rahul.Rahul Krishna Upadhyaya
 
PipelineAI + TensorFlow AI + Spark ML + Kuberenetes + Istio + AWS SageMaker +...
PipelineAI + TensorFlow AI + Spark ML + Kuberenetes + Istio + AWS SageMaker +...PipelineAI + TensorFlow AI + Spark ML + Kuberenetes + Istio + AWS SageMaker +...
PipelineAI + TensorFlow AI + Spark ML + Kuberenetes + Istio + AWS SageMaker +...Chris Fregly
 
Apache Performance Tuning: Scaling Out
Apache Performance Tuning: Scaling OutApache Performance Tuning: Scaling Out
Apache Performance Tuning: Scaling OutSander Temme
 
Streamline your development environment with docker
Streamline your development environment with dockerStreamline your development environment with docker
Streamline your development environment with dockerGiacomo Bagnoli
 
High Performance Distributed TensorFlow with GPUs - NYC Workshop - July 9 2017
High Performance Distributed TensorFlow with GPUs - NYC Workshop - July 9 2017High Performance Distributed TensorFlow with GPUs - NYC Workshop - July 9 2017
High Performance Distributed TensorFlow with GPUs - NYC Workshop - July 9 2017Chris Fregly
 
High Performance Distributed TensorFlow in Production with GPUs - NIPS 2017 -...
High Performance Distributed TensorFlow in Production with GPUs - NIPS 2017 -...High Performance Distributed TensorFlow in Production with GPUs - NIPS 2017 -...
High Performance Distributed TensorFlow in Production with GPUs - NIPS 2017 -...Chris Fregly
 
Performance Load Cache
Performance Load CachePerformance Load Cache
Performance Load CacheAltan Khendup
 
Nvidia GPU Tech Conference - Optimizing, Profiling, and Deploying TensorFlow...
Nvidia GPU Tech Conference -  Optimizing, Profiling, and Deploying TensorFlow...Nvidia GPU Tech Conference -  Optimizing, Profiling, and Deploying TensorFlow...
Nvidia GPU Tech Conference - Optimizing, Profiling, and Deploying TensorFlow...Chris Fregly
 
Android Platform Debugging and Development at ELCE 2013
Android Platform Debugging and Development at ELCE 2013Android Platform Debugging and Development at ELCE 2013
Android Platform Debugging and Development at ELCE 2013Opersys inc.
 
DCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDocker, Inc.
 
Optimizing, Profiling, and Deploying TensorFlow AI Models with GPUs - San Fra...
Optimizing, Profiling, and Deploying TensorFlow AI Models with GPUs - San Fra...Optimizing, Profiling, and Deploying TensorFlow AI Models with GPUs - San Fra...
Optimizing, Profiling, and Deploying TensorFlow AI Models with GPUs - San Fra...Chris Fregly
 
Into The Box 2018 | Content box + docker
Into The Box 2018 | Content box + dockerInto The Box 2018 | Content box + docker
Into The Box 2018 | Content box + dockerOrtus Solutions, Corp
 
Devfest 2021' - Artifact Registry Introduction (Taipei)
Devfest 2021' - Artifact Registry Introduction (Taipei)Devfest 2021' - Artifact Registry Introduction (Taipei)
Devfest 2021' - Artifact Registry Introduction (Taipei)KAI CHU CHUNG
 
Optimize + Deploy Distributed Tensorflow, Spark, and Scikit-Learn Models on G...
Optimize + Deploy Distributed Tensorflow, Spark, and Scikit-Learn Models on G...Optimize + Deploy Distributed Tensorflow, Spark, and Scikit-Learn Models on G...
Optimize + Deploy Distributed Tensorflow, Spark, and Scikit-Learn Models on G...Chris Fregly
 
Java & containers: What I wish I knew before I used it | DevNation Tech Talk
Java & containers: What I wish I knew before I used it | DevNation Tech TalkJava & containers: What I wish I knew before I used it | DevNation Tech Talk
Java & containers: What I wish I knew before I used it | DevNation Tech TalkRed Hat Developers
 
Docker and configuration management
Docker and configuration managementDocker and configuration management
Docker and configuration managementMukta Aphale
 
Tomcat and apache httpd training
Tomcat and apache httpd trainingTomcat and apache httpd training
Tomcat and apache httpd trainingFranck SIMON
 
Get you Java application ready for Kubernetes !
Get you Java application ready for Kubernetes !Get you Java application ready for Kubernetes !
Get you Java application ready for Kubernetes !Anthony Dahanne
 

La actualidad más candente (20)

Openstack Rally - Benchmark as a Service. Openstack Meetup India. Ananth/Rahul.
Openstack Rally - Benchmark as a Service. Openstack Meetup India. Ananth/Rahul.Openstack Rally - Benchmark as a Service. Openstack Meetup India. Ananth/Rahul.
Openstack Rally - Benchmark as a Service. Openstack Meetup India. Ananth/Rahul.
 
PipelineAI + TensorFlow AI + Spark ML + Kuberenetes + Istio + AWS SageMaker +...
PipelineAI + TensorFlow AI + Spark ML + Kuberenetes + Istio + AWS SageMaker +...PipelineAI + TensorFlow AI + Spark ML + Kuberenetes + Istio + AWS SageMaker +...
PipelineAI + TensorFlow AI + Spark ML + Kuberenetes + Istio + AWS SageMaker +...
 
JavaCro'15 - Conquer the Internet of Things with Java and Docker - Johan Jans...
JavaCro'15 - Conquer the Internet of Things with Java and Docker - Johan Jans...JavaCro'15 - Conquer the Internet of Things with Java and Docker - Johan Jans...
JavaCro'15 - Conquer the Internet of Things with Java and Docker - Johan Jans...
 
Apache Performance Tuning: Scaling Out
Apache Performance Tuning: Scaling OutApache Performance Tuning: Scaling Out
Apache Performance Tuning: Scaling Out
 
Streamline your development environment with docker
Streamline your development environment with dockerStreamline your development environment with docker
Streamline your development environment with docker
 
High Performance Distributed TensorFlow with GPUs - NYC Workshop - July 9 2017
High Performance Distributed TensorFlow with GPUs - NYC Workshop - July 9 2017High Performance Distributed TensorFlow with GPUs - NYC Workshop - July 9 2017
High Performance Distributed TensorFlow with GPUs - NYC Workshop - July 9 2017
 
High Performance Distributed TensorFlow in Production with GPUs - NIPS 2017 -...
High Performance Distributed TensorFlow in Production with GPUs - NIPS 2017 -...High Performance Distributed TensorFlow in Production with GPUs - NIPS 2017 -...
High Performance Distributed TensorFlow in Production with GPUs - NIPS 2017 -...
 
Performance Load Cache
Performance Load CachePerformance Load Cache
Performance Load Cache
 
Nvidia GPU Tech Conference - Optimizing, Profiling, and Deploying TensorFlow...
Nvidia GPU Tech Conference -  Optimizing, Profiling, and Deploying TensorFlow...Nvidia GPU Tech Conference -  Optimizing, Profiling, and Deploying TensorFlow...
Nvidia GPU Tech Conference - Optimizing, Profiling, and Deploying TensorFlow...
 
Android Platform Debugging and Development at ELCE 2013
Android Platform Debugging and Development at ELCE 2013Android Platform Debugging and Development at ELCE 2013
Android Platform Debugging and Development at ELCE 2013
 
DCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker Captains
 
Optimizing, Profiling, and Deploying TensorFlow AI Models with GPUs - San Fra...
Optimizing, Profiling, and Deploying TensorFlow AI Models with GPUs - San Fra...Optimizing, Profiling, and Deploying TensorFlow AI Models with GPUs - San Fra...
Optimizing, Profiling, and Deploying TensorFlow AI Models with GPUs - San Fra...
 
Into The Box 2018 | Content box + docker
Into The Box 2018 | Content box + dockerInto The Box 2018 | Content box + docker
Into The Box 2018 | Content box + docker
 
Devfest 2021' - Artifact Registry Introduction (Taipei)
Devfest 2021' - Artifact Registry Introduction (Taipei)Devfest 2021' - Artifact Registry Introduction (Taipei)
Devfest 2021' - Artifact Registry Introduction (Taipei)
 
Optimize + Deploy Distributed Tensorflow, Spark, and Scikit-Learn Models on G...
Optimize + Deploy Distributed Tensorflow, Spark, and Scikit-Learn Models on G...Optimize + Deploy Distributed Tensorflow, Spark, and Scikit-Learn Models on G...
Optimize + Deploy Distributed Tensorflow, Spark, and Scikit-Learn Models on G...
 
Java & containers: What I wish I knew before I used it | DevNation Tech Talk
Java & containers: What I wish I knew before I used it | DevNation Tech TalkJava & containers: What I wish I knew before I used it | DevNation Tech Talk
Java & containers: What I wish I knew before I used it | DevNation Tech Talk
 
Docker and configuration management
Docker and configuration managementDocker and configuration management
Docker and configuration management
 
2012 09-08-josug-jeff
2012 09-08-josug-jeff2012 09-08-josug-jeff
2012 09-08-josug-jeff
 
Tomcat and apache httpd training
Tomcat and apache httpd trainingTomcat and apache httpd training
Tomcat and apache httpd training
 
Get you Java application ready for Kubernetes !
Get you Java application ready for Kubernetes !Get you Java application ready for Kubernetes !
Get you Java application ready for Kubernetes !
 

Similar a Master your java_applications_in_kubernetes

The JVM in the Cloud: OpenJ9 and the traditional HotSpot JVM
The JVM in the Cloud: OpenJ9 and the traditional HotSpot JVMThe JVM in the Cloud: OpenJ9 and the traditional HotSpot JVM
The JVM in the Cloud: OpenJ9 and the traditional HotSpot JVMAndy Moncsek
 
Using Docker For Development
Using Docker For DevelopmentUsing Docker For Development
Using Docker For DevelopmentLaura Frank Tacho
 
L0037 - Basic Eclipse Configuration
L0037 - Basic Eclipse ConfigurationL0037 - Basic Eclipse Configuration
L0037 - Basic Eclipse ConfigurationTonny Madsen
 
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020Jelastic Multi-Cloud PaaS
 
It's always sunny with OpenJ9
It's always sunny with OpenJ9It's always sunny with OpenJ9
It's always sunny with OpenJ9DanHeidinga
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 
DCSF19 Dockerfile Best Practices
DCSF19 Dockerfile Best PracticesDCSF19 Dockerfile Best Practices
DCSF19 Dockerfile Best PracticesDocker, Inc.
 
[k8s] Kubernetes terminology (1).pdf
[k8s] Kubernetes terminology (1).pdf[k8s] Kubernetes terminology (1).pdf
[k8s] Kubernetes terminology (1).pdfFrederik Wouters
 
Securing Containers - Sathyajit Bhat - Adobe - Container Conference 18
Securing Containers - Sathyajit Bhat - Adobe - Container Conference 18Securing Containers - Sathyajit Bhat - Adobe - Container Conference 18
Securing Containers - Sathyajit Bhat - Adobe - Container Conference 18CodeOps Technologies LLP
 
Oracle goldengate and RAC12c
Oracle goldengate and RAC12cOracle goldengate and RAC12c
Oracle goldengate and RAC12cSiraj Ahmed
 
Java and Container - Make it Awesome !
Java and Container - Make it Awesome !Java and Container - Make it Awesome !
Java and Container - Make it Awesome !Dinakar Guniguntala
 
Integrating Apache Web Server with Tomcat Application Server
Integrating Apache Web Server with Tomcat Application ServerIntegrating Apache Web Server with Tomcat Application Server
Integrating Apache Web Server with Tomcat Application Serverwebhostingguy
 
Integrating Apache Web Server with Tomcat Application Server
Integrating Apache Web Server with Tomcat Application ServerIntegrating Apache Web Server with Tomcat Application Server
Integrating Apache Web Server with Tomcat Application Serverwebhostingguy
 
DCEU 18: Developing with Docker Containers
DCEU 18: Developing with Docker ContainersDCEU 18: Developing with Docker Containers
DCEU 18: Developing with Docker ContainersDocker, Inc.
 
Improving build solutions dependency management with webpack
Improving build solutions  dependency management with webpackImproving build solutions  dependency management with webpack
Improving build solutions dependency management with webpackNodeXperts
 
Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Bo-Yi Wu
 
0628阙宏宇
0628阙宏宇0628阙宏宇
0628阙宏宇zhu02
 
Decrease build time and application size
Decrease build time and application sizeDecrease build time and application size
Decrease build time and application sizeKeval Patel
 
Android tools for testers
Android tools for testersAndroid tools for testers
Android tools for testersMaksim Kovalev
 

Similar a Master your java_applications_in_kubernetes (20)

The JVM in the Cloud: OpenJ9 and the traditional HotSpot JVM
The JVM in the Cloud: OpenJ9 and the traditional HotSpot JVMThe JVM in the Cloud: OpenJ9 and the traditional HotSpot JVM
The JVM in the Cloud: OpenJ9 and the traditional HotSpot JVM
 
Using Docker For Development
Using Docker For DevelopmentUsing Docker For Development
Using Docker For Development
 
L0037 - Basic Eclipse Configuration
L0037 - Basic Eclipse ConfigurationL0037 - Basic Eclipse Configuration
L0037 - Basic Eclipse Configuration
 
Securing containers
Securing containersSecuring containers
Securing containers
 
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
 
It's always sunny with OpenJ9
It's always sunny with OpenJ9It's always sunny with OpenJ9
It's always sunny with OpenJ9
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 
DCSF19 Dockerfile Best Practices
DCSF19 Dockerfile Best PracticesDCSF19 Dockerfile Best Practices
DCSF19 Dockerfile Best Practices
 
[k8s] Kubernetes terminology (1).pdf
[k8s] Kubernetes terminology (1).pdf[k8s] Kubernetes terminology (1).pdf
[k8s] Kubernetes terminology (1).pdf
 
Securing Containers - Sathyajit Bhat - Adobe - Container Conference 18
Securing Containers - Sathyajit Bhat - Adobe - Container Conference 18Securing Containers - Sathyajit Bhat - Adobe - Container Conference 18
Securing Containers - Sathyajit Bhat - Adobe - Container Conference 18
 
Oracle goldengate and RAC12c
Oracle goldengate and RAC12cOracle goldengate and RAC12c
Oracle goldengate and RAC12c
 
Java and Container - Make it Awesome !
Java and Container - Make it Awesome !Java and Container - Make it Awesome !
Java and Container - Make it Awesome !
 
Integrating Apache Web Server with Tomcat Application Server
Integrating Apache Web Server with Tomcat Application ServerIntegrating Apache Web Server with Tomcat Application Server
Integrating Apache Web Server with Tomcat Application Server
 
Integrating Apache Web Server with Tomcat Application Server
Integrating Apache Web Server with Tomcat Application ServerIntegrating Apache Web Server with Tomcat Application Server
Integrating Apache Web Server with Tomcat Application Server
 
DCEU 18: Developing with Docker Containers
DCEU 18: Developing with Docker ContainersDCEU 18: Developing with Docker Containers
DCEU 18: Developing with Docker Containers
 
Improving build solutions dependency management with webpack
Improving build solutions  dependency management with webpackImproving build solutions  dependency management with webpack
Improving build solutions dependency management with webpack
 
Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署
 
0628阙宏宇
0628阙宏宇0628阙宏宇
0628阙宏宇
 
Decrease build time and application size
Decrease build time and application sizeDecrease build time and application size
Decrease build time and application size
 
Android tools for testers
Android tools for testersAndroid tools for testers
Android tools for testers
 

Más de Andy Moncsek

Going serverless with Fn project, Fn Flow and Kubernetes
Going serverless with Fn project, Fn Flow and KubernetesGoing serverless with Fn project, Fn Flow and Kubernetes
Going serverless with Fn project, Fn Flow and KubernetesAndy Moncsek
 
Vert.x based microservices with vxms
Vert.x based microservices with vxmsVert.x based microservices with vxms
Vert.x based microservices with vxmsAndy Moncsek
 
Event driven microservices with vxms, hazelcast and kubernetes - muenchen
Event driven microservices with vxms, hazelcast and kubernetes - muenchenEvent driven microservices with vxms, hazelcast and kubernetes - muenchen
Event driven microservices with vxms, hazelcast and kubernetes - muenchenAndy Moncsek
 
Event driven microservices with vertx and kubernetes
Event driven microservices with vertx and kubernetesEvent driven microservices with vertx and kubernetes
Event driven microservices with vertx and kubernetesAndy Moncsek
 
autodiscoverable microservices with vertx3
autodiscoverable microservices with vertx3autodiscoverable microservices with vertx3
autodiscoverable microservices with vertx3Andy Moncsek
 
Building non-blocking JavaFX 8 applications with JacpFX [CON1823]
Building non-blocking JavaFX 8 applications with JacpFX [CON1823]Building non-blocking JavaFX 8 applications with JacpFX [CON1823]
Building non-blocking JavaFX 8 applications with JacpFX [CON1823]Andy Moncsek
 
JavaFX / JacpFX interaction with JSR356 WebSockets
JavaFX / JacpFX interaction with JSR356 WebSocketsJavaFX / JacpFX interaction with JSR356 WebSockets
JavaFX / JacpFX interaction with JSR356 WebSocketsAndy Moncsek
 
Scalableenterpriseapplicationswith jee7andbeyond
Scalableenterpriseapplicationswith jee7andbeyondScalableenterpriseapplicationswith jee7andbeyond
Scalableenterpriseapplicationswith jee7andbeyondAndy Moncsek
 

Más de Andy Moncsek (8)

Going serverless with Fn project, Fn Flow and Kubernetes
Going serverless with Fn project, Fn Flow and KubernetesGoing serverless with Fn project, Fn Flow and Kubernetes
Going serverless with Fn project, Fn Flow and Kubernetes
 
Vert.x based microservices with vxms
Vert.x based microservices with vxmsVert.x based microservices with vxms
Vert.x based microservices with vxms
 
Event driven microservices with vxms, hazelcast and kubernetes - muenchen
Event driven microservices with vxms, hazelcast and kubernetes - muenchenEvent driven microservices with vxms, hazelcast and kubernetes - muenchen
Event driven microservices with vxms, hazelcast and kubernetes - muenchen
 
Event driven microservices with vertx and kubernetes
Event driven microservices with vertx and kubernetesEvent driven microservices with vertx and kubernetes
Event driven microservices with vertx and kubernetes
 
autodiscoverable microservices with vertx3
autodiscoverable microservices with vertx3autodiscoverable microservices with vertx3
autodiscoverable microservices with vertx3
 
Building non-blocking JavaFX 8 applications with JacpFX [CON1823]
Building non-blocking JavaFX 8 applications with JacpFX [CON1823]Building non-blocking JavaFX 8 applications with JacpFX [CON1823]
Building non-blocking JavaFX 8 applications with JacpFX [CON1823]
 
JavaFX / JacpFX interaction with JSR356 WebSockets
JavaFX / JacpFX interaction with JSR356 WebSocketsJavaFX / JacpFX interaction with JSR356 WebSockets
JavaFX / JacpFX interaction with JSR356 WebSockets
 
Scalableenterpriseapplicationswith jee7andbeyond
Scalableenterpriseapplicationswith jee7andbeyondScalableenterpriseapplicationswith jee7andbeyond
Scalableenterpriseapplicationswith jee7andbeyond
 

Último

TSM unit 5 Toxicokinetics seminar by Ansari Aashif Raza.pptx
TSM unit 5 Toxicokinetics seminar by  Ansari Aashif Raza.pptxTSM unit 5 Toxicokinetics seminar by  Ansari Aashif Raza.pptx
TSM unit 5 Toxicokinetics seminar by Ansari Aashif Raza.pptxAnsari Aashif Raza Mohd Imtiyaz
 
Microsoft Fabric Analytics Engineer (DP-600) Exam Dumps 2024.pdf
Microsoft Fabric Analytics Engineer (DP-600) Exam Dumps 2024.pdfMicrosoft Fabric Analytics Engineer (DP-600) Exam Dumps 2024.pdf
Microsoft Fabric Analytics Engineer (DP-600) Exam Dumps 2024.pdfSkillCertProExams
 
SaaStr Workshop Wednesday with CEO of Guru
SaaStr Workshop Wednesday with CEO of GuruSaaStr Workshop Wednesday with CEO of Guru
SaaStr Workshop Wednesday with CEO of Gurusaastr
 
2024 mega trends for the digital workplace - FINAL.pdf
2024 mega trends for the digital workplace - FINAL.pdf2024 mega trends for the digital workplace - FINAL.pdf
2024 mega trends for the digital workplace - FINAL.pdfNancy Goebel
 
2024-05-15-Surat Meetup-Hyperautomation.pptx
2024-05-15-Surat Meetup-Hyperautomation.pptx2024-05-15-Surat Meetup-Hyperautomation.pptx
2024-05-15-Surat Meetup-Hyperautomation.pptxnitishjain2015
 
DAY 0 8 A Revelation 05-19-2024 PPT.pptx
DAY 0 8 A Revelation 05-19-2024 PPT.pptxDAY 0 8 A Revelation 05-19-2024 PPT.pptx
DAY 0 8 A Revelation 05-19-2024 PPT.pptxFamilyWorshipCenterD
 
Understanding Poverty: A Community Questionnaire
Understanding Poverty: A Community QuestionnaireUnderstanding Poverty: A Community Questionnaire
Understanding Poverty: A Community Questionnairebazilnaeem7
 
ServiceNow CIS-Discovery Exam Dumps 2024
ServiceNow CIS-Discovery Exam Dumps 2024ServiceNow CIS-Discovery Exam Dumps 2024
ServiceNow CIS-Discovery Exam Dumps 2024SkillCertProExams
 
Databricks Machine Learning Associate Exam Dumps 2024.pdf
Databricks Machine Learning Associate Exam Dumps 2024.pdfDatabricks Machine Learning Associate Exam Dumps 2024.pdf
Databricks Machine Learning Associate Exam Dumps 2024.pdfSkillCertProExams
 
The Influence and Evolution of Mogul Press in Contemporary Public Relations.docx
The Influence and Evolution of Mogul Press in Contemporary Public Relations.docxThe Influence and Evolution of Mogul Press in Contemporary Public Relations.docx
The Influence and Evolution of Mogul Press in Contemporary Public Relations.docxMogul Press
 
The Concession of Asaba International Airport: Balancing Politics and Policy ...
The Concession of Asaba International Airport: Balancing Politics and Policy ...The Concession of Asaba International Airport: Balancing Politics and Policy ...
The Concession of Asaba International Airport: Balancing Politics and Policy ...Kayode Fayemi
 
ACM CHT Best Inspection Practices Kinben Innovation MIC Slideshare.pdf
ACM CHT Best Inspection Practices Kinben Innovation MIC Slideshare.pdfACM CHT Best Inspection Practices Kinben Innovation MIC Slideshare.pdf
ACM CHT Best Inspection Practices Kinben Innovation MIC Slideshare.pdfKinben Innovation Private Limited
 
STM valmiusseminaari 26-04-2024 PUUMALAINEN Ajankohtaista kansainvälisestä yh...
STM valmiusseminaari 26-04-2024 PUUMALAINEN Ajankohtaista kansainvälisestä yh...STM valmiusseminaari 26-04-2024 PUUMALAINEN Ajankohtaista kansainvälisestä yh...
STM valmiusseminaari 26-04-2024 PUUMALAINEN Ajankohtaista kansainvälisestä yh...Sosiaali- ja terveysministeriö / yleiset
 
Deciding The Topic of our Magazine.pptx.
Deciding The Topic of our Magazine.pptx.Deciding The Topic of our Magazine.pptx.
Deciding The Topic of our Magazine.pptx.bazilnaeem7
 

Último (14)

TSM unit 5 Toxicokinetics seminar by Ansari Aashif Raza.pptx
TSM unit 5 Toxicokinetics seminar by  Ansari Aashif Raza.pptxTSM unit 5 Toxicokinetics seminar by  Ansari Aashif Raza.pptx
TSM unit 5 Toxicokinetics seminar by Ansari Aashif Raza.pptx
 
Microsoft Fabric Analytics Engineer (DP-600) Exam Dumps 2024.pdf
Microsoft Fabric Analytics Engineer (DP-600) Exam Dumps 2024.pdfMicrosoft Fabric Analytics Engineer (DP-600) Exam Dumps 2024.pdf
Microsoft Fabric Analytics Engineer (DP-600) Exam Dumps 2024.pdf
 
SaaStr Workshop Wednesday with CEO of Guru
SaaStr Workshop Wednesday with CEO of GuruSaaStr Workshop Wednesday with CEO of Guru
SaaStr Workshop Wednesday with CEO of Guru
 
2024 mega trends for the digital workplace - FINAL.pdf
2024 mega trends for the digital workplace - FINAL.pdf2024 mega trends for the digital workplace - FINAL.pdf
2024 mega trends for the digital workplace - FINAL.pdf
 
2024-05-15-Surat Meetup-Hyperautomation.pptx
2024-05-15-Surat Meetup-Hyperautomation.pptx2024-05-15-Surat Meetup-Hyperautomation.pptx
2024-05-15-Surat Meetup-Hyperautomation.pptx
 
DAY 0 8 A Revelation 05-19-2024 PPT.pptx
DAY 0 8 A Revelation 05-19-2024 PPT.pptxDAY 0 8 A Revelation 05-19-2024 PPT.pptx
DAY 0 8 A Revelation 05-19-2024 PPT.pptx
 
Understanding Poverty: A Community Questionnaire
Understanding Poverty: A Community QuestionnaireUnderstanding Poverty: A Community Questionnaire
Understanding Poverty: A Community Questionnaire
 
ServiceNow CIS-Discovery Exam Dumps 2024
ServiceNow CIS-Discovery Exam Dumps 2024ServiceNow CIS-Discovery Exam Dumps 2024
ServiceNow CIS-Discovery Exam Dumps 2024
 
Databricks Machine Learning Associate Exam Dumps 2024.pdf
Databricks Machine Learning Associate Exam Dumps 2024.pdfDatabricks Machine Learning Associate Exam Dumps 2024.pdf
Databricks Machine Learning Associate Exam Dumps 2024.pdf
 
The Influence and Evolution of Mogul Press in Contemporary Public Relations.docx
The Influence and Evolution of Mogul Press in Contemporary Public Relations.docxThe Influence and Evolution of Mogul Press in Contemporary Public Relations.docx
The Influence and Evolution of Mogul Press in Contemporary Public Relations.docx
 
The Concession of Asaba International Airport: Balancing Politics and Policy ...
The Concession of Asaba International Airport: Balancing Politics and Policy ...The Concession of Asaba International Airport: Balancing Politics and Policy ...
The Concession of Asaba International Airport: Balancing Politics and Policy ...
 
ACM CHT Best Inspection Practices Kinben Innovation MIC Slideshare.pdf
ACM CHT Best Inspection Practices Kinben Innovation MIC Slideshare.pdfACM CHT Best Inspection Practices Kinben Innovation MIC Slideshare.pdf
ACM CHT Best Inspection Practices Kinben Innovation MIC Slideshare.pdf
 
STM valmiusseminaari 26-04-2024 PUUMALAINEN Ajankohtaista kansainvälisestä yh...
STM valmiusseminaari 26-04-2024 PUUMALAINEN Ajankohtaista kansainvälisestä yh...STM valmiusseminaari 26-04-2024 PUUMALAINEN Ajankohtaista kansainvälisestä yh...
STM valmiusseminaari 26-04-2024 PUUMALAINEN Ajankohtaista kansainvälisestä yh...
 
Deciding The Topic of our Magazine.pptx.
Deciding The Topic of our Magazine.pptx.Deciding The Topic of our Magazine.pptx.
Deciding The Topic of our Magazine.pptx.
 

Master your java_applications_in_kubernetes

  • 1. Ó Adcubum AG 1 Master your Java applications in Kubernetes Andy Moncsek 03.2019
  • 2. Ó Adcubum AG 2 § Andy Moncsek à Architect § Creator or… see my Github § Likes coffee & HiFi & cameras § Twitter: @AndyAHCP About me
  • 3. Ó Adcubum AG 3 Agenda § Choose your (Java) Runtime § Build & execute your applications § Create your image § Run your applications in Kubernetes § Final thoughts
  • 4. Ó Adcubum AG 4 § How to integrate? You plan to move to Kubernetes? Typical issues § Slow startup? § No more capacity?
  • 5. Ó Adcubum AG 5 Choose your (Java) Runtime
  • 6. Ó Adcubum AG 6 § Support? § License & LTS? § Container aware? § since Java SE 8u131 & JDK 9 § changes in JDK 8u191 & JDK 10 Choose your (Java) Runtime
  • 7. Ó Adcubum AG 7 Hotspot + C1 & C2 Jit Choose your (Java) Runtime Many (possible) options, out there + Substrate VM Hotspot +
  • 8. Ó Adcubum AG 8 § Contributed by IBM to the Eclipse Foundation in 2017 § It replaces HotSpot JVM in the OpenJDK build § Small memory footprint & fast startup § Optimization for virtualized environments Choose your (Java) Runtime OpenJ9
  • 9. Ó Adcubum AG 9 § Universal VM running various languages § Removes isolation & enables interoperability between programming languages § Can be integrated in various native & managed env. (OpenJDK, Node.js, OracleDB, MySQL,…) Choose your (Java) Runtime GraalVM § The Graal compiler § as JIT compiler since Java 10 § as AOT compiler since Java 9
  • 10. Ó Adcubum AG 10 Choose your (Java) Runtime Relation to Containers / Kubernetes? § JVM needs to be aware of containers (CPU & memory) § Small memory/image footprint (run & deploy many containers) § Fast startup time (auto scaler, elastic)
  • 11. Ó Adcubum AG 11 Build & execute your application
  • 12. Ó Adcubum AG 12 § -XX:[+|-]UseContainerSupport § Correct CPU count & total memory allocated to the container § -XX:InitialRAMPercentage § Set initial heap size as a percentage of total memory (-Xms) § -XX:MaxRAMPercentage & -XX:MinRAMPercentage § used to calculate maximum heap size (-Xmx) Build & execute your application “Basic” container specific flags phys_mem * MinRAMPercentage / 100 (if this value is less than 96M) MAX(phys_mem * MaxRAMPercentage / 100, 96M)
  • 13. Ó Adcubum AG 13 § -Xtune:virtualized § Tuning for containers § Reduction in footprint & startup time (but also in throughput) § Enables VM idle management § -Xquickstart § Designed for the fastest start-up § Ideal for short-lived tasks § May limit peak throughput Build & execute your application OpenJ9 specific container flags
  • 14. Ó Adcubum AG 14 § AOT compilation (since JDK9 / JEP 295) § Transforms Java bytecode to OS-specific machine code § Performs simple optimizations of Java bytecode § AOT vs. JIT compiled (rule of thumb) § Pro: better startup time § Cons: worse performance of long-running applications Build & execute your application Ahead-of-time (AOT) > jaotc --output app.so --jar microservice.jar --module jdk.httpserver --module java.base > java -XX:AOTLibrary=./app.so -jar microservice.jar
  • 15. Ó Adcubum AG 15 § Since JDK10 (JEP310) § Sharing of classes loaded by the application class loader § Still some limitations (since Java 11 support for module path) § Flag UseAppCDS (introduced in Java 10) removed in Java12 § Automatically enabled in Java 12 § Reduce memory footprint/startup time § Needs two preparation steps Build & execute your application AppCDS Heap Objects Shared String O. Shared Classes Class Metadata JVM 1 Heap Objects Shared String O. Shared Classes Class Metadata JVM 2 Archive File
  • 16. Ó Adcubum AG 16 Build & execute your application AppCDS Usage à DEMO // step1: run the app & record all classes java -XX:+UseAppCDS -XX:DumpLoadedClassList=classes.lst –jar app.jar // step 2: create an archive java -XX:+UseAppCDS -Xshare:dump -XX:SharedClassListFile=classes.lst -XX:SharedArchiveFile=cds.jsa --class-path app.jar // step 3: start/use your application java -XX:+UseAppCDS -Xshare:on -XX:SharedArchiveFile=cds.jsa –jar app.jar
  • 17. Ó Adcubum AG 17 § Enable class data sharing à AOT compilation is also enabled by default § dynamically compiles certain methods into AOT code at runtime § applicable to boot, extension, & application loaders & all URLClassloader-subclasses § -Xshareclasses option to enable class sharing & AOT § -Xshareclasses:cacheDir=/opt/shareclasses Build & execute your application CDS & AOT in OpenJ9 JVM 1 JVM 2 JVM 3 Shared classes cache
  • 18. Ó Adcubum AG 18 § Native compilation (in a nutshell) § Based on Graal compiler & SubstrateVM § Still many limitations (class loading, reflection,… ) § How to use § Download GraalVM & Build your (fat) jar § native-image –jar app.jar && ./app § Working frameworks? § Micronaut, Spark Java, Vert.x Build & execute your application Native compilation
  • 19. Ó Adcubum AG 19 Build & execute your application Some benchmarks ;-) from October 2018 / Java 10 https://www.slideshare.net/trivadis/techevent-graalvm-performance-interoperability Always do you own tests!
  • 20. Ó Adcubum AG 20 Create your images
  • 21. Ó Adcubum AG 21 § Shrink your image to a minimum § Works also with non-modular Java applications (like spring-boot) Create your image Usage of modular run-time images & multi-stage builds FROM openjdk:12-ea-jdk-alpine3.8 as builder RUN jlink // works for spring-boot --add-modules java.sql, java.naming, java.net.http, java.management, java.instrument,java.security.jgss,java.desktop,jdk.unsupported --verbose --strip-debug --compress 2 --no-header-files --no-man-pages --output /opt/jre-minimal FROM alpine:3.8 COPY --from=builder /opt/jre-minimal /opt/jre-minimal PATH=${PATH}:/opt/jre-minimal/bin . . . CMD
  • 22. Ó Adcubum AG 22 § Use multistage builds, if needed § Split up layers, based on their potential for reuse § Put any components that will update very rarely at the top of the Dockerfile § Merge commands together, because each RUN line adds a layer to the image § Advantage: faster builds, less storage, pull faster Create your image Create lean images # Do RUN apt-get update && apt-get install package-bar # Don’t RUN apt-get update RUN apt-get install package-bar
  • 23. Ó Adcubum AG 23 Create your image Create lean images FROM adoptopenjdk/openjdk11-openj9:alpine-slim RUN mkdir -p /usr/src/app && mkdir -p /usr/src/app/config ARG APPLICATION=target/application COPY ${APPLICATION}/BOOT-INF/lib /app/lib COPY ${APPLICATION}/META-INF /app/META-INF COPY ${APPLICATION}/BOOT-INF/classes /app ENTRYPOINT ["java","-cp","app:app/lib/*:/usr/src/app/config",»com.*.KafkaAdapterMain"] (reuse) dependencies
  • 24. Ó Adcubum AG 24 § Try to avoid “fat” jars & wars § Use skinny / thin § Different approaches for: § Tomcat, Open Liberty, WildFly, Spring § Spring § Maven dependency plugin § Open Liberty boost plugin § spring-boot-thin-launcher Create your image Think about your layers https://openliberty.io/blog/2018/07/02/creating-dual-layer-docker-images-for-spring-boot-apps.html
  • 25. Ó Adcubum AG 25 Be frugal Choose your image Image type Red Hat Enterprise 7 Standard Red Hat Enterprise Atomic Debian Stable Alpine C Library glibc glibc glibc musel c Size on Disk 200MB 78MB 100MB 4MB § Look for vendor-specific (or official) images § Don’t use :latest or no tag! § Do you really need an application server?
  • 26. Ó Adcubum AG 26 Run your application (in Kubernetes)
  • 27. Ó Adcubum AG 27 Run your application Share your CDS files in Kubernetes apiVersion: v1 kind: Pod metadata: name: myApp spec: containers: - image: myApp name: myApp volumeMounts: - mountPath: /cdscache name: cdscache volumes: - name: cdscache hostPath: path: /cdscache #location on host type: Directory CMD java -jar -Xshareclasses:cacheDir=/cdscache app.jar
  • 28. Ó Adcubum AG 28 § Each Container has a request of 0.25 cpu and 64MB of memory. § Each Container has a limit of 0.5 cpu and 128MB of memory. Run your application Use resource request and limits kind: Pod metadata: name: frontend spec: containers: - name: wp image: wordpress resources: requests: memory: "64M" cpu: "250m" limits: memory: "128M" cpu: "500m" ....
  • 29. Ó Adcubum AG 29 § Apply quotas on Namespace level § Constraints on number of objects, cpu & memory § When enabled, resource limits must be set Run your application Quotas kind: ResourceQuota metadata: name: quota spec: hard: cpu: "2" memory: 1G pods: "10" replicationcontrollers: " 5" resourcequotas: "1" services: "5"
  • 30. Ó Adcubum AG 30 Run your application ConfigMaps & Secrets to externalize your configuration kind: ConfigMap metadata: name: spring-prop data: application.yml: | server: port: 8080 kind: Pod spec: volumes: - name: config configMap: name: spring-prop items: - key: application.yml path: application-kube.yml containers: - volumeMounts: - name: config mountPath: /usr/src/app/config
  • 32. Ó Adcubum AG 32 § Avoid infrastructure code in your applications § Service mesh with circuit breaker § Service Discovery (using DNS or Labels in Kubernetes) § Configuration via ConfigMap § Helm Charts to ship your application § Package manager like “apt” in Debian § Kubernetes Operators helps you to manage upgrades, lifecycle & insights Be inventive Final thoughts
  • 33. Ó Adcubum AG 33 § Don’t overlook Serverless!! § Better utilization of your cluster § Many measured run-times (AWS, Serverless,..) § Knative pushed to Kubernetes (by Google & Pivotal) § GraalVM and other projects focusing low footprint & fast startup Be inventive Final thoughts
  • 34. Ó Adcubum AG 34 § Why you should optimize your applications for containers & cloud? § Costs!!!!! à smaller footprint, CPU cycles, pay-per-use § The application life cycle has changed § no longer dominated by uptime § startup is now critical to your application § Expect to spend more and more time looking at resource usage, performance and footprint. Be inventive Final thoughts
  • 35. Ó Adcubum AG 35 Any questions?
  • 36. Ó Adcubum AG 36 § https://github.com/amoAHCP/JavaContainerTests § https://www.slideshare.net/DanHeidinga/j9-under-the-hood-of-the-next-open-source-jvm § https://github.com/eclipse/openj9-website/blob/master/benchmark/daytrader3.md § https://static.rainfocus.com/oracle/oow18/sess/1525896302003001DAHT/PF/CodeOne_2018_hw_154082375281200 1Nmsq.pdf § https://hub.docker.com/r/adoptopenjdk/openjdk10-openj9 § https://www.eclipse.org/openj9/docs/xshareclasses/ Links