SlideShare a Scribd company logo
1 of 22
Download to read offline
© 2017 Software AG. All rights reserved. For internal use only
Anthony Dahanne. Montreal JUG, May 2nd, 2018
KUBERNETES FOR JAVA DEVELOPERS
LET ME INTRODUCE MYSELF
„Anthony Dahanne, Software Engineer @ Terracotta, a Software AG
company
„Working on the Management and Monitoring in Terracotta products
(Ehcache, Terracotta Store)
„Also working on Terracotta products integration with cloud (Docker,
Kubernetes, AWS, etc.)
Go and try our latest images and instructions at :
https://store.docker.com/publishers/softwareag
https://github.com/SoftwareAG/terracotta-db-cloud
All this presentation’s examples are on Github:
https://github.com/anthonydahanne/kubernetes-for-java-developers
AGENDA
Docker & Java refresher in 2 slides
Kubernetes concepts and examples
Tools to become a productive developer with
Kubernetes
Coding Java applications leveraging Kubernetes
CONTAINERS IN 1 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 namespaces and cgroups
• namespaces : limits what you can see
• pid, net, mnt, uts, ipc, user
• cgroups : limits what you can use
• memory, CPU, block IO, network (with iptables)
THAT’S JUST AN ISOLATED PROCESS !
https://www.enterprisetech.com/2014/08/18/ibm-techies-pit-docker-kvm-bare-metal/
https://www.slideshare.net/jpetazzo/anatomy-of-a-container-namespaces-cgroups-some-filesystem-magic-linuxcon
JAVA AND LINUX CONTAINERS
• The JVM “guesses” available CPU and Memory resources available on the host
• 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 !)
Demo : Memory Eater
KUBERNETES
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.10 (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, OpenTracing, containerd, CNI, FluentD, etc.
FROM BORG TO CNCF
https://github.com/cncf/landscape
KUBERNETES LOCAL COMMUNITY
• Kubernetes / CNCF Montreal Meetup every quarter
• Almost 1000 members
• Slack channel sync’ing all other Canadians K8s communities
k8scanada.slack.com
• Led by Archy, CNCF Ambassador
YOU ARE NOT ALONE !
KUBERNETES ARCHITECTURE
MASTER NODES, WORKER NODES, SOME NETWORKING…
By Khtan66 - CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=53571935
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', 'sleep 3600’]
volumes: (secrets, configmaps, etc.)
hostname: terracotta
+ Jobs, StatefulSets, Daemon sets, etc.
metadata:
labels:
tier: tmc
KUBERNETES SERVICES
• ClusterIP (default)
• Exposes the service on a cluster-
internal IP
• NodePort
• Exposes the service on each node’s IP
address, on a defined port
• LoadBalancer
• Exposes the service externally, using
the cluster provided load balancer
• no default LoadBalancer on premise …
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
• ConfigMaps and Secrets are stored on the etcd key/value store
• Often times, volumes are abstracted away with PersistentVolumes and
PersistentVolumeClaims
• Many types of volumes are available : hostPath, nfs, cloud specific, etc.
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 (although EKS is around the corner)
• Playgrounds : Katacoda and Play with Kubernetes
• On-premise
• Hard way
• Kubeadm
• Local
• Minikube
• Minishift
• Docker for Mac (more on this one later)
CLOUD, ON-PREMISE, LOCAL
Demo : Fullstack app deployment
BEING A PRODUCTIVE DEVELOPER WITH KUBERNETES
TOOLING !
• IDE plugins
• auto completion for Dockerfile
• To build and deploy images from the IDE
• Build tooling Docker integration (Maven / Gradle)
• To build Docker (and push) images during the build
• Maven Docker plugin
DOCKER TOOLING
• Docker for Mac / Win 10
• As of today, only the edge
version comes with
Kubernetes support
KUBERNETES OWN TOOLING
• IDE plugins
• auto completion for Dockerfile
• To build and deploy images from the IDE
• Build tooling Docker integration (Maven / Gradle)
• To build Docker (and push) images during the build
• Kubectl (obviously !)
• and its bash / zsh auto completion !
• Kubernetic UI
• and more !
KUBERNETES TOOLING : 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/v1beta2
kind: Deployment
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "terracotta-server.name" . }}
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ template "terracotta-server.name" . }}
release: {{ .Release.Name }}
spec:
hostname: {{ template "terracotta-server.fullname" . }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: terracotta-port
containerPort: 9410
protocol: TCP
Demo : helm for fullstack app
KUBERNETES TOOLING : SKAFFOLD
• Skaffold goal is to auto re deploy on save
• Download the binary and you can start “skaffolding”
• It’s not even necessary to provide k8s manifest files
MAGICALLY AUTO REDEPLOY
apiVersion: skaffold/v1alpha2
kind: Config
build:
artifacts:
- imageName: gcr.io/k8s-skaffold/skaffold-no-manifest-example
deploy:
kubectl:
manifests:
Demo : skaffold for Java hello world
KUBERNETES BASED TOOLING : JENKINS X
JENKINS, NEXUS, HELM AND FRIENDS IN THE CLOUD
Very new !!!(public sinceMarch 2018)
Available at https://jenkins-x.io/
Demo : JenkinsX on AWS
INTERACTING WITH KUBERNETES FROM JAVA
HTTPS://GITHUB.COM/KUBERNETES-CLIENT/JAVA
SIMPLE JAVA WEB APP TO LIST AND DELETE PODS
THERE’S ALREADY A JAVA CLIENT API !
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);
CoreV1Api api = new CoreV1Api();
//list the pods
V1PodList list = api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null);
pods = list.getItems();
//delete a pod
V1DeleteOptions v1DeleteOptions = new V1DeleteOptions();
api.deleteNamespacedPod(name, "default", v1DeleteOptions, null, null, false, null);
Demo : simple webapp to list and delete pods
© 2017 Software AG. All rights reserved. For internal use only!22

