SlideShare une entreprise Scribd logo
1  sur  30
Télécharger pour lire hors ligne
© 2018 Software AG. All rights reserved.
Anthony Dahanne
@anthonydahanne
blog.dahanne.net
October 23rd 2018
[TUT5930]
KUBERNETES
FOR JAVA DEVELOPERS
LET ME INTRODUCE MYSELF
„Anthony Dahanne, Software Engineer
@Terracotta, a Software AG company
„Working on Terracotta cloud deployments
(Docker, Kubernetes, AWS, etc.)
„Also working on Management and Monitoring for
Terracotta products
„Montréal JUG leader
AGENDA
• Containers & the JVM
• Kubernetes 101
• Tools to become a 100x developer with Kubernetes
• Integrating with Kubernetes
CONTAINERS IN ONE SLIDE
• Containers all use host OS kernel
• Host OS can be running in a VM or barebone
• Host OS Linux distribution does not matter
• only the kernel does !
• Isolation performed with chroot, namespaces, cgroups
• namespaces : limit what you can see
• pid, net, mnt, uts, ipc, user
• cgroups : limit what you can use
• memory, CPU, block IO, network (with iptables)
THAT’S JUST AN ISOLATED PROCESS !
https://www.slideshare.net/jpetazzo/anatomy-of-a-container-namespaces-cgroups-some-filesystem-magic-linuxcon
https://www.enterprisetech.com/2014/08/18/ibm-techies-pit-docker-kvm-bare-metal/
JAVA AND LINUX CONTAINERS
• The JVM “guesses” available CPU and Memory resources available on the host
• By default, uses 1/4 of the available memory
• Although it can be set manually
• -XX:ParallelGCThreads,-XX:CICompilerCount,-Xmx
• Since Java SE 8u131, the JVM
• is “Docker aware with respect to Docker CPU limits transparently”
• has new options for detecting memory limits (not transparent, yet)
• -XX:+UnlockExperimentalVMOptions
• -XX:+UseCGroupMemoryLimitForHeap
BEWARE WHAT THE JVM CAN SEE ! (AND USE !)
Since Java 10
(backported to Java 8u191 !)
the JVM properly (without -XX)
detects CPU and Memory limits
https://blog.docker.com/2018/04/improved-docker-container-integration-with-java-10/
Container, exposing 8080
JVM based webapp, 8080
H2 (in memory db)
Ehcache (local caching)
REST API
Angular 2 UI
BASED ON JHIPSTER / SPRING BOOT 2
DOCKERIZING THE DEMO APP
WE ALL KNOW DOCKER, BUT…
IS IT THE ONLY OPTION TO BUILD IMAGES AND RUN CONTAINERS ?
FROM openjdk
EXPOSE 8080
ADD app.jar /app.jar
CMD java - jar /app.jar
Linux Container
Docker / OCI Image
Data & Metadata
runbuild
WE ALL KNOW DOCKER, BUT…
WHAT ARE THE CONTENDERS ?
• cri-o
• rkt
(Daemonless) BUILD RUN*
Supports Dockerfile ?
IMG Yes
Buildah Yes
Bazel No (has builder for java)
Buildpack No (has builder for java)
Jib No (java native builder)
And others local (Draft), and cloud builders : DockerHub, Google Cloud Builder, etc.
*: that includes registry and storage access
KUBERNETES 101
A CONTAINER ORCHESTRATOR
KUBERNETES INTRODUCTION
• Initial release June 7th 2014
• Apache 2 License, written in Go
• heavily inspired by Borg, internal system from Google
• Currently 1.12 (a new release every 3 months on average)
• Under the umbrella of the Cloud Native Computing Foundation
• that includes Oracle, Intel, IBM, Pivotal, Redhat, etc.
• along with Prometheus, Helm, OpenTracing, containerd, CNI, Buildpacks, etc.
FROM BORG TO CNCF
https://l.cncf.io
KUBERNETES ARCHITECTURE
By Khtan66 - CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=53571935
MASTER NODES, WORKER NODES, SOME NETWORKING…
Deployment (Declarative Updates)
> kubectl set image deployment/tmc-deployment tmc=tmc:10.3
> kubectl rollout status deployment/tmc-deployment
Replica Set (Match and Scale definitions)
spec:
replicas: 3
selector:
matchLabels:
tier: tmc
KUBERNETES WORKLOADS (PODS AND CONTROLLERS)
DEPLOYMENT > REPLICA SET > POD > CONTAINER
Pod
spec:
containers:
- name: tmc
image: store/softwareag/tmc:10.2
command: [‘start.sh’]
- name: helper-container
image: busybox
command: ['sh', '-c', 'ping tmc’]
volumes: (secrets, configmaps, etc.)
hostname: terracotta
+ Jobs, StatefulSets, Daemon sets, etc.
metadata:
labels:
tier: tmc
KUBERNETES SERVICES (L4)
• ClusterIP (default)
• Exposes the service on a cluster-internal IP
• NodePort
• Exposes the service on a port on each node’s IP
• LoadBalancer
• Exposes the service externally,
• using the cluster provided load balancer
HOW DO YOU EXPOSE YOUR WORKLOADS
“A Kubernetes Service is an abstraction which defines a logical set of Pods and a policy by which to access them”
https://kubernetes.io/docs/concepts/services-networking/service/
Node A
Pod-1
labels
tier:frontend
Service
spec:
type: LoadBalancer
ports:
-port:80
selector:
tier:frontend
in | outside
NodeB
Pod-2
labels
tier:frontend
KUBERNETES VOLUMES, CONFIG MAPS AND SECRETS
• Many types of volumes are available : hostPath, nfs, cloud specific, etc.
• ConfigMaps and Secrets are stored on the Kubernetes key/value store
YOU CAN MOUNT THEM ALL !
Pod
apiVersion: v1
kind: Pod
spec:
containers:
- name: terracotta-server
image: store/softwareag/terracotta-server:10.2
volumeMounts:
- name: config-volume
mountPath: /config
- name: data
mountPath: /data
volumes:
- name: config-volume
configMap:
name: tc-config
- name: data
hostPath:
		path:	/usr	
ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
name: tc-config
data:
tc-config.xml: |
<xml></xml>
KUBERNETES DEPLOYMENTS
• Cloud providers
• Google Cloud with GKE
• Microsoft Azure with AKS
• Amazon with Kops and now EKS
• Oracle Cloud with OKE
• Exoscale, Digital Ocean,OVH, etc.
• Playgrounds : Katacoda and Play with
Kubernetes
CLOUD, ON-PREMISE, LOCAL
• On-premise
• Hard way
• Kubeadm
• Local
• Minikube
• Minishift
• Docker for Mac (more on this one later)
Kubernetes Cluster
n
Terracotta Server
Terracotta Server…
Demo app
MySQL
DEPLOYING THE DEMO APP TO KUBERNETES
KUBERNETES PACKAGING : HELM
• Helm is installed on the client, Tiller is the server side
• With Helm you deploy / create Charts that are run as Releases
• In a Chart, you package your Kubernetes manifests, and your dependencies
• A very notable feature is the “templatization“ of your Kubernetes manifests
APT / YUM FOR KUBERNETES
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ template "terracotta.fullname" . }}
labels:
app: {{ template "terracotta.name" . }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "terracotta.name" . }}
serviceName: {{ template "terracotta.fullname" . }}
spec:
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
containers:
- name: {{ template "terracotta.fullname" . }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}”
TOOLS TO BECOME A 100X DEVELOPER
WITH KUBERNETES
CLASSIC DOCKER AND KUBERNETES TOOLING
• IDE plugins
• auto completion for Dockerfile, Kubernetes and Helm! (IntelliJ 2018.3)
• To build and deploy images from the IDE
• Build tools (Maven / Gradle) Docker integration
• Maven Docker plugin, Jib
• Docker for Mac / Win 10
•latest stable comes with K8s support
• Minikube
KUBERNETES TOOLING : SKAFFOLD
• Skaffold goal is to auto re-deploy on change
• A month ago jib integration was added
• A Kubernetes manifest, a skaffold config file and skaffold dev
• watches your source files
• rebuilds them (output is a Docker image) on change
• (re) deploys your app to Kubernetes
MAGICALLY AUTO REDEPLOYS ON CHANGE
apiVersion: skaffold/v1alpha4
kind: Config
build:
artifacts:
- image: anthonydahanne/fullstack
context: .
jibMaven:
profile: "dev,skipTestsAndYarn"
KUBERNETES TOOLING : TELEPRESENCE
• Telepresence goal is to allow local processes to be available in a remote
Kubernetes cluster
• A process running on your laptop can access (remote) Kubernetes resources
• It can also be seen by them
• Most common use case is to replace an existing pod with the telepresence pod
that proxies both ways to your local process
MAGICALLY DEPLOY LOCAL PROCESSES INTO THE K8S CLUSTER
>	telepresence		
				--swap-deployment	fullstack		
				--expose	8080:80	
				--run	java	-jar	target/demo-1.0.0-SNAPSHOT.war
