August 2015 - Presented at LinuxCon and ContainerCon
Demos:
1) NGINX Web Cluster with Local Storage
2) Hot Upgrade/Deploy of an NGINX Web Cluster with Shared Storage (GlusterFS)
3) MySQL with Block Storage (Ceph RBD)
4) Apache Spark in Kubernetes with Shared Storage
3. @wattsteve
Kubernetes Cluster
Kubernetes Architectural Overview
Kubernetes Master Server(s)Kubernetes Master Server(s)
Linux Server(s)
etcd API Server
Controller Manager
Kubernetes NodeKubernetes Node
Linux Server
KubeletDocker
Kubernetes Proxy
Kubernetes NodeKubernetes Node
Linux Server
KubeletDocker
Kubernetes Proxy
Kubernetes NodeKubernetes Node
Linux Server
KubeletDocker
Kubernetes Proxy
Scheduler
4. @wattsteve
Installing Kubernetes
• Hosted Services: Google Compute Engine
• Support for a wide variety of Infrastructure (Azure,
Rackspace, vSphere, AWS)
• Support for several OS’ (RHEL, CentOS, Fedora,
Debian, Ubuntu, Atomic, CoreOS)
• Local but automated (Vagrant/Ansible) * Magic *
• Local but manual (Fedora) * What I use *
5. @wattsteve
What do you need to know to get started?
Pods
-Pods describe a tightly coupled group of containers that typically need to be deployed on the
same server because they share resources.
-Pods are described in Pod Files which also articulate what shared resources the containers in the
Pod require. An example of a Shared Resource is a Kubernetes Volume
-Pods are deployed on Kubernetes Nodes.
Labels
-Pods describe a tightly coupled group of containers that typically need to be deployed on the
same server because they share resources.
Services
-Pods and containers will die and get scheduled on different machines. Services provide you with
the ability to have a consistent, known endpoint for your pod that stays the same, regardless of
where your pod is moved to.
Replication Controllers (RCs)
-Replication Controllers are used to scale out Pods.
-RCs produce identical instances of pods that correspond to a replica count that has been set.
-Services will route requests between multiple instances of the same Pod.
Volumes
-Allow you to mount Local and Network Storage Systems to the containers with your Pods.
7. @wattsteve
Kubernetes Node 1Kubernetes Node 1
Kubernetes Cluster
NGINX Pod
NGINX ContainerNGINX Container
Kubernetes Node 2Kubernetes Node 2
NGINX Pod
Example 1 – Build a Scalable Web Application with Local Storage
Kubernetes MasterKubernetes Master
Browser
Request
Browser
Request
NGINX ServiceNGINX Service
NGINX RCNGINX RC
NGINX ContainerNGINX Container
8. @wattsteve
Kubernetes MasterKubernetes Master
Kubernetes Node 1Kubernetes Node 1
Kubernetes Cluster
NGINX Pod
NGINX ContainerNGINX Container
Browser
Request
Browser
Request
Kubernetes Node 2Kubernetes Node 2
MySQL Pod
Example 2 – Then use Labels to Hot “Upgrade” to Shared Storage
NGINX ContainerNGINX Container
NGINX ServiceNGINX Service
NGINX RCNGINX RC
9. @wattsteve
Kubernetes Node 1Kubernetes Node 1
Kubernetes Cluster
NGINX Pod
NGINX ContainerNGINX Container
Kubernetes Node 2Kubernetes Node 2
MySQL Pod
MySQL ContainerMySQL Container
Example 3 – Now lets add a Database
RBD
Network
Disk
RBD
Network
Disk
Kubernetes MasterKubernetes Master
Browser
Request
Browser
Request
NGINX ServiceNGINX Service
NGINX RCNGINX RC
10. @wattsteve
Kubernetes MasterKubernetes Master
Kubernetes Node 1Kubernetes Node 1
Kubernetes Cluster
Spark Worker Pod
Spark Worker ContainerSpark Worker Container
Terminal
Or
Zeppelin
Terminal
Or
Zeppelin
Kubernetes Node 2Kubernetes Node 2
Spark Worker Pod
Example 4 – Deploy Apache Spark to Analyze your data
Spark Worker ContainerSpark Worker Container
Spark Master ServiceSpark Master Service
Spark Worker RCSpark Worker RC
Spark Master Pod
Spark Master ContainerSpark Master Container
11. @wattsteve
Kubernetes MasterKubernetes Master
Kubernetes Node 1Kubernetes Node 1
Kubernetes Cluster
GlusterFS Pod
GlusterFS ContainerGlusterFS Container
Browser
Request
Browser
Request
Kubernetes Node 2Kubernetes Node 2
GlusterFS Pod
Example 5 – Deploying Storage Platforms in Kubernetes
GlusterFS ContainerGlusterFS Container
NGINX ServiceNGINX Service
NGINX RCNGINX RC
Kubernetes Node 3Kubernetes Node 3
NGINX Pod
NGINX ContainerNGINX Container
Mount
Hi I’m Steve Watt from Red Hat ET. I am one of Red Hat’s Kubernetes Contributors. I’m going to be presenting on “Building Clustered Applications…”
Kubernetes is a very fast moving project and it can feel a bit overwhelming for new folks, so my motivation for this talk is for you to leave here knowing how to use Kubernetes to Deploy and Manage your Containerized Applications. This talk won’t cover how Kubernetes is different from the other projects in the Container Orchestration and Management space
To achieve this, I have 4-5 slides on what you need to know about Kubernetes, but the rest of the presentation is focused on various walkthroughs of different types of applications. Hopefully you are able to stitch together what you see to build your own application.
But first,
Who here has deployed Kubernetes?
Who here has submitted a Kubernetes Pod before?
My favorite example of the advantage that Kubernetes provides is if we contrast containers in Scale Up and Scale Out Architectures:
Scale Up – Easy: Fairly trivial to launch and manage images on just a few servers.
Scale Out – Hard: Too much to track when you have images across 400+ nodes on commodity hardware
So we clearly lack an elegant solution Orchestrating and Managing clusters of containers.
Kubernetes provides a DECLARATIVE framework for you to describe your Application and the Images it needs and its dependencies as a Pod file
You submit it and Kubernetes handles the deployment and availability for you
Firstly, Kubernetes is a Master / Worker Architecture that runs on Linux and is written in Go.
You don’t have to know anything about Go to use it. You do need to be familiar terminals, JSON and YAML though.
So lets go through the processes on the Master and Worker Nodes.
Kube Master Server
Etcd - Distributed Key/Value Store that the API Server uses to persist configuration information.
Kube API Server - RESTful and Command Line interface. Handles the Creation of Objects.
Scheduler – ensures Pods are scheduled. Can apply scheduling policies.
Kube Controller Manager = Ensures Pod Replication Policies are implemented consistently.
Kube Node –
Kube Proxy -Network Proxy for Containers and Service Endpoints.
Kubelet - Provisions the resources in the Pods provided it. Interacts with Docker to launch containers
Kubernetes can be deployed on a whole host of Cloud Providers. GCE is a Service, the rest is IaaS.
Its up to you which one you use. When I’m new I like to setup things manually so I can understand how it works together.
But, if you feel that is too complex then you should check out Kubernetes-Ansible. The Author, Eric Paris is presenting on Wednesday. You should go to his session!
These are the 5 Key things, you have to know in order to build applications within Kubernetes.
So it sounds good in theory, lets check it out in practice. We’re going to build a scale out containerized web application using NGINX.
We are going to build a layered application. So we’ll start small and then build up.
Think Standalone EC2
Show Single Pod – CAT and RUN
Show RC – CAT and RUN
Show Service – CAT and RUN
Get Pods, Describe Pods
Lets check the finished result out with our client script simulating the request to the Services
LEAVE Client Script RUNNING
Think EC2 with EFS
Show ENDPOINTS - CAT
Show RC – CAT and RUN
Lets check the finished result out with our client script simulating the request to the Services
kubectl scale --replicas=0 rc nginx-local-controller
Think EC2 with EBS
Show how to create an RBD and make it available and then connect to it from MySQL.
rbd create demo -s 1024
rbd list
rbd map demo --pool rbd --name client.admin
ls -l /dev/rbd?
mkfs.ext4 /dev/rbd0
rbd unmap /dev/rbd0
CAT and RUN MySQL Pod. Explain RBD Block Device.
DESCRIBE Pod
Docker exec MySQL container
MySQL> use us_states;
MySQL> select * from states;
GET Endpoints - Discuss that we’ll be using the GlusterFS Plugin again which means the endpoints will be needed
CAT and SUBMIT the Spark Master Pod
CAT and SUBMIT the Spark Master Service Pod
SHOW the Spark Master in the BROWSER
CAT and SUBMIT the Spark Worker RC
SHOW the Spark Master in the BROWSER