SlideShare a Scribd company logo
1
Kubernetes Introduction
Rafael Benevides & Edson Yanaga
benevides@redhat.com / yanaga@redhat.com
@rafabene / @yanaga
http://bit.ly/kubernetes-intro
Rafael Benevides
Director of Developer Experience at Red Hat
Apache DeltaSpike P.M.C
benevides@redhat.com
@rafabene
Java Certifications:
SCJA / SCJP / SCWCD / SCBCD / SCEA
JBoss Certifications:
JBCD / JBCAA
Red Hat Certifications:
OpenShift / Containers / Ansible
Other Certifications:
SAP Netweaver / ITIL / IBM Software Quality
Edson Yanaga
Director of Developer Experience at Red Hat
yanaga@redhat.com
@yanaga
Java Champion
Microsoft MVP
developers.redhat.com
http://developers.redhat.comhttp://developers.redhat.com
@rafabene / @yanaga
Why do you want to run your application inside containers?
@rafabene / @yanaga
● Lightweight footprint and minimal overhead,
● Portability across machines,
● Simplify DevOps practices,
● Speeds up Continuous Integration,
● Empower Microservices Architectures.
● Isolation
Container
Advantages
Container Engine
@rafabene / @yanaga
A way to run a Linux container:
$ docker run -d <image-name>
A single and isolated Linux process
running in a single machine
@rafabene / @yanaga
DevOps challenges for multiple containers
● How to scale?
● How to avoid port conflicts?
● How to manage them in multiple
hosts?
● What happens if a host has a
trouble?
● How to keep them running?
● How to update them?
● Where are my containers?
Node Node
Logger
Node
Node Node Node
@rafabene / @yanaga
Greek for “Helmsman”; also the root of the word
“Governor” (from latin: gubernator)
● Container orchestrator
● Supports multiple cloud and bare-metal environments
● Inspired by Google’s experience with containers
● Open source, written in Go
Manage applications, not machines
Meet Kubernetes
@rafabene / @yanaga
Version 1.3
Hosted on GitHub
800+ contributors
34,000+ commits
16,000+ GitHub stars
Red Hat
HP
IBM
Mesosphere
Microsoft
Project Partners
CoreOS
Pivotal
SaltStack
VMWare
http://kubernetes.io/
https://github.com/kubernetes/kubernetes
Open Source community
Master
API Server
Service Layer
VirtualPhysical Private Public
Persistent
Storage
Node Node
Logger
Node
Node Node Node
Dev
Ops
SCM
(Git/Svn)
CI/CD
Automation
Routing Layer
Registry
SDN Overlay Network
Controllers
- Scheduler
- Replication
- Services
- Builds
- Routes
- Deployment
Kubernetes
OpenShift
- Deployments
- Builds
- ImageStreams
@rafabene developers.redhat.com
Kubernetes Concepts
Pod Replication
Controller
Service Label
One or More Containers
Shared IP
Shared Storage Volume
Shared Resources
Shared Lifecycle
Ensures that a specified
number of pod replicas are
running at any one time
Grouping of pods, act as
one, has stable virtual IP
and DNS name
Key/Value pairs associated
with Kubernetes objects
(e.g. env=production)
@rafabene / @yanaga
Concept: Pod
● Group of containers
● Live and die together
● Share:
○ IP
○ Secrets
○ Labels *
○ Volumes *
* we will talk about these concepts later
Labels
Application
Administrative
console
Log collector
IP: 10.x.x.x
Volume
@rafabene / @yanaga
Concept: POD
Defining a POD as YAML:
apiVersion: v1
kind: Pod
metadata:
name: myPod
labels:
key: value
spec:
containers:
- name: mysql
image: username/image
- name: phpMyAdmin
image: username/image2
key: value
myPOD
mysql
phpMy..
SCM
(Git/Svn)
Master
API Server
Service Layer
VirtualPhysical Private Public
Persistent
Storage
Node Node
Logger
Node
Node Node Node
Dev
Ops
CI/CD
Automation
Routing Layer
Registry
SDN Overlay Network
Controllers
- Scheduler
- Replication
- Services
- Builds
- Routes
- Deployment
Kubernetes
OpenShift
- Deployments
- Builds
- ImageStreams
SCM
(Git/Svn)
Master
API Server
Service Layer
VirtualPhysical Private Public
Persistent
Storage
Node Node
Logger
Node
Node Node Node
Dev
Ops
CI/CD
Automation
Routing Layer
Registry
SDN Overlay Network
Controllers
- Scheduler
- Replication
- Services
- Builds
- Routes
- Deployment
Kubernetes
OpenShift
- Deployments
- Builds
- ImageStreams
SCM
(Git/Svn)
Master
API Server
Service Layer
VirtualPhysical Private Public
Persistent
Storage
Node Node
Logger
Node
Node Node Node
Dev
Ops
CI/CD
Automation
Routing Layer
Registry
SDN Overlay Network
Controllers
- Scheduler
- Replication
- Services
- Builds
- Routes
- Deployment
Kubernetes
OpenShift
- Deployments
- Builds
- ImageStreams
@rafabene / @yanaga
Concept: Replication Controllers
Defining a Replication Controller as YAML:
apiVersion: v1
kind: Pod
metadata:
name: myPod
labels:
key: value
spec:
containers:
- name: myPod
image: username/image
ports:
- name: http
containerPort: 8080
apiVersion: v1
kind: ReplicationController
metadata:
name: myRC
spec:
replicas: 4
template:
metadata:
spec:
@rafabene / @yanaga
Concept: Labels
App: Cool
Env: Dev
Version: 1.0
App: Cool
Env: Prod
Version: 1.0
App: Cool
Env: Dev
Version: 2.0
App: Cool
Env: Prod
Version: 2.0
Everything in Kubernetes can
have a label
Node
Logger
Node
NodeNode
@rafabene / @yanaga
Concept: Labels
App: Cool
Env: Dev
Version: 1.0
App: Cool
Env: Prod
Version: 1.0
App: Cool
Env: Dev
Version: 2.0
App: Cool
Env: Prod
Version: 2.0
Node
Logger
Node
NodeNode
@rafabene / @yanaga
Concept: Labels
App: Cool
Env: Dev
Version: 1.0
App: Cool
Env: Prod
Version: 1.0
App: Cool
Env: Dev
Version: 2.0
App: Cool
Env: Prod
Version: 2.0
Node
Logger
Node
NodeNode
@rafabene / @yanaga
Concept: Labels
App: Cool
Env: Dev
Version: 1.0
App: Cool
Env: Prod
Version: 1.0
App: Cool
Env: Dev
Version: 2.0
App: Cool
Env: Prod
Version: 2.0
Node
Logger
Node
NodeNode
@rafabene / @yanaga
Concept: Labels
App: Cool
Env: Dev
Version: 1.0
App: Cool
Env: Prod
Version: 1.0
App: Cool
Env: Dev
Version: 2.0
App: Cool
Env: Prod
Version: 2.0
Node
Logger
Node
NodeNode
@rafabene / @yanaga
Concept: Labels
App: Cool
Env: Dev
Version: 1.0
App: Cool
Env: Dev
Version: 2.0
App: Cool
Env: Prod
Version: 1.0
App: Cool
Env: Prod
Version: 2.0
Node
Logger
Node
NodeNode
@rafabene / @yanaga
Concept: Labels
metadata:
name: objectName
labels:
App: Cool
Env: Dev
Version: 1.0
Defining Labels as YAML:
(can be placed in any object metadata)
App: Cool
Env: Dev
Version: 1.0
@rafabene / @yanaga
Node 2
POD
App: Cool
Env: Prod
Version: 1.0
POD
Service
Labels selector:
● App=Cool
● Env=Prod
IP: 172.x.x.x
App: Nice
Env: Prod
Version: 1.0
Concept: Services
Node 1
POD
@rafabene / @yanaga
Concept: Services
apiVersion: v1
kind: Service
metadata:
name: myService
labels:
...
spec:
ports:
- port: 80
targetPort: 80
selector:
App: Cool
Env: Prod
Defining a Service as YAML:
myService
Labels selector:
● App=Cool
● Env=Prod
IP: 172.x.x.x
@rafabene / @yanaga
Using Environment variables:
Using internal DNS: $ ping mysql
Service discovery inside Kubernetes
@rafabene / @yanaga
Other concepts
Rolling updatesPersistent Volumes
@rafabene / @yanaga
Admin Owned
Users Owned
Persistent Volume
GCE PD AWS LB
NFS GlusterFS
Persistent Volume Claim
POD Volume
● Admin provisions them, Users claim them
● High-level abstraction
● Pods can mount PVCs as Volumes
Concept: Persistent Volumes
@rafabene / @yanaga
Deployment Concept: Rolling Updates
Pod
Replication
Controller
Pod Pod Pod
App: Cool
Version: 1.0
Version: 1.0
Replicas: 4
Backend
Replication
Controller
Version: 2.0
Replicas: 1
PodPod Pod Pod
App: Cool
Version: 2.0
Version: 1.0
Replicas: 3
Version: 2.0
Replicas: 2
Version: 1.0
Replicas: 2
Version: 2.0
Replicas: 3
Version: 1.0
Replicas: 1
Version: 2.0
Replicas: 4
@rafabene / @yanaga
Kubernetes lab
@rafabene / @yanaga
Application Overview
@rafabene / @yanaga
@rafabene / @yanaga
Hello World Service
- Greet
Guestbook Service
- Create
Guestbook Service -
Retrieve
@rafabene / @yanaga
Lab infrastructure
Hypervisor
RHEL VM Image
● OpenShift
● Kubernetes
● Docker
Container Development Kit
http://developers.redhat.com/products/cdk/download/
@rafabene / @yanaga
Kubernetes lab
VERY IMPORTANT
http://bit.ly/kubernetes-lab
Follow me on the Setup environment section!
developers.redhat.com
http://developers.redhat.comhttp://developers.redhat.com
@RAFABENE

