SlideShare a Scribd company logo
#DevoxxFR
Devoxx France 2018
Mes Applications en Production
sur Kubernetes
Michael Morello
@barkbay
#DevoxxFR
About me
MICHAEL MORELLO
deploy, manage, maintain { , }
Kubernetes
@
},
GO
,
} developer
#DevoxxFR
Kubernetes ?
•C’est un « cluster manager » :
K8S gère une flotte de machines (physiques ou virtuelles)
•C’est un ensemble d’ «objets » :
K8S permet de déclarer l’état attendu d’une application
•Pilotable par API :
Référence : https://kubernetes.io/docs/concepts/
#DevoxxFR
Observability
Security
Resilience
#DevoxxFR
POD ?
Interface réseau commune aux conteneurs
Partage de système de fichiers
Colocalisés sur un
même serveur
#DevoxxFR
Un POD ?
metadata:
labels:
app: lab-java
spec:
containers:
- name: lab
image: barkbay/k8s-app-lab:java-v0
ports:
- containerPort: 8080
Une liste de
conteneurs
Quelques
métadonnées
#DevoxxFR
A security context defines privilege
and access control settings for a
Pod or Container :
• User ID
• Linux Capabilities
• SELinux labels
• AllowPrivilegeEscalation
Security context
#DevoxxFR
SecurityContext
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1234
fsGroup: 2000
containers:
- name: lab
image: barkbay/k8s-app-lab:java-v0
securityContext:
allowPrivilegeEscalation: false
ports:
- containerPort: 8080
SecurityContext
PodSecurityContext
#DevoxxFR
« SCCs are objects that define a set of conditions that a pod must run
with in order to be accepted into the system. »
TL;DR : Les SCCs permettent d’appliquer un contexte de sécurité par
défaut sur les PODs.
PSP : Pod Security Policy is a cluster-level resource that controls
security sensitive aspects of the pod specification.
OU
Un SecurityContext automatique ?
#DevoxxFR
Comprendre les SecurityContext, travailler avec vos OPS sur la mise en œuvre des PSP (ou
utilisez Openshift)
SELinux : "Every time you run setenforce 0, you make Dan Walsh weep. Dan is a nice guy and
he certainly doesn't deserve that. »
Utiliser des namespaces dédiés
Utiliser des ServiceAccount : des comptes techniques qui vous permettront de jouer avec les
RBAC
Quelle sécurité pour les flux applicatifs ? TLS de bout en bout ?
Security takeaway
#DevoxxFR
Gestion des ressources partagées
#DevoxxFR
Multi-tenant : Share Cpu and memory
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
fsGroup: 2000
containers:
- name: lab
image: barkbay/k8s-app-lab:java-v0
resources:
requests:
memory: "128Mi"
cpu: "500m"
limits:
memory: "192Mi"
cpu: "2"
securityContext:
allowPrivilegeEscalation: false
ports:
- containerPort: 8080
Limits control the maximum amount of
resources that the container may use
The scheduler uses resources
requests to find a node with an
appropriate fit for all containers in a
POD.
#DevoxxFR
Multi-tenant : Share Cpu and memory
containers:
- name: lab
image: barkbay/k8s-app-lab:java-v0
resources:
requests:
memory: "128Mi"
cpu: "500m"
limits:
memory: "192Mi"
cpu: "2"
« Converted to its millicore value and
multiplied by 100. The resulting value is the
total amount of CPU time that a container
can use every 100ms. A container cannot
use more than its share of CPU time during
this interval. »
On appelle ça faire du Throttling
#DevoxxFR
Multi-tenant : Share Cpu and memory
containers:
- name: lab
image: barkbay/k8s-app-lab:java-v0
resources:
requests:
memory: "128Mi"
cpu: "500m"
limits:
memory: "192Mi"
cpu: "2"
"GC task thread#0 (ParallelGC)" […] runnable
"GC task thread#1 (ParallelGC)" […] runnable
"GC task thread#2 (ParallelGC)" […] runnable
"GC task thread#3 (ParallelGC)" […] runnable
Tuning automatique
de la JVM
Runtime.getRuntime()
.availableProcessors() = 4
#DevoxxFR
Multi-tenant : Share Cpu and memory
containers:
- name: lab
image: barkbay/k8s-app-lab:java-v0
resources:
requests:
memory: "128Mi"
cpu: "500m"
limits:
memory: "192Mi"
cpu: "2"
$ cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us
200000
$ cat /sys/fs/cgroup/cpu/cpu.cfs_period_us
100000
$ expr 200000 / 100000
2 <= ~= 2 CPUs disponibles
-XX:ParallelGCThreads=2
-XX:ConcGCThreads=2
-Djava.util.concurrent.ForkJoinPool.common.parallelism=2
-XX:CICompilerCount=2
Java 8
-XX:ActiveProcessorCount=2
https://docs.oracle.com/javase/10/tools/java.htm
Java 10
#DevoxxFR
Monitoring CPU cgroup
$ cat /sys/fs/cgroup/cpu/cpu.stat
user 1637
system 88
nr_periods 520
nr_throttled 364 : number of times tasks in a cgroup have been
throttled
throttled_time 72988838516 : the total time duration (in
nanoseconds) for which tasks in a cgroup have been throttled.
1
#DevoxxFR
Memory cgroup
PAGE
CACHE
FREE
RECLAIMABLE MEMORY
CGROUP MANAGED MEMORY
Java Virtual Machine
HEAP
Native
Memory
USED
#DevoxxFR
Memory cgroup
PAGE
CACHE
FREE
RECLAIMABLE MEMORY
CGROUP MANAGED MEMORY
Java Virtual Machine
HEAP
Native
Memory
USED
#DevoxxFR
Memory cgroup
F
R
E
E
RECLAIMABLE
MEMORY ?
CGROUP MANAGED MEMORY
Java Virtual Machine
HEAP
Native
Memory
USED
#DevoxxFR
OOM-KILLER In Action
java invoked oom-killer: gfp_mask=0xd0, order=0, oom_score_adj=872
[…]
memory: usage 196608kB, limit 196608kB, failcnt 1953
[…]
[ pid ] uid tgid total_vm rss nr_ptes swapents oom_score_adj name
[25616] 1000 25616 254 1 4 0 -998 pause
[25687] 1000 25687 678075 48764 165 0 872 java
Memory cgroup out of memory: Kill process 25908 (java) score 1864 or
sacrifice child
Killed process 25687 (java) total-vm:2712300kB, anon-rss:191448kB, file-
rss:3520kB, shmem-rss:0kB
The failcnt field gives the number of times that the
cgroup limit was exceeded.
limits:
memory: "192Mi"
#DevoxxFR
Avoid OOM-Killer with Java 8
$ # Dans le conteneur
$ cat /sys/fs/cgroup/memory/memory.limit_in_bytes
402653184 #384Mo max
$ # A vous de calculer le Xmx qui va bien
ou
-XX:+UnlockExperimentalVMOptions
-XX:+UseCGroupMemoryLimitForHeap
#DevoxxFR
Interlude « Collectons les Métriques »
#DevoxxFR
Métriques ?
container_cpu_cfs_throttled_seconds_total{container_name="foo"} 1027 1395066363000
Metric name
Label
Value Timestamp
GET /metrics HTTP/1.0
PROMETHEUS
#DevoxxFR
Prometheus
PROMETHEUS
ALERTING
#DevoxxFR
Fin de l’Interlude « Collectons les Métriques »
#DevoxxFR
Monitoring containers limits
• container_cpu_cfs_throttled_periods_total
• container_cpu_cfs_throttled_seconds_total
• container_memory_failcnt
#DevoxxFR
Monitoring your own metrics
kind: Service
apiVersion: v1
metadata:
name: lab-java-service
annotations:
prometheus.io/scrape: "true"
spec:
selector:
app: lab-java
ports:
- protocol: TCP
port: 80
targetPort: 8080
+
endpoint_hello_total{status="get",} 1606.0
Implement call to /metrics :
#DevoxxFR
HPA : Horizontal Pod Autoscaler
COREAPICustomMetricAPI
API
POD
de
Mediation
scale up !H.P.A.
PROMETHEUS
/metrics
POD POD POD
GET /apis/custom.metrics.k8s.io/[…]/lab-java-service/endpoint_hello
42
#DevoxxFR
Is it alive ?
spec:
containers:
- name: lab
image: barkbay/k8s-app-lab:java-v0
livenessProbe:
httpGet:
path: /hello
port: 8080
readinessProbe:
httpGet:
path: /hello
port: 8080
initialDelaySeconds: 5
periodSeconds: 2
ports:
- containerPort: 8080
Ouvrir les flux ?
Redémarrer
le conteneur ?
#DevoxxFR
Is it alive ?
spec:
containers:
- name: lab
image: barkbay/k8s-app-lab:java-v0
livenessProbe:
tcpSocket:
port: 8080
readinessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 5
periodSeconds: 2
ports:
- containerPort: 8080
Ouvrir les flux ?
Redémarrer
le conteneur ?
#DevoxxFR
Pod Disruption Budget (a.k.a. PDB)
En cas de "disruption" "volontaire" permet de maintenir un nombre minimum
d’instances.
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: lab-java-pdb
spec:
minAvailable: 1
selector:
matchLabels:
app: lab-java
#DevoxxFR
Takeaway
•Security first
•Exposer des métriques
•Collecter des métriques
•Surveiller :
•cgroups : memory and cpu
•application restarts
•events dans les namespaces
•Implementer des tests Liveness and Readiness simples
#DevoxxFR
Merci / Thank you
Code source de l’application :
https://github.com/barkbay/k8s-app-lab/
#DevoxxFR
We love picture
We try to keep the Devox France logo and the Tweet
hashtag on all slides
3