INTEGRATION WITH KUBERNETES
MONITORING WITH PROMETHEUS
• CNCF graduated / is the basis for an open monitoring format
• By default pull metrics from apps; but a Node exporter supports push
• Extremely simple to configure for Kubernetes workloads :
• Dropwizard metrics, micrometer, etc. provide Prometheus integration for Java
MONITORING SYSTEM AND TIME SERIES DATABASE
kind: Service
metadata:
annotations:
prometheus.io/scrape: 'true'
prometheus.io/path: '/prometheusMetrics'
MONITORING WITH PROMETHEUS
GENERAL ARCHITECTURE
https://winderresearch.com/introduction-to-monitoring-microservices-with-prometheus/
KUBERNETES OPERATOR IN JAVA
• Operators (or controllers) provide better user experience for deploying and
managing complex applications like databases (PostgreSQL, Terracotta server, etc.)
• They can create and manage their own Custom Resource Definitions (CRDs)
- or provide a CLI or UI via their own REST endpoints
USING FABRIC8 OR KUBERNETES JAVA SDK
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client</artifactId>
<version>4.0.3</version>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java</artifactId>
<version>3.0.0-beta2</version>
</dependency>
Service tmcService = new ServiceBuilder()
.withNewMetadata()
.withName("tmc")
.endMetadata()
.withNewSpec()
.addNewPort()
.withName("tmc-port")
.withPort(9480)
.endPort()
.withType("LoadBalancer")
.addToSelector("app", "tmc")
.endSpec()
.build();
TERRACOTTA OPERATOR ARCHITECTURE
Kubernetes Cluster
Terracotta Operator
REST API
CLI / Web UI
K8S API Server
Java SDK
REST calls
license
tc-configs
operator config
Terracotta
ServerTerracotta
Server
TMC
ConfigMaps
Services,
StatefulSets
A PRIVILEGED POD THAT LISTENS TO THE USER
TERRACOTTA OPERATOR ARCHITECTURE
Kubernetes Cluster
Terracotta Operator
kubectl apply
K8S API Server
Java SDK
Watch
license
tc-configs
operator config
Terracotta
ServerTerracotta
Server
TMC
ConfigMaps
Services,
StatefulSets
A PRIVILEGED POD THAT LISTENS TO THE API SERVER
THE END ! OR JUST THE BEGINNING ?
RBAC
Service Mesh
Ingress controller
…
LINKS AND OTHER REFERENCES
• Containers from scratch, talk by Liz Rice
• Jib presentation, talk by Qingyang Chen and Appu Goundan
• The fullstack demo app (and its jib, kubernetes, helm, scaffold files) is on Github
© 2017 Software AG. All rights reserved. For internal use only
Coming up next !