More Related Content

Kubernetes for Java Developers

  • 1. 1 Kubernetes Introduction Rafael Benevides & Edson Yanaga benevides@redhat.com / yanaga@redhat.com @rafabene / @yanaga http://bit.ly/kubernetes-intro
  • 2. Rafael Benevides Director of Developer Experience at Red Hat Apache DeltaSpike P.M.C benevides@redhat.com @rafabene Java Certifications: SCJA / SCJP / SCWCD / SCBCD / SCEA JBoss Certifications: JBCD / JBCAA Red Hat Certifications: OpenShift / Containers / Ansible Other Certifications: SAP Netweaver / ITIL / IBM Software Quality
  • 3. Edson Yanaga Director of Developer Experience at Red Hat yanaga@redhat.com @yanaga Java Champion Microsoft MVP
  • 5. @rafabene / @yanaga Why do you want to run your application inside containers?
  • 6. @rafabene / @yanaga ● Lightweight footprint and minimal overhead, ● Portability across machines, ● Simplify DevOps practices, ● Speeds up Continuous Integration, ● Empower Microservices Architectures. ● Isolation Container Advantages Container Engine
  • 7. @rafabene / @yanaga A way to run a Linux container: $ docker run -d <image-name> A single and isolated Linux process running in a single machine
  • 8. @rafabene / @yanaga DevOps challenges for multiple containers ● How to scale? ● How to avoid port conflicts? ● How to manage them in multiple hosts? ● What happens if a host has a trouble? ● How to keep them running? ● How to update them? ● Where are my containers? Node Node Logger Node Node Node Node
  • 9. @rafabene / @yanaga Greek for “Helmsman”; also the root of the word “Governor” (from latin: gubernator) ● Container orchestrator ● Supports multiple cloud and bare-metal environments ● Inspired by Google’s experience with containers ● Open source, written in Go Manage applications, not machines Meet Kubernetes
  • 10. @rafabene / @yanaga Version 1.3 Hosted on GitHub 800+ contributors 34,000+ commits 16,000+ GitHub stars Red Hat HP IBM Mesosphere Microsoft Project Partners CoreOS Pivotal SaltStack VMWare http://kubernetes.io/ https://github.com/kubernetes/kubernetes Open Source community
  • 11. Master API Server Service Layer VirtualPhysical Private Public Persistent Storage Node Node Logger Node Node Node Node Dev Ops SCM (Git/Svn) CI/CD Automation Routing Layer Registry SDN Overlay Network Controllers - Scheduler - Replication - Services - Builds - Routes - Deployment Kubernetes OpenShift - Deployments - Builds - ImageStreams
  • 12. @rafabene developers.redhat.com Kubernetes Concepts Pod Replication Controller Service Label One or More Containers Shared IP Shared Storage Volume Shared Resources Shared Lifecycle Ensures that a specified number of pod replicas are running at any one time Grouping of pods, act as one, has stable virtual IP and DNS name Key/Value pairs associated with Kubernetes objects (e.g. env=production)
  • 13. @rafabene / @yanaga Concept: Pod ● Group of containers ● Live and die together ● Share: ○ IP ○ Secrets ○ Labels * ○ Volumes * * we will talk about these concepts later Labels Application Administrative console Log collector IP: 10.x.x.x Volume
  • 14. @rafabene / @yanaga Concept: POD Defining a POD as YAML: apiVersion: v1 kind: Pod metadata: name: myPod labels: key: value spec: containers: - name: mysql image: username/image - name: phpMyAdmin image: username/image2 key: value myPOD mysql phpMy..
  • 15. SCM (Git/Svn) Master API Server Service Layer VirtualPhysical Private Public Persistent Storage Node Node Logger Node Node Node Node Dev Ops CI/CD Automation Routing Layer Registry SDN Overlay Network Controllers - Scheduler - Replication - Services - Builds - Routes - Deployment Kubernetes OpenShift - Deployments - Builds - ImageStreams
  • 16. SCM (Git/Svn) Master API Server Service Layer VirtualPhysical Private Public Persistent Storage Node Node Logger Node Node Node Node Dev Ops CI/CD Automation Routing Layer Registry SDN Overlay Network Controllers - Scheduler - Replication - Services - Builds - Routes - Deployment Kubernetes OpenShift - Deployments - Builds - ImageStreams
  • 17. SCM (Git/Svn) Master API Server Service Layer VirtualPhysical Private Public Persistent Storage Node Node Logger Node Node Node Node Dev Ops CI/CD Automation Routing Layer Registry SDN Overlay Network Controllers - Scheduler - Replication - Services - Builds - Routes - Deployment Kubernetes OpenShift - Deployments - Builds - ImageStreams
  • 18. @rafabene / @yanaga Concept: Replication Controllers Defining a Replication Controller as YAML: apiVersion: v1 kind: Pod metadata: name: myPod labels: key: value spec: containers: - name: myPod image: username/image ports: - name: http containerPort: 8080 apiVersion: v1 kind: ReplicationController metadata: name: myRC spec: replicas: 4 template: metadata: spec:
  • 19. @rafabene / @yanaga Concept: Labels App: Cool Env: Dev Version: 1.0 App: Cool Env: Prod Version: 1.0 App: Cool Env: Dev Version: 2.0 App: Cool Env: Prod Version: 2.0 Everything in Kubernetes can have a label Node Logger Node NodeNode
  • 20. @rafabene / @yanaga Concept: Labels App: Cool Env: Dev Version: 1.0 App: Cool Env: Prod Version: 1.0 App: Cool Env: Dev Version: 2.0 App: Cool Env: Prod Version: 2.0 Node Logger Node NodeNode
  • 21. @rafabene / @yanaga Concept: Labels App: Cool Env: Dev Version: 1.0 App: Cool Env: Prod Version: 1.0 App: Cool Env: Dev Version: 2.0 App: Cool Env: Prod Version: 2.0 Node Logger Node NodeNode
  • 22. @rafabene / @yanaga Concept: Labels App: Cool Env: Dev Version: 1.0 App: Cool Env: Prod Version: 1.0 App: Cool Env: Dev Version: 2.0 App: Cool Env: Prod Version: 2.0 Node Logger Node NodeNode
  • 23. @rafabene / @yanaga Concept: Labels App: Cool Env: Dev Version: 1.0 App: Cool Env: Prod Version: 1.0 App: Cool Env: Dev Version: 2.0 App: Cool Env: Prod Version: 2.0 Node Logger Node NodeNode
  • 24. @rafabene / @yanaga Concept: Labels App: Cool Env: Dev Version: 1.0 App: Cool Env: Dev Version: 2.0 App: Cool Env: Prod Version: 1.0 App: Cool Env: Prod Version: 2.0 Node Logger Node NodeNode
  • 25. @rafabene / @yanaga Concept: Labels metadata: name: objectName labels: App: Cool Env: Dev Version: 1.0 Defining Labels as YAML: (can be placed in any object metadata) App: Cool Env: Dev Version: 1.0
  • 26. @rafabene / @yanaga Node 2 POD App: Cool Env: Prod Version: 1.0 POD Service Labels selector: ● App=Cool ● Env=Prod IP: 172.x.x.x App: Nice Env: Prod Version: 1.0 Concept: Services Node 1 POD
  • 27. @rafabene / @yanaga Concept: Services apiVersion: v1 kind: Service metadata: name: myService labels: ... spec: ports: - port: 80 targetPort: 80 selector: App: Cool Env: Prod Defining a Service as YAML: myService Labels selector: ● App=Cool ● Env=Prod IP: 172.x.x.x
  • 28. @rafabene / @yanaga Using Environment variables: Using internal DNS: $ ping mysql Service discovery inside Kubernetes
  • 29. @rafabene / @yanaga Other concepts Rolling updatesPersistent Volumes
  • 30. @rafabene / @yanaga Admin Owned Users Owned Persistent Volume GCE PD AWS LB NFS GlusterFS Persistent Volume Claim POD Volume ● Admin provisions them, Users claim them ● High-level abstraction ● Pods can mount PVCs as Volumes Concept: Persistent Volumes
  • 31. @rafabene / @yanaga Deployment Concept: Rolling Updates Pod Replication Controller Pod Pod Pod App: Cool Version: 1.0 Version: 1.0 Replicas: 4 Backend Replication Controller Version: 2.0 Replicas: 1 PodPod Pod Pod App: Cool Version: 2.0 Version: 1.0 Replicas: 3 Version: 2.0 Replicas: 2 Version: 1.0 Replicas: 2 Version: 2.0 Replicas: 3 Version: 1.0 Replicas: 1 Version: 2.0 Replicas: 4
  • 35. @rafabene / @yanaga Hello World Service - Greet Guestbook Service - Create Guestbook Service - Retrieve
  • 36. @rafabene / @yanaga Lab infrastructure Hypervisor RHEL VM Image ● OpenShift ● Kubernetes ● Docker Container Development Kit http://developers.redhat.com/products/cdk/download/
  • 37. @rafabene / @yanaga Kubernetes lab VERY IMPORTANT http://bit.ly/kubernetes-lab Follow me on the Setup environment section!