More Related Content

What's hot

CoreOSによるDockerコンテナのクラスタリング
CoreOSによるDockerコンテナのクラスタリングCoreOSによるDockerコンテナのクラスタリング
CoreOSによるDockerコンテナのクラスタリング
Yuji ODA
 
Red Hat Enterprise Linux OpenStack Platform on Inktank Ceph Enterprise
Red Hat Enterprise Linux OpenStack Platform on Inktank Ceph EnterpriseRed Hat Enterprise Linux OpenStack Platform on Inktank Ceph Enterprise
Red Hat Enterprise Linux OpenStack Platform on Inktank Ceph Enterprise
Red_Hat_Storage
 
Java 8-at-sb-2016-02-26
Java 8-at-sb-2016-02-26Java 8-at-sb-2016-02-26
Java 8-at-sb-2016-02-26
Thorbjørn Andersen
 
Shared Memory Performance: Beyond TCP/IP with Ben Cotton, JPMorgan
Shared Memory Performance: Beyond TCP/IP with Ben Cotton, JPMorganShared Memory Performance: Beyond TCP/IP with Ben Cotton, JPMorgan
Shared Memory Performance: Beyond TCP/IP with Ben Cotton, JPMorgan
Hazelcast
 
(PFC303) Milliseconds Matter: Design, Deploy, and Operate Your Application fo...
(PFC303) Milliseconds Matter: Design, Deploy, and Operate Your Application fo...(PFC303) Milliseconds Matter: Design, Deploy, and Operate Your Application fo...
(PFC303) Milliseconds Matter: Design, Deploy, and Operate Your Application fo...
Amazon Web Services
 