Contenu connexe

Tendances

Tendances (20)

Kubernetes Ingress 101
Kubernetes Ingress 101Kubernetes Ingress 101
Kubernetes Ingress 101
 
K8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingK8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals Training
 
Kubernetes Overview - Deploy your app with confidence
Kubernetes Overview - Deploy your app with confidenceKubernetes Overview - Deploy your app with confidence
Kubernetes Overview - Deploy your app with confidence
 
Kubecon seattle 2018 recap - Application Deployment aspects
Kubecon seattle 2018 recap - Application Deployment aspectsKubecon seattle 2018 recap - Application Deployment aspects
Kubecon seattle 2018 recap - Application Deployment aspects
 
What's new in Docker - InfraKit - Docker Meetup Berlin 2016
What's new in Docker - InfraKit - Docker Meetup Berlin 2016What's new in Docker - InfraKit - Docker Meetup Berlin 2016
What's new in Docker - InfraKit - Docker Meetup Berlin 2016
 
Cloudfoundry Overview
Cloudfoundry OverviewCloudfoundry Overview
Cloudfoundry Overview
 
Docker SF Meetup January 2016
Docker SF Meetup January 2016Docker SF Meetup January 2016
Docker SF Meetup January 2016
 
Kubernetes for the PHP developer
Kubernetes for the PHP developerKubernetes for the PHP developer
Kubernetes for the PHP developer
 
