Kubernetes for Java Developers
- 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
- 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
- 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
- 36. @rafabene / @yanaga
Lab infrastructure
Hypervisor
RHEL VM Image
● OpenShift
● Kubernetes
● Docker
Container Development Kit
http://developers.redhat.com/products/cdk/download/