Guava
GuavaGuava
Guava
fbenault
 
Guava Overview Part 2 Bucharest JUG #2
Guava Overview Part 2 Bucharest JUG #2 Guava Overview Part 2 Bucharest JUG #2
Guava Overview Part 2 Bucharest JUG #2
Andrei Savu
 
Move Over, Rsync
Move Over, RsyncMove Over, Rsync
Move Over, Rsync
All Things Open
 
GlusterFS As an Object Storage
GlusterFS As an Object StorageGlusterFS As an Object Storage
GlusterFS As an Object Storage
Keisuke Takahashi
 
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation CenterDUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
Andrey Kudryavtsev
 
Docker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in PragueDocker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in Prague
tomasbart
 
Object Storage with Gluster
Object Storage with GlusterObject Storage with Gluster
Object Storage with Gluster
Gluster.org
 
Elastic 101 tutorial - Percona Europe 2018
Elastic 101 tutorial - Percona Europe 2018 Elastic 101 tutorial - Percona Europe 2018
Elastic 101 tutorial - Percona Europe 2018
Antonios Giannopoulos
 
Aerospike Go Language Client
Aerospike Go Language ClientAerospike Go Language Client
Aerospike Go Language Client
Sayyaparaju Sunil
 
glance replicator
glance replicatorglance replicator
glance replicator
irix_jp
 