More Related Content

What's hot

What's hot (20)

Kubernetes Architecture - beyond a black box - Part 2
Kubernetes Architecture - beyond a black box - Part 2Kubernetes Architecture - beyond a black box - Part 2
Kubernetes Architecture - beyond a black box - Part 2
 
Containers #101 : Docker ONBUILD triggers and Introduction to Docker Compose
Containers #101 : Docker ONBUILD triggers and Introduction to Docker ComposeContainers #101 : Docker ONBUILD triggers and Introduction to Docker Compose
Containers #101 : Docker ONBUILD triggers and Introduction to Docker Compose
 
Container Days Boston - Kubernetes in production
Container Days Boston - Kubernetes in productionContainer Days Boston - Kubernetes in production
Container Days Boston - Kubernetes in production
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Docker worshop @Twitter - How to use your own private registry
Docker worshop @Twitter - How to use your own private registryDocker worshop @Twitter - How to use your own private registry
Docker worshop @Twitter - How to use your own private registry
 
Microservices using relocatable Docker containers
Microservices using relocatable Docker containersMicroservices using relocatable Docker containers
Microservices using relocatable Docker containers
 
Docker and stuff
Docker and stuffDocker and stuff
Docker and stuff
 
Kubernetes Java Operator
Kubernetes Java OperatorKubernetes Java Operator
Kubernetes Java Operator
 
Discovering Docker Volume Plugins and Apps using VirtualBox
Discovering Docker Volume Plugins and Apps using VirtualBoxDiscovering Docker Volume Plugins and Apps using VirtualBox
Discovering Docker Volume Plugins and Apps using VirtualBox
 
Basic docker for developer
Basic docker for developerBasic docker for developer
Basic docker for developer
 
Continuous Integration with Docker on AWS
Continuous Integration with Docker on AWSContinuous Integration with Docker on AWS
Continuous Integration with Docker on AWS
 
Kubernetes and Hybrid Deployments
Kubernetes and Hybrid DeploymentsKubernetes and Hybrid Deployments
Kubernetes and Hybrid Deployments
 
Docker - From Walking To Running
Docker - From Walking To RunningDocker - From Walking To Running
Docker - From Walking To Running
 
Docker at Spotify - Dockercon14
Docker at Spotify - Dockercon14Docker at Spotify - Dockercon14
Docker at Spotify - Dockercon14
 
Docker - 15 great Tutorials
Docker - 15 great TutorialsDocker - 15 great Tutorials
Docker - 15 great Tutorials
 
Docker Container As A Service - March 2016
Docker Container As A Service - March 2016Docker Container As A Service - March 2016
Docker Container As A Service - March 2016
 
Docker, LinuX Container
Docker, LinuX ContainerDocker, LinuX Container
Docker, LinuX Container
 
Scaling Docker with Kubernetes
Scaling Docker with KubernetesScaling Docker with Kubernetes
Scaling Docker with Kubernetes
 
Docker Ecosystem on Azure
Docker Ecosystem on AzureDocker Ecosystem on Azure
Docker Ecosystem on Azure
 
Optimizing Docker Images
Optimizing Docker ImagesOptimizing Docker Images
Optimizing Docker Images
 

Similar to Kubernetes for Java Developers

Application Deployment on Openstack
Application Deployment on OpenstackApplication Deployment on Openstack
Application Deployment on Openstack
Docker, Inc.
 

Similar to Kubernetes for Java Developers (20)

Kubernetes for the PHP developer
Kubernetes for the PHP developerKubernetes for the PHP developer
Kubernetes for the PHP developer
 
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
 