Docker Distributed application bundle & Stack - Overview
Docker Distributed application bundle & Stack - Overview Docker Distributed application bundle & Stack - Overview
Docker Distributed application bundle & Stack - Overview
 
Docker HK Meetup - 201707
Docker HK Meetup - 201707Docker HK Meetup - 201707
Docker HK Meetup - 201707
 
SCALE 2011 Deploying OpenStack with Chef
SCALE 2011 Deploying OpenStack with ChefSCALE 2011 Deploying OpenStack with Chef
SCALE 2011 Deploying OpenStack with Chef
 
OSDC 2018 | Spicing up VMWare with Ansible and InSpec by Martin Schurz and S...
OSDC 2018 | Spicing up VMWare with Ansible and InSpec by Martin Schurz and  S...OSDC 2018 | Spicing up VMWare with Ansible and InSpec by Martin Schurz and  S...
OSDC 2018 | Spicing up VMWare with Ansible and InSpec by Martin Schurz and S...
 
Kubernetes: My BFF
Kubernetes: My BFFKubernetes: My BFF
Kubernetes: My BFF
 
Containers in depth – Understanding how containers work to better work with c...
Containers in depth – Understanding how containers work to better work with c...Containers in depth – Understanding how containers work to better work with c...
Containers in depth – Understanding how containers work to better work with c...
 
Introduction to Kubernetes
Introduction to KubernetesIntroduction to Kubernetes
Introduction to Kubernetes
 
Devoxx 2016 - Docker Nuts and Bolts
Devoxx 2016 - Docker Nuts and BoltsDevoxx 2016 - Docker Nuts and Bolts
Devoxx 2016 - Docker Nuts and Bolts
 
virtualization-vs-containerization-paas
virtualization-vs-containerization-paasvirtualization-vs-containerization-paas
virtualization-vs-containerization-paas
 
Webinar container management in OpenStack
Webinar container management in OpenStackWebinar container management in OpenStack
Webinar container management in OpenStack
 
Red Hat Forum Benelux 2015
Red Hat Forum Benelux 2015Red Hat Forum Benelux 2015
Red Hat Forum Benelux 2015
 
Containers and Kubernetes -Notes Leo
Containers and Kubernetes -Notes LeoContainers and Kubernetes -Notes Leo
Containers and Kubernetes -Notes Leo
 

Similaire à Kubernetes for java developers - Tutorial at Oracle Code One 2018

Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
QAware GmbH
 

Similaire à Kubernetes for java developers - Tutorial at Oracle Code One 2018 (20)

Kubernetes for Java Developers
Kubernetes for Java DevelopersKubernetes for Java Developers
Kubernetes for Java Developers
 
Kubernetes #1 intro
Kubernetes #1   introKubernetes #1   intro
Kubernetes #1 intro
 
Docker and kubernetes
Docker and kubernetesDocker and kubernetes
Docker and kubernetes
 
What's New in Docker - February 2017
What's New in Docker - February 2017What's New in Docker - February 2017
What's New in Docker - February 2017
 
Dessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloudDessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloud
 
Come costruire una Platform As A Service con Docker, Kubernetes Go e Java
Come costruire una Platform As A Service con Docker, Kubernetes Go e JavaCome costruire una Platform As A Service con Docker, Kubernetes Go e Java
Come costruire una Platform As A Service con Docker, Kubernetes Go e Java
 
Docker Enterprise Workshop - Technical
Docker Enterprise Workshop - TechnicalDocker Enterprise Workshop - Technical
Docker Enterprise Workshop - Technical
 
Cloud-native .NET Microservices mit Kubernetes
Cloud-native .NET Microservices mit KubernetesCloud-native .NET Microservices mit Kubernetes
Cloud-native .NET Microservices mit Kubernetes
 