10 things i wish i'd known before using spark in production
10 things i wish i'd known before using spark in production10 things i wish i'd known before using spark in production
10 things i wish i'd known before using spark in production
Paris Data Engineers !
 
Ceph issue 해결 사례
Ceph issue 해결 사례Ceph issue 해결 사례
Ceph issue 해결 사례
Open Source Consulting
 
Commication Framework in OpenStack
Commication Framework in OpenStackCommication Framework in OpenStack
Commication Framework in OpenStack
Sean Chang
 
Storage based on_openstack_mariocho
Storage based on_openstack_mariochoStorage based on_openstack_mariocho
Storage based on_openstack_mariocho
Mario Cho
 
Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)
Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)
Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)
Ontico
 

What's hot (20)

CoreOSによるDockerコンテナのクラスタリング
CoreOSによるDockerコンテナのクラスタリングCoreOSによるDockerコンテナのクラスタリング
CoreOSによるDockerコンテナのクラスタリング
 
Red Hat Enterprise Linux OpenStack Platform on Inktank Ceph Enterprise
Red Hat Enterprise Linux OpenStack Platform on Inktank Ceph EnterpriseRed Hat Enterprise Linux OpenStack Platform on Inktank Ceph Enterprise
Red Hat Enterprise Linux OpenStack Platform on Inktank Ceph Enterprise
 
Java 8-at-sb-2016-02-26
Java 8-at-sb-2016-02-26Java 8-at-sb-2016-02-26
Java 8-at-sb-2016-02-26
 
Shared Memory Performance: Beyond TCP/IP with Ben Cotton, JPMorgan
Shared Memory Performance: Beyond TCP/IP with Ben Cotton, JPMorganShared Memory Performance: Beyond TCP/IP with Ben Cotton, JPMorgan
Shared Memory Performance: Beyond TCP/IP with Ben Cotton, JPMorgan
 
(PFC303) Milliseconds Matter: Design, Deploy, and Operate Your Application fo...
(PFC303) Milliseconds Matter: Design, Deploy, and Operate Your Application fo...(PFC303) Milliseconds Matter: Design, Deploy, and Operate Your Application fo...
(PFC303) Milliseconds Matter: Design, Deploy, and Operate Your Application fo...
 
Guava
GuavaGuava
Guava
 
Guava Overview Part 2 Bucharest JUG #2
Guava Overview Part 2 Bucharest JUG #2 Guava Overview Part 2 Bucharest JUG #2
Guava Overview Part 2 Bucharest JUG #2
 
Move Over, Rsync
Move Over, RsyncMove Over, Rsync
Move Over, Rsync
 
GlusterFS As an Object Storage
GlusterFS As an Object StorageGlusterFS As an Object Storage
GlusterFS As an Object Storage
 
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation CenterDUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
 
Docker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in PragueDocker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in Prague
 
Object Storage with Gluster
Object Storage with GlusterObject Storage with Gluster
Object Storage with Gluster
 
Elastic 101 tutorial - Percona Europe 2018
Elastic 101 tutorial - Percona Europe 2018 Elastic 101 tutorial - Percona Europe 2018
Elastic 101 tutorial - Percona Europe 2018
 
Aerospike Go Language Client
Aerospike Go Language ClientAerospike Go Language Client
Aerospike Go Language Client
 
glance replicator
glance replicatorglance replicator
glance replicator
 
10 things i wish i'd known before using spark in production
10 things i wish i'd known before using spark in production10 things i wish i'd known before using spark in production
10 things i wish i'd known before using spark in production
 
Ceph issue 해결 사례
Ceph issue 해결 사례Ceph issue 해결 사례
Ceph issue 해결 사례
 
Commication Framework in OpenStack
Commication Framework in OpenStackCommication Framework in OpenStack
Commication Framework in OpenStack
 
Storage based on_openstack_mariocho
Storage based on_openstack_mariochoStorage based on_openstack_mariocho
Storage based on_openstack_mariocho
 
Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)
Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)
Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)
 

Similar to Devoxx France 2018 : Mes Applications en Production sur Kubernetes

Kubernetes - Starting with 1.2
Kubernetes  - Starting with 1.2Kubernetes  - Starting with 1.2
Kubernetes - Starting with 1.2
William Stewart
 