The App Developer's Kubernetes Toolbox
The App Developer's Kubernetes ToolboxThe App Developer's Kubernetes Toolbox
The App Developer's Kubernetes Toolbox
 
Containerised ASP.NET Core apps with Kubernetes
Containerised ASP.NET Core apps with KubernetesContainerised ASP.NET Core apps with Kubernetes
Containerised ASP.NET Core apps with Kubernetes
 
Introduction to Kubernetes
Introduction to KubernetesIntroduction to Kubernetes
Introduction to Kubernetes
 
Sebastien goasguen cloud stack and docker
Sebastien goasguen   cloud stack and dockerSebastien goasguen   cloud stack and docker
Sebastien goasguen cloud stack and docker
 
Kubernetes #1 intro
Kubernetes #1   introKubernetes #1   intro
Kubernetes #1 intro
 
The path to a serverless-native era with Kubernetes
The path to a serverless-native era with KubernetesThe path to a serverless-native era with Kubernetes
The path to a serverless-native era with Kubernetes
 
Microservices in Java
Microservices in JavaMicroservices in Java
Microservices in Java
 
Docker Presentation at the OpenStack Austin Meetup | 2013-09-12
Docker Presentation at the OpenStack Austin Meetup | 2013-09-12Docker Presentation at the OpenStack Austin Meetup | 2013-09-12
Docker Presentation at the OpenStack Austin Meetup | 2013-09-12
 
Application Deployment on Openstack
Application Deployment on OpenstackApplication Deployment on Openstack
Application Deployment on Openstack
 
Kubernetes: The Next Research Platform
Kubernetes: The Next Research PlatformKubernetes: The Next Research Platform
Kubernetes: The Next Research Platform
 
Docker kubernetes fundamental(pod_service)_190307
Docker kubernetes fundamental(pod_service)_190307Docker kubernetes fundamental(pod_service)_190307
Docker kubernetes fundamental(pod_service)_190307
 
Managing Container Clusters in OpenStack Native Way
Managing Container Clusters in OpenStack Native WayManaging Container Clusters in OpenStack Native Way
Managing Container Clusters in OpenStack Native Way
 
Kubernetes - how to orchestrate containers
Kubernetes - how to orchestrate containersKubernetes - how to orchestrate containers
Kubernetes - how to orchestrate containers
 
Docker SF Meetup January 2016
Docker SF Meetup January 2016Docker SF Meetup January 2016
Docker SF Meetup January 2016
 
Kubernetes Introduction
Kubernetes IntroductionKubernetes Introduction
Kubernetes Introduction
 
Docker module 1
Docker module 1Docker module 1
Docker module 1
 
A DevOps guide to Kubernetes
A DevOps guide to KubernetesA DevOps guide to Kubernetes
A DevOps guide to Kubernetes
 

More from 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
 

More from 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
 

Recently uploaded

%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
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
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
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
 

Recently uploaded (20)

Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
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
 
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
 
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...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
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...
 
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...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
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
 