ОЛЕГ МАЦЬКІВ «Crash course on Operator Framework» Lviv DevOps Conference 2019
ОЛЕГ МАЦЬКІВ «Crash course on Operator Framework» Lviv DevOps Conference 2019ОЛЕГ МАЦЬКІВ «Crash course on Operator Framework» Lviv DevOps Conference 2019
ОЛЕГ МАЦЬКІВ «Crash course on Operator Framework» Lviv DevOps Conference 2019
 
Pro2516 10 things about oracle and k8s.pptx-final
Pro2516   10 things about oracle and k8s.pptx-finalPro2516   10 things about oracle and k8s.pptx-final
Pro2516 10 things about oracle and k8s.pptx-final
 
Kubernetes extensibility
Kubernetes extensibilityKubernetes extensibility
Kubernetes extensibility
 
A Hitchhiker’s Guide to the Cloud Native Stack. #CDS17
A Hitchhiker’s Guide to the Cloud Native Stack. #CDS17A Hitchhiker’s Guide to the Cloud Native Stack. #CDS17
A Hitchhiker’s Guide to the Cloud Native Stack. #CDS17
 
A hitchhiker‘s guide to the cloud native stack
A hitchhiker‘s guide to the cloud native stackA hitchhiker‘s guide to the cloud native stack
A hitchhiker‘s guide to the cloud native stack
 
01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware
01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware
01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware
 
Docker kubernetes fundamental(pod_service)_190307
Docker kubernetes fundamental(pod_service)_190307Docker kubernetes fundamental(pod_service)_190307
Docker kubernetes fundamental(pod_service)_190307
 
Kubernetes - how to orchestrate containers
Kubernetes - how to orchestrate containersKubernetes - how to orchestrate containers
Kubernetes - how to orchestrate containers
 
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
 
OSDC 2018 | Three years running containers with Kubernetes in Production by T...
OSDC 2018 | Three years running containers with Kubernetes in Production by T...OSDC 2018 | Three years running containers with Kubernetes in Production by T...
OSDC 2018 | Three years running containers with Kubernetes in Production by T...
 
Continuous Deployment with Akka.Cluster and Kubernetes (Akka.NET)
Continuous Deployment with Akka.Cluster and Kubernetes (Akka.NET)Continuous Deployment with Akka.Cluster and Kubernetes (Akka.NET)
Continuous Deployment with Akka.Cluster and Kubernetes (Akka.NET)
 
Why kubernetes for Serverless (FaaS)
Why kubernetes for Serverless (FaaS)Why kubernetes for Serverless (FaaS)
Why kubernetes for Serverless (FaaS)
 

Plus de Anthony Dahanne

Confoo2013 make your java-app rest enabled
Confoo2013 make your java-app rest enabledConfoo2013 make your java-app rest enabled
Confoo2013 make your java-app rest enabled
Anthony Dahanne
 

Plus de Anthony Dahanne (15)

Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024
 
No more Dockerfiles? Buildpacks to help you ship your image!
No more Dockerfiles? Buildpacks to help you ship your image!No more Dockerfiles? Buildpacks to help you ship your image!
No more Dockerfiles? Buildpacks to help you ship your image!
 
CNCF Québec Meetup du 16 Novembre 2023
CNCF Québec Meetup du 16 Novembre 2023CNCF Québec Meetup du 16 Novembre 2023
CNCF Québec Meetup du 16 Novembre 2023
 
Buildpacks: the other way to build container images
Buildpacks: the other way to build container imagesBuildpacks: the other way to build container images
Buildpacks: the other way to build container images
 
Tu changes d'emploi - retour d'experience d'un développeur
Tu changes d'emploi - retour d'experience d'un développeurTu changes d'emploi - retour d'experience d'un développeur
Tu changes d'emploi - retour d'experience d'un développeur
 
Java applications containerized and deployed
Java applications containerized and deployedJava applications containerized and deployed
Java applications containerized and deployed
 
Contribuer à la traduction française de kubernetes
Contribuer à la traduction française de kubernetesContribuer à la traduction française de kubernetes
Contribuer à la traduction française de kubernetes
 
Caching in applications still matters
Caching in applications still mattersCaching in applications still matters
Caching in applications still matters
 
Docker and java
Docker and javaDocker and java
Docker and java
 