K8s best practices from the field!
K8s best practices from the field!K8s best practices from the field!
K8s best practices from the field!
DoiT International
 
Lessons from running potentially malicious code inside containers
Lessons from running potentially malicious code inside containersLessons from running potentially malicious code inside containers
Lessons from running potentially malicious code inside containers
Ben Hall
 
Kubernetes Architecture and Introduction – Paris Kubernetes Meetup
Kubernetes Architecture and Introduction – Paris Kubernetes MeetupKubernetes Architecture and Introduction – Paris Kubernetes Meetup
Kubernetes Architecture and Introduction – Paris Kubernetes Meetup
Stefan Schimanski
 
cache concepts and varnish-cache
cache concepts and varnish-cachecache concepts and varnish-cache
cache concepts and varnish-cache
Marc Cortinas Val
 
网易云K8S应用实践 | practices for kubernetes cluster provisioning, management and ap...
网易云K8S应用实践 | practices for kubernetes cluster provisioning, management and ap...网易云K8S应用实践 | practices for kubernetes cluster provisioning, management and ap...
网易云K8S应用实践 | practices for kubernetes cluster provisioning, management and ap...
Xiaohui Chen
 
Artem Zhurbila - docker clusters (solit 2015)
Artem Zhurbila - docker clusters (solit 2015)Artem Zhurbila - docker clusters (solit 2015)
Artem Zhurbila - docker clusters (solit 2015)
Artem Zhurbila
 
Container & kubernetes
Container & kubernetesContainer & kubernetes
Container & kubernetes
Ted Jung
 
K8s vs Cloud Foundry
K8s vs Cloud FoundryK8s vs Cloud Foundry
K8s vs Cloud Foundry
Ivan Borshukov
 
Container Performance Analysis Brendan Gregg, Netflix
Container Performance Analysis Brendan Gregg, NetflixContainer Performance Analysis Brendan Gregg, Netflix
Container Performance Analysis Brendan Gregg, Netflix
Docker, Inc.
 
Container Performance Analysis
Container Performance AnalysisContainer Performance Analysis
Container Performance Analysis
Brendan Gregg
 
Docker Security Paradigm
Docker Security ParadigmDocker Security Paradigm
Docker Security Paradigm
Anis LARGUEM
 
Web scale infrastructures with kubernetes and flannel
Web scale infrastructures with kubernetes and flannelWeb scale infrastructures with kubernetes and flannel
Web scale infrastructures with kubernetes and flannel
purpleocean
 
Openstack meetup lyon_2017-09-28
Openstack meetup lyon_2017-09-28Openstack meetup lyon_2017-09-28
Openstack meetup lyon_2017-09-28
Xavier Lucas
 
Who is afraid of privileged containers ?
Who is afraid of privileged containers ?Who is afraid of privileged containers ?
Who is afraid of privileged containers ?
Marko Bevc
 
Dessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloudDessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloud
Massimiliano Dessì
 
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
Codemotion
 
containerD
containerDcontainerD
containerD
strikr .
 
Drupalcamp es 2013 drupal with lxc docker and vagrant
Drupalcamp es 2013  drupal with lxc docker and vagrant Drupalcamp es 2013  drupal with lxc docker and vagrant
Drupalcamp es 2013 drupal with lxc docker and vagrant
Ricardo Amaro
 
How Zalando runs Kubernetes clusters at scale on AWS - AWS re:Invent
How Zalando runs Kubernetes clusters at scale on AWS - AWS re:InventHow Zalando runs Kubernetes clusters at scale on AWS - AWS re:Invent
How Zalando runs Kubernetes clusters at scale on AWS - AWS re:Invent
Henning Jacobs
 

Similar to Devoxx France 2018 : Mes Applications en Production sur Kubernetes (20)

Kubernetes - Starting with 1.2
Kubernetes  - Starting with 1.2Kubernetes  - Starting with 1.2
Kubernetes - Starting with 1.2
 
K8s best practices from the field!
K8s best practices from the field!K8s best practices from the field!
K8s best practices from the field!
 
Lessons from running potentially malicious code inside containers
Lessons from running potentially malicious code inside containersLessons from running potentially malicious code inside containers
Lessons from running potentially malicious code inside containers
 
