javacro'15 - docker, kubernetes and jube - a new cloud architecture - aleš justin, marko...
Upload: hujak-hrvatska-udruga-java-korisnika-croatian-java-user-association
Post on 21-Jul-2015
391 views
TRANSCRIPT
![Page 1: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/1.jpg)
Docker, Kubernetes & JubeBuild, containerize & orchestrate
Marko Lukša & Aleš Justin, Red [email protected]@redhat.com
![Page 2: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/2.jpg)
Docker● Platform for building, distributing and running
applications● Lightweight container “virtualization”● 10s of VMs => 100s, 1000s of containers per host
![Page 3: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/3.jpg)
Docker concepts● Images
○ A read-only package of an app & environment○ Consists of Layers (some layers shared by images)
● Registries○ Pull images from & push images to registry○ Private & public registries (Docker Hub)
● Containers○ A running image (“Process in a box”)○ Read-Write layer on top of base image
![Page 4: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/4.jpg)
Docker layers
![Page 5: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/5.jpg)
Creating Docker images● Use existing image (e.g. fedora, jboss/wildfly)● Run a command (anything, even a shell)
○ Docker creates a new container from image○ Allocates a read-write layer on top of image○ Executes the command
● Run additional commands● Look up last container id● Commit the container as new image
![Page 6: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/6.jpg)
Dockerfile● Build an image automatically● Specifies base image and instructions:
○ FROM <existing image>○ ADD <local file> <path inside image>○ RUN <cmd>○ EXPOSE <port>○ ENV <name> <value>○ CMD <cmd>
![Page 7: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/7.jpg)
Dockerfile - example# Use latest jboss/base-jdk:7 image as the baseFROM jboss/base-jdk:7
# Set the WILDFLY_VERSION env variableENV WILDFLY_VERSION 8.2.0.Final
# Add the WildFly distribution to /optRUN cd $HOME && curl http://download.jboss.org/wildfly/$WILDFLY_VERSION/wildfly-$WILDFLY_VERSION.tar.gz | tar zx && mv $HOME/wildfly-$WILDFLY_VERSION $HOME/wildfly
# Set the JBOSS_HOME env variableENV JBOSS_HOME /opt/jboss/wildfly
# Expose the ports we're interested inEXPOSE 8080 9990
# Set the default command to run on bootCMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0"]
![Page 8: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/8.jpg)
Kubernetes● Orchestration system for Docker containers● Provides basic mechanisms for:
○ deployment○ maintenance○ scaling
● Auto-restarting, re-scheduling & replicating containers
![Page 9: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/9.jpg)
Kubernetes architecture● Master node
○ etcd (distributed key value store)○ Kubernetes API Server (REST) (+ Scheduler)○ Kubernetes Controller Manager Server
● Minions○ Docker○ Kubelet○ Kubernetes Proxy
![Page 10: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/10.jpg)
Kubernetes concepts● Pods● Volumes● Labels● Replication controllers● Services
![Page 11: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/11.jpg)
apiVersion: v1beta1
id: www
desiredState:
manifest:
version: v1beta1
id: X
containers:
- name: nginx
image: dockerfile/nginx
- name: mydb
image: foo/mycooldb
Pods
Minion (Host) 1
A
Pod X
B
![Page 12: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/12.jpg)
● Resource sharing & communication
● Not fully isolated● Scheduled to a node● Containers are auto-
restarted● If a node dies, its
pods are deleted (not rescheduled)
Pods (continued)
Minion (Host) 1
A
Pod X
B
![Page 13: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/13.jpg)
desiredState: manifest:
containers:
- name: A
image: foo/A
volumeMounts:
- name: vol1
mountPath: /data/vol1
volumes:
- name: vol1
source:
emptyDir: {}
Or:
hostDir: /opt/data/vol1
Volumes
Minion (Host) 1
A
Pod X
BVol 1
![Page 14: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/14.jpg)
● key-value pairs● for categorizing things“env”:”dev”, “env”:”prod”, “env”:”qa”
“rel”:”stable”, “rel”:”canary”
“partition”:”custA”, “partition”:”custB”
● label selectors
Labels
Minion (Host) 1
A
Pod X
BVol 1
“name”: “podX”,“env”: “dev”
![Page 15: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/15.jpg)
id: replicationControllerY
kind: ReplicationController
desiredState:
replicas: 2
replicaSelector:
env: prod
rel: stable
podTemplate:
desiredState:
manifest:
...
labels:
- env: prod
- rel: stable
Replication controllers
Minion (Host) 1
A
Pod X
Minion 2
Replication controller Y(replicas: 2, podTemplate, replicaSelector:
{“env”:”prod”, “rel”:”stable”})
BVol 1
“name”: “podX”,“env”: “dev”
C
D
Pod Y1
“env”: “prod”,“rel”: “stable”
C
D
Pod Y2
“env”: “prod”,“rel”: “stable”
![Page 16: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/16.jpg)
id: myApp
kind: Service
apiVersion: v1beta1
port: 1234
selector:
env: prod
containerPort: 2345
Services
Minion (Host) 1
A
Pod X
Minion 2
Replication controller Y(replicas: 2, podTemplate, replicaSelector:
{“env”:”prod”, “rel”:”stable”})
BVol 1
“name”: “podX”,“env”: “dev”
C
D
Pod Y1
“env”: “prod”,“rel”: “stable”
C
D
Pod Y2
“env”: “prod”,“rel”: “stable”
myApp (selector: {env:prod})
● Env vars: MYAPP_SERVICE_HOST, MYAPP_SERVICE_PORT
● future: DNS
![Page 17: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/17.jpg)
● New replication controller (rel:canary)
● stable controller: replicas--
● canary controller:replicas++
Canary releases
Minion (Host) 1
A
Pod X
Minion 2
Replication controller Y(replicas: 1, podTemplate, replicaSelector:
{“env”:”prod”, “rel”:”stable”})
BVol 1
“name”: “podX”,“env”: “dev”
Replication controller Y’ (replicas: 1, podTemplate, replicaSelector:
{“env”:”prod”, “rel”:”canary”})
C
D
Pod Y1
“env”: “prod”,“rel”: “stable”
myApp (selector: {env:prod})
“env”: “prod”,“rel”: “stable”
C
D
Pod Y2
C’
D’
Pod Y’1
“env”: “prod”,“rel”: “canary”
![Page 18: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/18.jpg)
● labels of a running pod can be changed
● way of adding or removing pods from services or replication controllers
Debug pods
Minion (Host) 1
A
Pod X
Minion 2
Replication controller Y(replicas: 2, podTemplate, replicaSelector: {“env”:”prod”, “rel”:”stable”})
BVol 1
“name”: “podX”,“env”: “dev”
C
D
Pod Y1
“env”: “prod”,“rel”: “stable”
myApp (selector: {env:prod})
“env”: “prod”,“rel”: “stable”
C
D
Pod Y2
C
D
Pod Y3
“env”: “prod”,“rel”: “stable”
“env”: “debug”,“rel”: “stable”
![Page 19: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/19.jpg)
OpenShift v3● Platform-As-A-Service● Kubernetes extensions
○ Application Templates■ Single JSON file for configuring Kube resources■ Parameterizable (see example)
○ Builds■ Hosts source code in git repos■ Performs builds and hosts private docker images■ Kick off new builds on git-push
![Page 20: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/20.jpg)
OpenShift v3 - Fabric8● Fabric8 v2
○ Aggregate logging■ LogSpout, LogStash, Fluentd, Elastic, Kibana
○ Aggregate metrics■ kAdvisor, InfluxDB, Grafana
○ Auto-scaling■ Should be in K8s …■ AScaler
![Page 21: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/21.jpg)
OpenShift v3 - EAP● EAP
○ KubePing○ CE Arquillian
![Page 22: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/22.jpg)
What is Jube?● Issues ...
○ I’m not using Linux■ env switching pita
○ I want to debug my app■ local vs. remote
○ Everything is a Docker image■ I just want to use my (Java) app
![Page 23: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/23.jpg)
What is Jube?● Solution?
○ Java based Kubernetes mock○ It’s all about Kubernetes REST API
■ And similar Kubernetes-like behavior● Replication, master election, ...
● Where is Docker?○ Nope, no Docker here
■ Zip images■ Lifecycle scripts
![Page 24: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/24.jpg)
Demo (ping us after presentation ;-)● Jube● Fabric8● Hawtio● WildFly● Cluster● Hello servlet
![Page 25: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/25.jpg)
Resources● https://github.com/jubeio/jube● http://fabric8.io/● https://github.com/hawtio/hawtio● http://www.wildfly.org
![Page 26: JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Justin, Marko Lukša](https://reader034.vdocuments.mx/reader034/viewer/2022052401/55ae618e1a28ab30798b4661/html5/thumbnails/26.jpg)
Resources● https://www.docker.com/● https://www.docker.com/tryit/● https://registry.hub.docker.com/
● http://kubernetes.io/● https://github.com/GoogleCloudPlatform/kubernetes● https://godoc.org/github.com/GoogleCloudPlatform/kubernetes/pkg/api
● https://github.com/openshift/origin● https://blog.openshift.com/openshift-v3-deep-dive-docker-kubernetes/