Terracotta Ehcache : Simpler, faster, distributed
Terracotta Ehcache : Simpler, faster, distributedTerracotta Ehcache : Simpler, faster, distributed
Terracotta Ehcache : Simpler, faster, distributed
 
Docker and java, at Montréal JUG
Docker and java, at Montréal JUGDocker and java, at Montréal JUG
Docker and java, at Montréal JUG
 
Writing a Jenkins / Hudson plugin
Writing a Jenkins / Hudson pluginWriting a Jenkins / Hudson plugin
Writing a Jenkins / Hudson plugin
 
Confoo2013 make your java-app rest enabled
Confoo2013 make your java-app rest enabledConfoo2013 make your java-app rest enabled
Confoo2013 make your java-app rest enabled
 
Ci for-android-apps
Ci for-android-appsCi for-android-apps
Ci for-android-apps
 
Asynctasks
AsynctasksAsynctasks
Asynctasks
 

Dernier

Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Dernier (20)

WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 

Kubernetes for java developers - Tutorial at Oracle Code One 2018

  • 1. © 2018 Software AG. All rights reserved. Anthony Dahanne @anthonydahanne blog.dahanne.net October 23rd 2018 [TUT5930] KUBERNETES FOR JAVA DEVELOPERS
  • 2. LET ME INTRODUCE MYSELF „Anthony Dahanne, Software Engineer @Terracotta, a Software AG company „Working on Terracotta cloud deployments (Docker, Kubernetes, AWS, etc.) „Also working on Management and Monitoring for Terracotta products „Montréal JUG leader
  • 3. AGENDA • Containers & the JVM • Kubernetes 101 • Tools to become a 100x developer with Kubernetes • Integrating with Kubernetes
  • 4. CONTAINERS IN ONE SLIDE • Containers all use host OS kernel • Host OS can be running in a VM or barebone • Host OS Linux distribution does not matter • only the kernel does ! • Isolation performed with chroot, namespaces, cgroups • namespaces : limit what you can see • pid, net, mnt, uts, ipc, user • cgroups : limit what you can use • memory, CPU, block IO, network (with iptables) THAT’S JUST AN ISOLATED PROCESS ! https://www.slideshare.net/jpetazzo/anatomy-of-a-container-namespaces-cgroups-some-filesystem-magic-linuxcon https://www.enterprisetech.com/2014/08/18/ibm-techies-pit-docker-kvm-bare-metal/
  • 5. JAVA AND LINUX CONTAINERS • The JVM “guesses” available CPU and Memory resources available on the host • By default, uses 1/4 of the available memory • Although it can be set manually • -XX:ParallelGCThreads,-XX:CICompilerCount,-Xmx • Since Java SE 8u131, the JVM • is “Docker aware with respect to Docker CPU limits transparently” • has new options for detecting memory limits (not transparent, yet) • -XX:+UnlockExperimentalVMOptions • -XX:+UseCGroupMemoryLimitForHeap BEWARE WHAT THE JVM CAN SEE ! (AND USE !) Since Java 10 (backported to Java 8u191 !) the JVM properly (without -XX) detects CPU and Memory limits https://blog.docker.com/2018/04/improved-docker-container-integration-with-java-10/
  • 6. Container, exposing 8080 JVM based webapp, 8080 H2 (in memory db) Ehcache (local caching) REST API Angular 2 UI BASED ON JHIPSTER / SPRING BOOT 2 DOCKERIZING THE DEMO APP
  • 7. WE ALL KNOW DOCKER, BUT… IS IT THE ONLY OPTION TO BUILD IMAGES AND RUN CONTAINERS ? FROM openjdk EXPOSE 8080 ADD app.jar /app.jar CMD java - jar /app.jar Linux Container Docker / OCI Image Data & Metadata runbuild
  • 8. WE ALL KNOW DOCKER, BUT… WHAT ARE THE CONTENDERS ? • cri-o • rkt (Daemonless) BUILD RUN* Supports Dockerfile ? IMG Yes Buildah Yes Bazel No (has builder for java) Buildpack No (has builder for java) Jib No (java native builder) And others local (Draft), and cloud builders : DockerHub, Google Cloud Builder, etc. *: that includes registry and storage access
  • 10. KUBERNETES INTRODUCTION • Initial release June 7th 2014 • Apache 2 License, written in Go • heavily inspired by Borg, internal system from Google • Currently 1.12 (a new release every 3 months on average) • Under the umbrella of the Cloud Native Computing Foundation • that includes Oracle, Intel, IBM, Pivotal, Redhat, etc. • along with Prometheus, Helm, OpenTracing, containerd, CNI, Buildpacks, etc. FROM BORG TO CNCF https://l.cncf.io
  • 11. KUBERNETES ARCHITECTURE By Khtan66 - CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=53571935 MASTER NODES, WORKER NODES, SOME NETWORKING…
  • 12. Deployment (Declarative Updates) > kubectl set image deployment/tmc-deployment tmc=tmc:10.3 > kubectl rollout status deployment/tmc-deployment Replica Set (Match and Scale definitions) spec: replicas: 3 selector: matchLabels: tier: tmc KUBERNETES WORKLOADS (PODS AND CONTROLLERS) DEPLOYMENT > REPLICA SET > POD > CONTAINER Pod spec: containers: - name: tmc image: store/softwareag/tmc:10.2 command: [‘start.sh’] - name: helper-container image: busybox command: ['sh', '-c', 'ping tmc’] volumes: (secrets, configmaps, etc.) hostname: terracotta + Jobs, StatefulSets, Daemon sets, etc. metadata: labels: tier: tmc
  • 13. KUBERNETES SERVICES (L4) • ClusterIP (default) • Exposes the service on a cluster-internal IP • NodePort • Exposes the service on a port on each node’s IP • LoadBalancer • Exposes the service externally, • using the cluster provided load balancer HOW DO YOU EXPOSE YOUR WORKLOADS “A Kubernetes Service is an abstraction which defines a logical set of Pods and a policy by which to access them” https://kubernetes.io/docs/concepts/services-networking/service/ Node A Pod-1 labels tier:frontend Service spec: type: LoadBalancer ports: -port:80 selector: tier:frontend in | outside NodeB Pod-2 labels tier:frontend
  • 14. KUBERNETES VOLUMES, CONFIG MAPS AND SECRETS • Many types of volumes are available : hostPath, nfs, cloud specific, etc. • ConfigMaps and Secrets are stored on the Kubernetes key/value store YOU CAN MOUNT THEM ALL ! Pod apiVersion: v1 kind: Pod spec: containers: - name: terracotta-server image: store/softwareag/terracotta-server:10.2 volumeMounts: - name: config-volume mountPath: /config - name: data mountPath: /data volumes: - name: config-volume configMap: name: tc-config - name: data hostPath: path: /usr ConfigMap apiVersion: v1 kind: ConfigMap metadata: name: tc-config data: tc-config.xml: | <xml></xml>
  • 15. KUBERNETES DEPLOYMENTS • Cloud providers • Google Cloud with GKE • Microsoft Azure with AKS • Amazon with Kops and now EKS • Oracle Cloud with OKE • Exoscale, Digital Ocean,OVH, etc. • Playgrounds : Katacoda and Play with Kubernetes CLOUD, ON-PREMISE, LOCAL • On-premise • Hard way • Kubeadm • Local • Minikube • Minishift • Docker for Mac (more on this one later)
  • 16. Kubernetes Cluster n Terracotta Server Terracotta Server… Demo app MySQL DEPLOYING THE DEMO APP TO KUBERNETES
  • 17. KUBERNETES PACKAGING : HELM • Helm is installed on the client, Tiller is the server side • With Helm you deploy / create Charts that are run as Releases • In a Chart, you package your Kubernetes manifests, and your dependencies • A very notable feature is the “templatization“ of your Kubernetes manifests APT / YUM FOR KUBERNETES apiVersion: apps/v1 kind: StatefulSet metadata: name: {{ template "terracotta.fullname" . }} labels: app: {{ template "terracotta.name" . }} spec: replicas: {{ .Values.replicaCount }} selector: matchLabels: app: {{ template "terracotta.name" . }} serviceName: {{ template "terracotta.fullname" . }} spec: {{- if .Values.nodeSelector }} nodeSelector: {{ toYaml .Values.nodeSelector | indent 8 }} {{- end }} containers: - name: {{ template "terracotta.fullname" . }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}”
  • 18. TOOLS TO BECOME A 100X DEVELOPER WITH KUBERNETES
  • 19. CLASSIC DOCKER AND KUBERNETES TOOLING • IDE plugins • auto completion for Dockerfile, Kubernetes and Helm! (IntelliJ 2018.3) • To build and deploy images from the IDE • Build tools (Maven / Gradle) Docker integration • Maven Docker plugin, Jib • Docker for Mac / Win 10 •latest stable comes with K8s support • Minikube
  • 20. KUBERNETES TOOLING : SKAFFOLD • Skaffold goal is to auto re-deploy on change • A month ago jib integration was added • A Kubernetes manifest, a skaffold config file and skaffold dev • watches your source files • rebuilds them (output is a Docker image) on change • (re) deploys your app to Kubernetes MAGICALLY AUTO REDEPLOYS ON CHANGE apiVersion: skaffold/v1alpha4 kind: Config build: artifacts: - image: anthonydahanne/fullstack context: . jibMaven: profile: "dev,skipTestsAndYarn"
  • 21. KUBERNETES TOOLING : TELEPRESENCE • Telepresence goal is to allow local processes to be available in a remote Kubernetes cluster • A process running on your laptop can access (remote) Kubernetes resources • It can also be seen by them • Most common use case is to replace an existing pod with the telepresence pod that proxies both ways to your local process MAGICALLY DEPLOY LOCAL PROCESSES INTO THE K8S CLUSTER > telepresence --swap-deployment fullstack --expose 8080:80 --run java -jar target/demo-1.0.0-SNAPSHOT.war
  • 23. MONITORING WITH PROMETHEUS • CNCF graduated / is the basis for an open monitoring format • By default pull metrics from apps; but a Node exporter supports push • Extremely simple to configure for Kubernetes workloads : • Dropwizard metrics, micrometer, etc. provide Prometheus integration for Java MONITORING SYSTEM AND TIME SERIES DATABASE kind: Service metadata: annotations: prometheus.io/scrape: 'true' prometheus.io/path: '/prometheusMetrics'
  • 24. MONITORING WITH PROMETHEUS GENERAL ARCHITECTURE https://winderresearch.com/introduction-to-monitoring-microservices-with-prometheus/
  • 25. KUBERNETES OPERATOR IN JAVA • Operators (or controllers) provide better user experience for deploying and managing complex applications like databases (PostgreSQL, Terracotta server, etc.) • They can create and manage their own Custom Resource Definitions (CRDs) - or provide a CLI or UI via their own REST endpoints USING FABRIC8 OR KUBERNETES JAVA SDK <dependency> <groupId>io.fabric8</groupId> <artifactId>kubernetes-client</artifactId> <version>4.0.3</version> </dependency> <dependency> <groupId>io.kubernetes</groupId> <artifactId>client-java</artifactId> <version>3.0.0-beta2</version> </dependency> Service tmcService = new ServiceBuilder() .withNewMetadata() .withName("tmc") .endMetadata() .withNewSpec() .addNewPort() .withName("tmc-port") .withPort(9480) .endPort() .withType("LoadBalancer") .addToSelector("app", "tmc") .endSpec() .build();
  • 26. TERRACOTTA OPERATOR ARCHITECTURE Kubernetes Cluster Terracotta Operator REST API CLI / Web UI K8S API Server Java SDK REST calls license tc-configs operator config Terracotta ServerTerracotta Server TMC ConfigMaps Services, StatefulSets A PRIVILEGED POD THAT LISTENS TO THE USER
  • 27. TERRACOTTA OPERATOR ARCHITECTURE Kubernetes Cluster Terracotta Operator kubectl apply K8S API Server Java SDK Watch license tc-configs operator config Terracotta ServerTerracotta Server TMC ConfigMaps Services, StatefulSets A PRIVILEGED POD THAT LISTENS TO THE API SERVER
  • 28. THE END ! OR JUST THE BEGINNING ? RBAC Service Mesh Ingress controller …
  • 29. LINKS AND OTHER REFERENCES • Containers from scratch, talk by Liz Rice • Jib presentation, talk by Qingyang Chen and Appu Goundan • The fullstack demo app (and its jib, kubernetes, helm, scaffold files) is on Github
  • 30. © 2017 Software AG. All rights reserved. For internal use only Coming up next !