Kubernetes Architecture and Introduction – Paris Kubernetes Meetup
Kubernetes Architecture and Introduction – Paris Kubernetes MeetupKubernetes Architecture and Introduction – Paris Kubernetes Meetup
Kubernetes Architecture and Introduction – Paris Kubernetes Meetup
 
cache concepts and varnish-cache
cache concepts and varnish-cachecache concepts and varnish-cache
cache concepts and varnish-cache
 
网易云K8S应用实践 | practices for kubernetes cluster provisioning, management and ap...
网易云K8S应用实践 | practices for kubernetes cluster provisioning, management and ap...网易云K8S应用实践 | practices for kubernetes cluster provisioning, management and ap...
网易云K8S应用实践 | practices for kubernetes cluster provisioning, management and ap...
 
Artem Zhurbila - docker clusters (solit 2015)
Artem Zhurbila - docker clusters (solit 2015)Artem Zhurbila - docker clusters (solit 2015)
Artem Zhurbila - docker clusters (solit 2015)
 
Container & kubernetes
Container & kubernetesContainer & kubernetes
Container & kubernetes
 
K8s vs Cloud Foundry
K8s vs Cloud FoundryK8s vs Cloud Foundry
K8s vs Cloud Foundry
 
Container Performance Analysis Brendan Gregg, Netflix
Container Performance Analysis Brendan Gregg, NetflixContainer Performance Analysis Brendan Gregg, Netflix
Container Performance Analysis Brendan Gregg, Netflix
 
Container Performance Analysis
Container Performance AnalysisContainer Performance Analysis
Container Performance Analysis
 
Docker Security Paradigm
Docker Security ParadigmDocker Security Paradigm
Docker Security Paradigm
 
Web scale infrastructures with kubernetes and flannel
Web scale infrastructures with kubernetes and flannelWeb scale infrastructures with kubernetes and flannel
Web scale infrastructures with kubernetes and flannel
 
Openstack meetup lyon_2017-09-28
Openstack meetup lyon_2017-09-28Openstack meetup lyon_2017-09-28
Openstack meetup lyon_2017-09-28
 
Who is afraid of privileged containers ?
Who is afraid of privileged containers ?Who is afraid of privileged containers ?
Who is afraid of privileged containers ?
 
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
 
containerD
containerDcontainerD
containerD
 
Drupalcamp es 2013 drupal with lxc docker and vagrant
Drupalcamp es 2013  drupal with lxc docker and vagrant Drupalcamp es 2013  drupal with lxc docker and vagrant
Drupalcamp es 2013 drupal with lxc docker and vagrant
 
How Zalando runs Kubernetes clusters at scale on AWS - AWS re:Invent
How Zalando runs Kubernetes clusters at scale on AWS - AWS re:InventHow Zalando runs Kubernetes clusters at scale on AWS - AWS re:Invent
How Zalando runs Kubernetes clusters at scale on AWS - AWS re:Invent
 

Recently uploaded

Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Pitangent Analytics & Technology Solutions Pvt. Ltd
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
Ajin Abraham
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
Ivo Velitchkov
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Neo4j
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
Safe Software
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
saastr
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
BibashShahi
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
Fwdays
 

Recently uploaded (20)

Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
 