Kubernetes for Java Developers

  • 1. © 2017 Software AG. All rights reserved. For internal use only Anthony Dahanne. Montreal JUG, May 2nd, 2018 KUBERNETES FOR JAVA DEVELOPERS
  • 2. LET ME INTRODUCE MYSELF „Anthony Dahanne, Software Engineer @ Terracotta, a Software AG company „Working on the Management and Monitoring in Terracotta products (Ehcache, Terracotta Store) „Also working on Terracotta products integration with cloud (Docker, Kubernetes, AWS, etc.) Go and try our latest images and instructions at : https://store.docker.com/publishers/softwareag https://github.com/SoftwareAG/terracotta-db-cloud All this presentation’s examples are on Github: https://github.com/anthonydahanne/kubernetes-for-java-developers
  • 3. AGENDA Docker & Java refresher in 2 slides Kubernetes concepts and examples Tools to become a productive developer with Kubernetes Coding Java applications leveraging Kubernetes
  • 4. CONTAINERS IN 1 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 namespaces and cgroups • namespaces : limits what you can see • pid, net, mnt, uts, ipc, user • cgroups : limits what you can use • memory, CPU, block IO, network (with iptables) THAT’S JUST AN ISOLATED PROCESS ! https://www.enterprisetech.com/2014/08/18/ibm-techies-pit-docker-kvm-bare-metal/ https://www.slideshare.net/jpetazzo/anatomy-of-a-container-namespaces-cgroups-some-filesystem-magic-linuxcon
  • 5. JAVA AND LINUX CONTAINERS • The JVM “guesses” available CPU and Memory resources available on the host • 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 !) Demo : Memory Eater
  • 7. KUBERNETES INTRODUCTION • Initial release June 7th 2014 • Apache 2 License, written in Go • heavily inspired by Borg, internal system from Google • Currently 1.10 (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, OpenTracing, containerd, CNI, FluentD, etc. FROM BORG TO CNCF https://github.com/cncf/landscape
  • 8. KUBERNETES LOCAL COMMUNITY • Kubernetes / CNCF Montreal Meetup every quarter • Almost 1000 members • Slack channel sync’ing all other Canadians K8s communities k8scanada.slack.com • Led by Archy, CNCF Ambassador YOU ARE NOT ALONE !
  • 9. KUBERNETES ARCHITECTURE MASTER NODES, WORKER NODES, SOME NETWORKING… By Khtan66 - CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=53571935
  • 10. 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', 'sleep 3600’] volumes: (secrets, configmaps, etc.) hostname: terracotta + Jobs, StatefulSets, Daemon sets, etc. metadata: labels: tier: tmc
  • 11. KUBERNETES SERVICES • ClusterIP (default) • Exposes the service on a cluster- internal IP • NodePort • Exposes the service on each node’s IP address, on a defined port • LoadBalancer • Exposes the service externally, using the cluster provided load balancer • no default LoadBalancer on premise … 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
  • 12. KUBERNETES VOLUMES, CONFIG MAPS AND SECRETS • ConfigMaps and Secrets are stored on the etcd key/value store • Often times, volumes are abstracted away with PersistentVolumes and PersistentVolumeClaims • Many types of volumes are available : hostPath, nfs, cloud specific, etc. 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>
  • 13. KUBERNETES DEPLOYMENTS • Cloud providers • Google Cloud with GKE • Microsoft Azure with AKS • Amazon with Kops (although EKS is around the corner) • Playgrounds : Katacoda and Play with Kubernetes • On-premise • Hard way • Kubeadm • Local • Minikube • Minishift • Docker for Mac (more on this one later) CLOUD, ON-PREMISE, LOCAL Demo : Fullstack app deployment
  • 14. BEING A PRODUCTIVE DEVELOPER WITH KUBERNETES TOOLING !
  • 15. • IDE plugins • auto completion for Dockerfile • To build and deploy images from the IDE • Build tooling Docker integration (Maven / Gradle) • To build Docker (and push) images during the build • Maven Docker plugin DOCKER TOOLING • Docker for Mac / Win 10 • As of today, only the edge version comes with Kubernetes support
  • 16. KUBERNETES OWN TOOLING • IDE plugins • auto completion for Dockerfile • To build and deploy images from the IDE • Build tooling Docker integration (Maven / Gradle) • To build Docker (and push) images during the build • Kubectl (obviously !) • and its bash / zsh auto completion ! • Kubernetic UI • and more !
  • 17. KUBERNETES TOOLING : 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/v1beta2 kind: Deployment spec: replicas: {{ .Values.replicaCount }} selector: matchLabels: app: {{ template "terracotta-server.name" . }} release: {{ .Release.Name }} template: metadata: labels: app: {{ template "terracotta-server.name" . }} release: {{ .Release.Name }} spec: hostname: {{ template "terracotta-server.fullname" . }} containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - name: terracotta-port containerPort: 9410 protocol: TCP Demo : helm for fullstack app
  • 18. KUBERNETES TOOLING : SKAFFOLD • Skaffold goal is to auto re deploy on save • Download the binary and you can start “skaffolding” • It’s not even necessary to provide k8s manifest files MAGICALLY AUTO REDEPLOY apiVersion: skaffold/v1alpha2 kind: Config build: artifacts: - imageName: gcr.io/k8s-skaffold/skaffold-no-manifest-example deploy: kubectl: manifests: Demo : skaffold for Java hello world
  • 19. KUBERNETES BASED TOOLING : JENKINS X JENKINS, NEXUS, HELM AND FRIENDS IN THE CLOUD Very new !!!(public sinceMarch 2018) Available at https://jenkins-x.io/ Demo : JenkinsX on AWS
  • 20. INTERACTING WITH KUBERNETES FROM JAVA HTTPS://GITHUB.COM/KUBERNETES-CLIENT/JAVA
  • 21. SIMPLE JAVA WEB APP TO LIST AND DELETE PODS THERE’S ALREADY A JAVA CLIENT API ! ApiClient client = Config.defaultClient(); Configuration.setDefaultApiClient(client); CoreV1Api api = new CoreV1Api(); //list the pods V1PodList list = api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null); pods = list.getItems(); //delete a pod V1DeleteOptions v1DeleteOptions = new V1DeleteOptions(); api.deleteNamespacedPod(name, "default", v1DeleteOptions, null, null, false, null); Demo : simple webapp to list and delete pods
  • 22. © 2017 Software AG. All rights reserved. For internal use only!22