Devoxx France 2018 : Mes Applications en Production sur Kubernetes

  • 1. #DevoxxFR Devoxx France 2018 Mes Applications en Production sur Kubernetes Michael Morello @barkbay
  • 2. #DevoxxFR About me MICHAEL MORELLO deploy, manage, maintain { , } Kubernetes @ }, GO , } developer
  • 3. #DevoxxFR Kubernetes ? •C’est un « cluster manager » : K8S gère une flotte de machines (physiques ou virtuelles) •C’est un ensemble d’ «objets » : K8S permet de déclarer l’état attendu d’une application •Pilotable par API : Référence : https://kubernetes.io/docs/concepts/
  • 5. #DevoxxFR POD ? Interface réseau commune aux conteneurs Partage de système de fichiers Colocalisés sur un même serveur
  • 6. #DevoxxFR Un POD ? metadata: labels: app: lab-java spec: containers: - name: lab image: barkbay/k8s-app-lab:java-v0 ports: - containerPort: 8080 Une liste de conteneurs Quelques métadonnées
  • 7. #DevoxxFR A security context defines privilege and access control settings for a Pod or Container : • User ID • Linux Capabilities • SELinux labels • AllowPrivilegeEscalation Security context
  • 8. #DevoxxFR SecurityContext spec: securityContext: runAsNonRoot: true runAsUser: 1234 fsGroup: 2000 containers: - name: lab image: barkbay/k8s-app-lab:java-v0 securityContext: allowPrivilegeEscalation: false ports: - containerPort: 8080 SecurityContext PodSecurityContext
  • 9. #DevoxxFR « SCCs are objects that define a set of conditions that a pod must run with in order to be accepted into the system. » TL;DR : Les SCCs permettent d’appliquer un contexte de sécurité par défaut sur les PODs. PSP : Pod Security Policy is a cluster-level resource that controls security sensitive aspects of the pod specification. OU Un SecurityContext automatique ?
  • 10. #DevoxxFR Comprendre les SecurityContext, travailler avec vos OPS sur la mise en œuvre des PSP (ou utilisez Openshift) SELinux : "Every time you run setenforce 0, you make Dan Walsh weep. Dan is a nice guy and he certainly doesn't deserve that. » Utiliser des namespaces dédiés Utiliser des ServiceAccount : des comptes techniques qui vous permettront de jouer avec les RBAC Quelle sécurité pour les flux applicatifs ? TLS de bout en bout ? Security takeaway
  • 12. #DevoxxFR Multi-tenant : Share Cpu and memory spec: securityContext: runAsNonRoot: true runAsUser: 1000 fsGroup: 2000 containers: - name: lab image: barkbay/k8s-app-lab:java-v0 resources: requests: memory: "128Mi" cpu: "500m" limits: memory: "192Mi" cpu: "2" securityContext: allowPrivilegeEscalation: false ports: - containerPort: 8080 Limits control the maximum amount of resources that the container may use The scheduler uses resources requests to find a node with an appropriate fit for all containers in a POD.
  • 13. #DevoxxFR Multi-tenant : Share Cpu and memory containers: - name: lab image: barkbay/k8s-app-lab:java-v0 resources: requests: memory: "128Mi" cpu: "500m" limits: memory: "192Mi" cpu: "2" « Converted to its millicore value and multiplied by 100. The resulting value is the total amount of CPU time that a container can use every 100ms. A container cannot use more than its share of CPU time during this interval. » On appelle ça faire du Throttling
  • 14. #DevoxxFR Multi-tenant : Share Cpu and memory containers: - name: lab image: barkbay/k8s-app-lab:java-v0 resources: requests: memory: "128Mi" cpu: "500m" limits: memory: "192Mi" cpu: "2" "GC task thread#0 (ParallelGC)" […] runnable "GC task thread#1 (ParallelGC)" […] runnable "GC task thread#2 (ParallelGC)" […] runnable "GC task thread#3 (ParallelGC)" […] runnable Tuning automatique de la JVM Runtime.getRuntime() .availableProcessors() = 4
  • 15. #DevoxxFR Multi-tenant : Share Cpu and memory containers: - name: lab image: barkbay/k8s-app-lab:java-v0 resources: requests: memory: "128Mi" cpu: "500m" limits: memory: "192Mi" cpu: "2" $ cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us 200000 $ cat /sys/fs/cgroup/cpu/cpu.cfs_period_us 100000 $ expr 200000 / 100000 2 <= ~= 2 CPUs disponibles -XX:ParallelGCThreads=2 -XX:ConcGCThreads=2 -Djava.util.concurrent.ForkJoinPool.common.parallelism=2 -XX:CICompilerCount=2 Java 8 -XX:ActiveProcessorCount=2 https://docs.oracle.com/javase/10/tools/java.htm Java 10
  • 16. #DevoxxFR Monitoring CPU cgroup $ cat /sys/fs/cgroup/cpu/cpu.stat user 1637 system 88 nr_periods 520 nr_throttled 364 : number of times tasks in a cgroup have been throttled throttled_time 72988838516 : the total time duration (in nanoseconds) for which tasks in a cgroup have been throttled. 1
  • 17. #DevoxxFR Memory cgroup PAGE CACHE FREE RECLAIMABLE MEMORY CGROUP MANAGED MEMORY Java Virtual Machine HEAP Native Memory USED
  • 18. #DevoxxFR Memory cgroup PAGE CACHE FREE RECLAIMABLE MEMORY CGROUP MANAGED MEMORY Java Virtual Machine HEAP Native Memory USED
  • 19. #DevoxxFR Memory cgroup F R E E RECLAIMABLE MEMORY ? CGROUP MANAGED MEMORY Java Virtual Machine HEAP Native Memory USED
  • 20. #DevoxxFR OOM-KILLER In Action java invoked oom-killer: gfp_mask=0xd0, order=0, oom_score_adj=872 […] memory: usage 196608kB, limit 196608kB, failcnt 1953 […] [ pid ] uid tgid total_vm rss nr_ptes swapents oom_score_adj name [25616] 1000 25616 254 1 4 0 -998 pause [25687] 1000 25687 678075 48764 165 0 872 java Memory cgroup out of memory: Kill process 25908 (java) score 1864 or sacrifice child Killed process 25687 (java) total-vm:2712300kB, anon-rss:191448kB, file- rss:3520kB, shmem-rss:0kB The failcnt field gives the number of times that the cgroup limit was exceeded. limits: memory: "192Mi"
  • 21. #DevoxxFR Avoid OOM-Killer with Java 8 $ # Dans le conteneur $ cat /sys/fs/cgroup/memory/memory.limit_in_bytes 402653184 #384Mo max $ # A vous de calculer le Xmx qui va bien ou -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap
  • 23. #DevoxxFR Métriques ? container_cpu_cfs_throttled_seconds_total{container_name="foo"} 1027 1395066363000 Metric name Label Value Timestamp GET /metrics HTTP/1.0 PROMETHEUS
  • 25. #DevoxxFR Fin de l’Interlude « Collectons les Métriques »
  • 26. #DevoxxFR Monitoring containers limits • container_cpu_cfs_throttled_periods_total • container_cpu_cfs_throttled_seconds_total • container_memory_failcnt
  • 27. #DevoxxFR Monitoring your own metrics kind: Service apiVersion: v1 metadata: name: lab-java-service annotations: prometheus.io/scrape: "true" spec: selector: app: lab-java ports: - protocol: TCP port: 80 targetPort: 8080 + endpoint_hello_total{status="get",} 1606.0 Implement call to /metrics :
  • 28. #DevoxxFR HPA : Horizontal Pod Autoscaler COREAPICustomMetricAPI API POD de Mediation scale up !H.P.A. PROMETHEUS /metrics POD POD POD GET /apis/custom.metrics.k8s.io/[…]/lab-java-service/endpoint_hello 42
  • 29. #DevoxxFR Is it alive ? spec: containers: - name: lab image: barkbay/k8s-app-lab:java-v0 livenessProbe: httpGet: path: /hello port: 8080 readinessProbe: httpGet: path: /hello port: 8080 initialDelaySeconds: 5 periodSeconds: 2 ports: - containerPort: 8080 Ouvrir les flux ? Redémarrer le conteneur ?
  • 30. #DevoxxFR Is it alive ? spec: containers: - name: lab image: barkbay/k8s-app-lab:java-v0 livenessProbe: tcpSocket: port: 8080 readinessProbe: tcpSocket: port: 8080 initialDelaySeconds: 5 periodSeconds: 2 ports: - containerPort: 8080 Ouvrir les flux ? Redémarrer le conteneur ?
  • 31. #DevoxxFR Pod Disruption Budget (a.k.a. PDB) En cas de "disruption" "volontaire" permet de maintenir un nombre minimum d’instances. apiVersion: policy/v1beta1 kind: PodDisruptionBudget metadata: name: lab-java-pdb spec: minAvailable: 1 selector: matchLabels: app: lab-java
  • 32. #DevoxxFR Takeaway •Security first •Exposer des métriques •Collecter des métriques •Surveiller : •cgroups : memory and cpu •application restarts •events dans les namespaces •Implementer des tests Liveness and Readiness simples
  • 33. #DevoxxFR Merci / Thank you Code source de l’application : https://github.com/barkbay/k8s-app-lab/
  • 34. #DevoxxFR We love picture We try to keep the Devox France logo and the Tweet hashtag on all slides 3

Editor's Notes

  1. A revoir, « sensation » d’opposition..