Kubernetes - Sailing a Sea of Containers

Kel Cecil
Kel CecilSoftware Engineer at ListHub
KubernetesKubernetes
Sailing a Sea of ContainersSailing a Sea of Containers
Kel Cecil - @praisechaos
What is Kubernetes?What is Kubernetes?
Container Orchestration Toolset
Originated at Google (Borg)
Now a Cloud Native Computing Foundation project
Used in commercial and open source projects
Tectonic (CoreOS)
Meteor Galaxy (MeteorJS)
OpenShift 3 (Red Hat)
Kubernetes Scheduler for Deis (Engine Yard)
Why Kubernetes?Why Kubernetes?
Deploying one single container app is easy
Deploying a complex app is more difficult
One or more containers
Replicas of containers
Data volumes for persistent storage
Deploying lots of complex apps can be a challenge
FeaturesFeatures
Services for load balancing
Resource-based scheduling
Robust API
Great CLI tooling via kubectl
Container-spec agnostic
What does a simple Kubernetes cluster look like?
Master
Node Node Node
NodeNode
Physical or virtual machine on which containers can be
scheduled
What unit runs on the nodes?What unit runs on the nodes?
PodPod
A colocated set of application containers and shared data
volumes.
Smallest unit that can be scheduled.
Pod
container 1 container n
AWS EBS Volume GCE Volume
NFS Share Git Commit
Containers
Data Volumes
And more...
How can we organize podsHow can we organize pods
(or any other Kubernetes resource)?
LabelsLabels
Key-value pairs used to organize resources.
important-microservice
docker.io/kelcecil/app:latest
env=production
server=nginx
important-microservice
docker.io/kelcecil/app:feature
env=qa
server=nginx
Pods Nodes
172.17.8.102
hostname=172.17.8.102
rack=tatooine
172.17.8.103
hostname=172.17.8.103
rack=tatooine
172.17.8.104
hostname=172.17.8.104
rack=alderaan
Let's have replicas of pods...Let's have replicas of pods...
(There's a Kubernetes resource for that.)
Replication ControllerReplication Controller
Manages the lifecycle of pods by ensuring a desired
number of pods exist.
Replication Controller
replicas=2
selector: app=user-service
Pod
labels: app=user-service
Pod
labels: app=user-service
Pod
labels: app=user-service
How can we direct traffic to pods?How can we direct traffic to pods?
ServiceService
Provides a single, stable endpoint for a set of pods.
Very much like a round-robin load balancer
user-microservice
app=user-service
user-microservice
app=user-service
Client
Service
name: user-microservice
port: 31335
selector: app=user-service
Pods
What components make up Kubernetes?
Master
Node
kube-apiserver
kube-scheduler
kube-controller-manager
kubelet
kube-proxy
Master
kube-apiserver
Validates and sets data for resources
Services REST operations
Provides the interface from which
components interact
Master
kube-scheduler
Performs scheduling of pods
Considers many factors when deciding
where to schedule
Resource requirements
Data locality
Process affinity and anti-affinity
Master
kube-controller-manager
Watches the state of the cluster through the API
Makes changes to make actual state of pods
match the desired state of pods
Node
kubelet
Ensures that pod specifications are met on a
node
Performs garbage collection on containers
Ensures that containers are healthy
Node
kube-proxy
Network proxy that forwards traffic to proper
container
Configured using Kubernetes service
Can forward TCP and UDP steams or round-
robin TCP and UDP forwarding
important-microservice
app=user-service
important-microservice
app=user-service
Client
Service
name: user-microservice
port: 31335
selector: app=user-service
Pods
kube-proxy
DemonstrationDemonstration
Let's deploy something!Let's deploy something!
Thanks for coming!
Questions?
kelcecil@praisechaos.com
Email:
Twitter:
@praisechaos
Website:
http://kelcecil.com
If you see this and following slides during the
talk, then my demo was a bust. These slides
are plan B. Sorry about that.
If you're browsing my slides after the talk,
then this is what I demonstrated live.
https://github.com/pires/kubernetes-vagrant-coreos-cluster​
Follow along with this simple Kubernetes vagrant setup.
apiVersion: v1
kind: ReplicationController
# Metadata about the controller
metadata:
name: blog-controller
labels:
name: blog-controller
spec:
replicas: 2
# The labels of pods to be monitored
selector:
name: blog-pod
# Template newly created pods follow
template:
metadata:
# Match the controller selector at minimum
labels:
name: blog-pod
spec:
containers:
- name: blog-container
image: quay.io/kelcecil/kelcecil-com:latest
# containerPort is port in use inside container
ports:
- containerPort: 80
Create a new replication controller
blog.yaml
Create a new replication controller (2/2)
# Set your KUBERNETES_MASTER to your API Server
# Alternatively, use the -s flag with kubectl
export KUBERNETES_MASTER="http://127.0.0.1:8080"
kubectl create -f blog.yaml
In your terminal...
Get a list of replication controllers and pods
kelcecil@Kels-MBP ~/c/kube-talk> kubectl get rc
CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLIC
blog-controller blog-container quay.io/kelcecil/kelcecil-com:latest name=blog-pod 2
kelcecil@Kels-MBP ~/c/kube-talk> kubectl get pods
NAME READY STATUS RESTARTS AGE
blog-controller-0g7ng 1/1 Running 0 1m
blog-controller-a6729 1/1 Running 0 1m
# You can use kubectl get with any Kubernetes resource
# kubectl get <resource>
# kubectl get nodes
# kubectl get services
kelcecil@Kels-MBP ~/c/kube-talk> kubectl describe pod blog-controller-0g7ng
Name: blog-controller-0g7ng
Namespace: default
Image(s): quay.io/kelcecil/kelcecil-com:latest
Node: 172.17.8.102/172.17.8.102
Labels: name=blog-pod
Status: Running
Reason:
Message:
IP: 10.244.35.4
Replication Controllers: blog-controller (2/2 replicas created)
Containers:
blog-container:
Image: quay.io/kelcecil/kelcecil-com:latest
State: Running
Started: Tue, 29 Sep 2015 20:44:37 -0400
Ready: True
Restart Count: 0
......
......
......
Get information about a particular pod
kubectl describe also works for any Kubernetes resource
kelcecil@Kels-MBP ~/c/kube-talk> kubectl describe node 172.17.8.102
Name: 172.17.8.102
Labels: kubernetes.io/hostname=172.17.8.102
CreationTimestamp: Sun, 13 Sep 2015 15:53:52 -0400
Conditions:
Type Status LastHeartbeatTime LastTransitionTime
Ready True Sun, 13 Sep 2015 16:55:16 -0400 Sun, 13 Sep 2015 15:53:52 -0400
Addresses: 172.17.8.102
Capacity:
memory: 2053532Ki
pods: 40
cpu: 1
Version:
Kernel Version: 4.1.6-coreos-r2
OS Image: CoreOS 801.0.0
Container Runtime Version: docker://1.8.1
Kubelet Version: v1.0.3
Kube-Proxy Version: v1.0.3
ExternalID: 172.17.8.102
Pods: (1 in total)
Namespace Name
default blog-lmj3c
No events.
Get system information about a node
kelcecil@Kels-MBP ~/c/kube-talk> kubectl get nodes
NAME LABELS STATUS
172.17.8.102 kubernetes.io/hostname=172.17.8.102 Ready
172.17.8.103 kubernetes.io/hostname=172.17.8.103 Ready
Create a label
kelcecil@Kels-MBP ~/c/kube-talk> kubectl label node 172.17.8.102 region=us-east-1
NAME LABELS STATUS
172.17.8.102 kubernetes.io/hostname=172.17.8.102,region=us-east-1 Ready
kelcecil@Kels-MBP ~/c/kube-talk> kubectl get nodes
NAME LABELS STATUS
172.17.8.102 kubernetes.io/hostname=172.17.8.102,region=us-east-1 Ready
172.17.8.103 kubernetes.io/hostname=172.17.8.103 Ready
kelcecil@Kels-MBP ~/c/kube-talk> kubectl get -l region=us-east-1 nodes
NAME LABELS STATUS
172.17.8.102 kubernetes.io/hostname=172.17.8.102,region=us-east-1 Ready
Filter resources by label
Remove a label
kelcecil@Kels-MBP ~/c/kube-talk> kubectl label node 172.17.8.102 region-
NAME LABELS STATUS
172.17.8.102 kubernetes.io/hostname=172.17.8.102 Ready
Scale a Replication Controller to 3 Replicas
kelcecil@Kels-MBP ~/c/kube-talk> kubectl get pods
NAME READY STATUS RESTARTS AGE
blog-controller-0g7ng 1/1 Running 0 3m
blog-controller-a6729 1/1 Running 0 3m
kelcecil@Kels-MBP ~/c/kube-talk> kubectl scale --replicas=3 rc blog-controller
scaled
kelcecil@Kels-MBP ~/c/kube-talk> kubectl get pods
NAME READY STATUS RESTARTS AGE
blog-controller-0g7ng 1/1 Running 0 3m
blog-controller-a6729 1/1 Running 0 3m
blog-controller-sems7 1/1 Running 0 18s
Get logs from a pod
> kubectl logs blog-controller-0g7ng
2015/09/14 03:07:32 [notice] 12#0: using the "epoll" event method
2015/09/14 03:07:32 [notice] 12#0: nginx/1.8.0
2015/09/14 03:07:32 [notice] 12#0: OS: Linux 4.1.6-coreos-r2
2015/09/14 03:07:32 [notice] 12#0: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2015/09/14 03:07:32 [notice] 12#0: start worker processes
2015/09/14 03:07:32 [notice] 12#0: start worker process 13
Executing a command inside a pod/container
> kubectl exec blog-controller-0g7ng "ps"
PID USER TIME COMMAND
1 root 0:00 /bin/sh -c nginx
12 root 0:00 nginx: master process nginx
13 nginx 0:00 nginx: worker process
82 root 0:00 ps
Interact with a shell inside a container
> kubectl exec -it blog-controller-0g7ng "sh"
/ # ps ax
PID USER TIME COMMAND
1 root 0:00 /bin/sh -c nginx
12 root 0:00 nginx: master process nginx
13 nginx 0:00 nginx: worker process
98 root 0:00 sh
103 root 0:00 ps ax
/ # exit
apiVersion: v1
kind: Service
# Metadata about the service
metadata:
name: blog-service
labels:
name: blog-service
spec:
# Open a port on nodes using kube-proxy
type: NodePort
ports:
# the port the container serves on
- port: 80
# Match the labels for pods to be served
selector:
name: blog-pod
Create a new service
blog-service.yaml
# Set your KUBERNETES_MASTER to your API Server
export KUBERNETES_MASTER="http://127.0.0.1:8080"
kubectl create -f blog-service.yaml
In your terminal...
Perform a rolling update on a container
> kubectl rolling-update --image=quay.io/kelcecil/kelcecil-com:talks blog-controller
Creating blog-controller-676be42f24a573bf0ee7733377bd5ea8
At beginning of loop: blog-controller replicas: 1, blog-controller-676be42f24a573bf0ee7733377bd5ea
Updating blog-controller replicas: 1, blog-controller-676be42f24a573bf0ee7733377bd5ea8 replicas: 1
At end of loop: blog-controller replicas: 1, blog-controller-676be42f24a573bf0ee7733377bd5ea8 repl
At beginning of loop: blog-controller replicas: 0, blog-controller-676be42f24a573bf0ee7733377bd5ea
Updating blog-controller replicas: 0, blog-controller-676be42f24a573bf0ee7733377bd5ea8 replicas: 2
At end of loop: blog-controller replicas: 0, blog-controller-676be42f24a573bf0ee7733377bd5ea8 repl
Update succeeded. Deleting old controller: blog-controller
Renaming blog-controller-676be42f24a573bf0ee7733377bd5ea8 to blog-controller
blog-controller
1 of 40

Recommended

Docker for Fun and Profit by
Docker for Fun and ProfitDocker for Fun and Profit
Docker for Fun and ProfitKel Cecil
1.4K views32 slides
Docker Datacenter Overview and Production Setup Slides by
Docker Datacenter Overview and Production Setup SlidesDocker Datacenter Overview and Production Setup Slides
Docker Datacenter Overview and Production Setup SlidesDocker, Inc.
3.1K views31 slides
Orchestrating Linux Containers while tolerating failures by
Orchestrating Linux Containers while tolerating failuresOrchestrating Linux Containers while tolerating failures
Orchestrating Linux Containers while tolerating failuresDocker, Inc.
7.2K views44 slides
Achieving CI/CD with Kubernetes by
Achieving CI/CD with KubernetesAchieving CI/CD with Kubernetes
Achieving CI/CD with KubernetesRamit Surana
48.8K views37 slides
Cluster management with Kubernetes by
Cluster management with KubernetesCluster management with Kubernetes
Cluster management with KubernetesSatnam Singh
9.1K views69 slides
Scaling Docker Containers using Kubernetes and Azure Container Service by
Scaling Docker Containers using Kubernetes and Azure Container ServiceScaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container ServiceBen Hall
804 views120 slides

More Related Content

What's hot

DockerCon EU 2015: The Latest in Docker Engine by
DockerCon EU 2015: The Latest in Docker EngineDockerCon EU 2015: The Latest in Docker Engine
DockerCon EU 2015: The Latest in Docker EngineDocker, Inc.
6.4K views23 slides
A brief study on Kubernetes and its components by
A brief study on Kubernetes and its componentsA brief study on Kubernetes and its components
A brief study on Kubernetes and its componentsRamit Surana
5.8K views34 slides
Scaling Docker with Kubernetes by
Scaling Docker with KubernetesScaling Docker with Kubernetes
Scaling Docker with KubernetesCarlos Sanchez
1.7K views50 slides
Docker for developers on mac and windows by
Docker for developers on mac and windowsDocker for developers on mac and windows
Docker for developers on mac and windowsDocker, Inc.
1.7K views58 slides
Secrets in Kubernetes by
Secrets in KubernetesSecrets in Kubernetes
Secrets in KubernetesJerry Jalava
3.4K views25 slides
Package your Java EE Application using Docker and Kubernetes by
Package your Java EE Application using Docker and KubernetesPackage your Java EE Application using Docker and Kubernetes
Package your Java EE Application using Docker and KubernetesArun Gupta
27.1K views108 slides

What's hot(20)

DockerCon EU 2015: The Latest in Docker Engine by Docker, Inc.
DockerCon EU 2015: The Latest in Docker EngineDockerCon EU 2015: The Latest in Docker Engine
DockerCon EU 2015: The Latest in Docker Engine
Docker, Inc.6.4K views
A brief study on Kubernetes and its components by Ramit Surana
A brief study on Kubernetes and its componentsA brief study on Kubernetes and its components
A brief study on Kubernetes and its components
Ramit Surana5.8K views
Scaling Docker with Kubernetes by Carlos Sanchez
Scaling Docker with KubernetesScaling Docker with Kubernetes
Scaling Docker with Kubernetes
Carlos Sanchez1.7K views
Docker for developers on mac and windows by Docker, Inc.
Docker for developers on mac and windowsDocker for developers on mac and windows
Docker for developers on mac and windows
Docker, Inc.1.7K views
Secrets in Kubernetes by Jerry Jalava
Secrets in KubernetesSecrets in Kubernetes
Secrets in Kubernetes
Jerry Jalava3.4K views
Package your Java EE Application using Docker and Kubernetes by Arun Gupta
Package your Java EE Application using Docker and KubernetesPackage your Java EE Application using Docker and Kubernetes
Package your Java EE Application using Docker and Kubernetes
Arun Gupta27.1K views
Zero downtime-java-deployments-with-docker-and-kubernetes by Arjan Schaaf
Zero downtime-java-deployments-with-docker-and-kubernetesZero downtime-java-deployments-with-docker-and-kubernetes
Zero downtime-java-deployments-with-docker-and-kubernetes
Arjan Schaaf7.2K views
Docker container basics and efficiency of Kubernetes by Akhter Al Amin
Docker container basics and efficiency of KubernetesDocker container basics and efficiency of Kubernetes
Docker container basics and efficiency of Kubernetes
Akhter Al Amin122 views
WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an... by Brian Grant
WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...
WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...
Brian Grant35.5K views
Windows Server and Docker - The Internals Behind Bringing Docker and Containe... by Docker, Inc.
Windows Server and Docker - The Internals Behind Bringing Docker and Containe...Windows Server and Docker - The Internals Behind Bringing Docker and Containe...
Windows Server and Docker - The Internals Behind Bringing Docker and Containe...
Docker, Inc.11.1K views
Kubernetes Architecture - beyond a black box - Part 1 by Hao H. Zhang
Kubernetes Architecture - beyond a black box - Part 1Kubernetes Architecture - beyond a black box - Part 1
Kubernetes Architecture - beyond a black box - Part 1
Hao H. Zhang7K views
Highly Available Persistent Applications in Containers by Kendrick Coleman, E... by Docker, Inc.
Highly Available Persistent Applications in Containers by Kendrick Coleman, E...Highly Available Persistent Applications in Containers by Kendrick Coleman, E...
Highly Available Persistent Applications in Containers by Kendrick Coleman, E...
Docker, Inc.305 views
Thinking Inside the Container: A Continuous Delivery Story by Maxfield Stewart by Docker, Inc.
Thinking Inside the Container: A Continuous Delivery Story by Maxfield Stewart Thinking Inside the Container: A Continuous Delivery Story by Maxfield Stewart
Thinking Inside the Container: A Continuous Delivery Story by Maxfield Stewart
Docker, Inc.20.9K views
What's new in Kubernetes by Daniel Smith
What's new in KubernetesWhat's new in Kubernetes
What's new in Kubernetes
Daniel Smith2K views
Building Clustered Applications with Kubernetes and Docker by Steve Watt
Building Clustered Applications with Kubernetes and DockerBuilding Clustered Applications with Kubernetes and Docker
Building Clustered Applications with Kubernetes and Docker
Steve Watt4.8K views
Cloning Running Servers with Docker and CRIU by Ross Boucher by Docker, Inc.
Cloning Running Servers with Docker and CRIU by Ross BoucherCloning Running Servers with Docker and CRIU by Ross Boucher
Cloning Running Servers with Docker and CRIU by Ross Boucher
Docker, Inc.4.9K views
Kubernetes Architecture - beyond a black box - Part 2 by Hao H. Zhang
Kubernetes Architecture - beyond a black box - Part 2Kubernetes Architecture - beyond a black box - Part 2
Kubernetes Architecture - beyond a black box - Part 2
Hao H. Zhang2.5K views
Docker and Microsoft - Windows Server 2016 Technical Deep Dive by Docker, Inc.
Docker and Microsoft - Windows Server 2016 Technical Deep DiveDocker and Microsoft - Windows Server 2016 Technical Deep Dive
Docker and Microsoft - Windows Server 2016 Technical Deep Dive
Docker, Inc.9.3K views

Similar to Kubernetes - Sailing a Sea of Containers

Learn kubernetes in 90 minutes by
Learn kubernetes in 90 minutesLearn kubernetes in 90 minutes
Learn kubernetes in 90 minutesLarry Cai
5.5K views27 slides
Kubernetes Node Deep Dive by
Kubernetes Node Deep DiveKubernetes Node Deep Dive
Kubernetes Node Deep DiveLei (Harry) Zhang
2.8K views32 slides
Hands-On Introduction to Kubernetes at LISA17 by
Hands-On Introduction to Kubernetes at LISA17Hands-On Introduction to Kubernetes at LISA17
Hands-On Introduction to Kubernetes at LISA17Ryan Jarvinen
1.1K views82 slides
Kubernetes extensibility by
Kubernetes extensibilityKubernetes extensibility
Kubernetes extensibilityDocker, Inc.
1K views73 slides
Lifecycle of a pod by
Lifecycle of a podLifecycle of a pod
Lifecycle of a podHarshal Shah
1.7K views16 slides
K8s in 3h - Kubernetes Fundamentals Training by
K8s in 3h - Kubernetes Fundamentals TrainingK8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingPiotr Perzyna
396 views80 slides

Similar to Kubernetes - Sailing a Sea of Containers(20)

Learn kubernetes in 90 minutes by Larry Cai
Learn kubernetes in 90 minutesLearn kubernetes in 90 minutes
Learn kubernetes in 90 minutes
Larry Cai5.5K views
Hands-On Introduction to Kubernetes at LISA17 by Ryan Jarvinen
Hands-On Introduction to Kubernetes at LISA17Hands-On Introduction to Kubernetes at LISA17
Hands-On Introduction to Kubernetes at LISA17
Ryan Jarvinen1.1K views
Kubernetes extensibility by Docker, Inc.
Kubernetes extensibilityKubernetes extensibility
Kubernetes extensibility
Docker, Inc.1K views
Lifecycle of a pod by Harshal Shah
Lifecycle of a podLifecycle of a pod
Lifecycle of a pod
Harshal Shah1.7K views
K8s in 3h - Kubernetes Fundamentals Training by Piotr Perzyna
K8s in 3h - Kubernetes Fundamentals TrainingK8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals Training
Piotr Perzyna396 views
Build Your Own CaaS (Container as a Service) by HungWei Chiu
Build Your Own CaaS (Container as a Service)Build Your Own CaaS (Container as a Service)
Build Your Own CaaS (Container as a Service)
HungWei Chiu726 views
Kubernetes Basics for Connections Admins by LetsConnect
Kubernetes Basics for Connections AdminsKubernetes Basics for Connections Admins
Kubernetes Basics for Connections Admins
LetsConnect285 views
Social Connections 14 - Kubernetes Basics for Connections Admins by panagenda
Social Connections 14 - Kubernetes Basics for Connections AdminsSocial Connections 14 - Kubernetes Basics for Connections Admins
Social Connections 14 - Kubernetes Basics for Connections Admins
panagenda2.5K views
Salvatore Incandela, Fabio Marinelli - Using Spinnaker to Create a Developmen... by Codemotion
Salvatore Incandela, Fabio Marinelli - Using Spinnaker to Create a Developmen...Salvatore Incandela, Fabio Marinelli - Using Spinnaker to Create a Developmen...
Salvatore Incandela, Fabio Marinelli - Using Spinnaker to Create a Developmen...
Codemotion136 views
OSS Japan 2019 service mesh bridging Kubernetes and legacy by Steve Wong
OSS Japan 2019 service mesh bridging Kubernetes and legacyOSS Japan 2019 service mesh bridging Kubernetes and legacy
OSS Japan 2019 service mesh bridging Kubernetes and legacy
Steve Wong273 views
Using kubernetes to lose your fear of using containers by josfuecas
Using kubernetes to lose your fear of using containersUsing kubernetes to lose your fear of using containers
Using kubernetes to lose your fear of using containers
josfuecas298 views
Kubernetes Architecture with Components by Ajeet Singh
 Kubernetes Architecture with Components Kubernetes Architecture with Components
Kubernetes Architecture with Components
Ajeet Singh111 views
Effective Building your Platform with Kubernetes == Keep it Simple by Wojciech Barczyński
Effective Building your Platform with Kubernetes == Keep it Simple Effective Building your Platform with Kubernetes == Keep it Simple
Effective Building your Platform with Kubernetes == Keep it Simple
Data weekender deploying prod grade sql 2019 big data clusters by Chris Adkin
Data weekender deploying prod grade sql 2019 big data clustersData weekender deploying prod grade sql 2019 big data clusters
Data weekender deploying prod grade sql 2019 big data clusters
Chris Adkin261 views
DCEU 18: Docker Container Networking by Docker, Inc.
DCEU 18: Docker Container NetworkingDCEU 18: Docker Container Networking
DCEU 18: Docker Container Networking
Docker, Inc.821 views
01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware by VMUG IT
01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware
01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware
VMUG IT262 views

Recently uploaded

What is Whirling Hygrometer.pdf by
What is Whirling Hygrometer.pdfWhat is Whirling Hygrometer.pdf
What is Whirling Hygrometer.pdfIIT KHARAGPUR
11 views3 slides
LFA-NPG-Paper.pdf by
LFA-NPG-Paper.pdfLFA-NPG-Paper.pdf
LFA-NPG-Paper.pdfharinsrikanth
40 views13 slides
Digital Watermarking Of Audio Signals.pptx by
Digital Watermarking Of Audio Signals.pptxDigital Watermarking Of Audio Signals.pptx
Digital Watermarking Of Audio Signals.pptxAyushJaiswal781174
8 views25 slides
fakenews_DBDA_Mar23.pptx by
fakenews_DBDA_Mar23.pptxfakenews_DBDA_Mar23.pptx
fakenews_DBDA_Mar23.pptxdeepmitra8
12 views34 slides
Deutsch Crimping by
Deutsch CrimpingDeutsch Crimping
Deutsch CrimpingIwiss Tools Co.,Ltd
19 views7 slides
Multi-objective distributed generation integration in radial distribution sy... by
Multi-objective distributed generation integration in radial  distribution sy...Multi-objective distributed generation integration in radial  distribution sy...
Multi-objective distributed generation integration in radial distribution sy...IJECEIAES
15 views14 slides

Recently uploaded(20)

What is Whirling Hygrometer.pdf by IIT KHARAGPUR
What is Whirling Hygrometer.pdfWhat is Whirling Hygrometer.pdf
What is Whirling Hygrometer.pdf
IIT KHARAGPUR 11 views
fakenews_DBDA_Mar23.pptx by deepmitra8
fakenews_DBDA_Mar23.pptxfakenews_DBDA_Mar23.pptx
fakenews_DBDA_Mar23.pptx
deepmitra812 views
Multi-objective distributed generation integration in radial distribution sy... by IJECEIAES
Multi-objective distributed generation integration in radial  distribution sy...Multi-objective distributed generation integration in radial  distribution sy...
Multi-objective distributed generation integration in radial distribution sy...
IJECEIAES15 views
Literature review and Case study on Commercial Complex in Nepal, Durbar mall,... by AakashShakya12
Literature review and Case study on Commercial Complex in Nepal, Durbar mall,...Literature review and Case study on Commercial Complex in Nepal, Durbar mall,...
Literature review and Case study on Commercial Complex in Nepal, Durbar mall,...
AakashShakya1245 views
cloud computing-virtualization.pptx by RajaulKarim20
cloud computing-virtualization.pptxcloud computing-virtualization.pptx
cloud computing-virtualization.pptx
RajaulKarim2082 views
13_DVD_Latch-up_prevention.pdf by Usha Mehta
13_DVD_Latch-up_prevention.pdf13_DVD_Latch-up_prevention.pdf
13_DVD_Latch-up_prevention.pdf
Usha Mehta9 views
NEW SUPPLIERS SUPPLIES (copie).pdf by georgesradjou
NEW SUPPLIERS SUPPLIES (copie).pdfNEW SUPPLIERS SUPPLIES (copie).pdf
NEW SUPPLIERS SUPPLIES (copie).pdf
georgesradjou7 views
performance uploading.pptx by SanthiS10
performance uploading.pptxperformance uploading.pptx
performance uploading.pptx
SanthiS107 views
DevOps to DevSecOps: Enhancing Software Security Throughout The Development L... by Anowar Hossain
DevOps to DevSecOps: Enhancing Software Security Throughout The Development L...DevOps to DevSecOps: Enhancing Software Security Throughout The Development L...
DevOps to DevSecOps: Enhancing Software Security Throughout The Development L...
Anowar Hossain10 views
Dynamics of Hard-Magnetic Soft Materials by Shivendra Nandan
Dynamics of Hard-Magnetic Soft MaterialsDynamics of Hard-Magnetic Soft Materials
Dynamics of Hard-Magnetic Soft Materials
Shivendra Nandan13 views

Kubernetes - Sailing a Sea of Containers

  • 1. KubernetesKubernetes Sailing a Sea of ContainersSailing a Sea of Containers Kel Cecil - @praisechaos
  • 2. What is Kubernetes?What is Kubernetes? Container Orchestration Toolset Originated at Google (Borg) Now a Cloud Native Computing Foundation project Used in commercial and open source projects Tectonic (CoreOS) Meteor Galaxy (MeteorJS) OpenShift 3 (Red Hat) Kubernetes Scheduler for Deis (Engine Yard)
  • 3. Why Kubernetes?Why Kubernetes? Deploying one single container app is easy Deploying a complex app is more difficult One or more containers Replicas of containers Data volumes for persistent storage Deploying lots of complex apps can be a challenge
  • 4. FeaturesFeatures Services for load balancing Resource-based scheduling Robust API Great CLI tooling via kubectl Container-spec agnostic
  • 5. What does a simple Kubernetes cluster look like? Master Node Node Node
  • 6. NodeNode Physical or virtual machine on which containers can be scheduled
  • 7. What unit runs on the nodes?What unit runs on the nodes?
  • 8. PodPod A colocated set of application containers and shared data volumes. Smallest unit that can be scheduled.
  • 9. Pod container 1 container n AWS EBS Volume GCE Volume NFS Share Git Commit Containers Data Volumes And more...
  • 10. How can we organize podsHow can we organize pods (or any other Kubernetes resource)?
  • 11. LabelsLabels Key-value pairs used to organize resources.
  • 13. Let's have replicas of pods...Let's have replicas of pods... (There's a Kubernetes resource for that.)
  • 14. Replication ControllerReplication Controller Manages the lifecycle of pods by ensuring a desired number of pods exist.
  • 15. Replication Controller replicas=2 selector: app=user-service Pod labels: app=user-service Pod labels: app=user-service Pod labels: app=user-service
  • 16. How can we direct traffic to pods?How can we direct traffic to pods?
  • 17. ServiceService Provides a single, stable endpoint for a set of pods. Very much like a round-robin load balancer
  • 19. What components make up Kubernetes?
  • 21. Master kube-apiserver Validates and sets data for resources Services REST operations Provides the interface from which components interact
  • 22. Master kube-scheduler Performs scheduling of pods Considers many factors when deciding where to schedule Resource requirements Data locality Process affinity and anti-affinity
  • 23. Master kube-controller-manager Watches the state of the cluster through the API Makes changes to make actual state of pods match the desired state of pods
  • 24. Node kubelet Ensures that pod specifications are met on a node Performs garbage collection on containers Ensures that containers are healthy
  • 25. Node kube-proxy Network proxy that forwards traffic to proper container Configured using Kubernetes service Can forward TCP and UDP steams or round- robin TCP and UDP forwarding
  • 29. If you see this and following slides during the talk, then my demo was a bust. These slides are plan B. Sorry about that. If you're browsing my slides after the talk, then this is what I demonstrated live. https://github.com/pires/kubernetes-vagrant-coreos-cluster​ Follow along with this simple Kubernetes vagrant setup.
  • 30. apiVersion: v1 kind: ReplicationController # Metadata about the controller metadata: name: blog-controller labels: name: blog-controller spec: replicas: 2 # The labels of pods to be monitored selector: name: blog-pod # Template newly created pods follow template: metadata: # Match the controller selector at minimum labels: name: blog-pod spec: containers: - name: blog-container image: quay.io/kelcecil/kelcecil-com:latest # containerPort is port in use inside container ports: - containerPort: 80 Create a new replication controller blog.yaml
  • 31. Create a new replication controller (2/2) # Set your KUBERNETES_MASTER to your API Server # Alternatively, use the -s flag with kubectl export KUBERNETES_MASTER="http://127.0.0.1:8080" kubectl create -f blog.yaml In your terminal...
  • 32. Get a list of replication controllers and pods kelcecil@Kels-MBP ~/c/kube-talk> kubectl get rc CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLIC blog-controller blog-container quay.io/kelcecil/kelcecil-com:latest name=blog-pod 2 kelcecil@Kels-MBP ~/c/kube-talk> kubectl get pods NAME READY STATUS RESTARTS AGE blog-controller-0g7ng 1/1 Running 0 1m blog-controller-a6729 1/1 Running 0 1m # You can use kubectl get with any Kubernetes resource # kubectl get <resource> # kubectl get nodes # kubectl get services
  • 33. kelcecil@Kels-MBP ~/c/kube-talk> kubectl describe pod blog-controller-0g7ng Name: blog-controller-0g7ng Namespace: default Image(s): quay.io/kelcecil/kelcecil-com:latest Node: 172.17.8.102/172.17.8.102 Labels: name=blog-pod Status: Running Reason: Message: IP: 10.244.35.4 Replication Controllers: blog-controller (2/2 replicas created) Containers: blog-container: Image: quay.io/kelcecil/kelcecil-com:latest State: Running Started: Tue, 29 Sep 2015 20:44:37 -0400 Ready: True Restart Count: 0 ...... ...... ...... Get information about a particular pod kubectl describe also works for any Kubernetes resource
  • 34. kelcecil@Kels-MBP ~/c/kube-talk> kubectl describe node 172.17.8.102 Name: 172.17.8.102 Labels: kubernetes.io/hostname=172.17.8.102 CreationTimestamp: Sun, 13 Sep 2015 15:53:52 -0400 Conditions: Type Status LastHeartbeatTime LastTransitionTime Ready True Sun, 13 Sep 2015 16:55:16 -0400 Sun, 13 Sep 2015 15:53:52 -0400 Addresses: 172.17.8.102 Capacity: memory: 2053532Ki pods: 40 cpu: 1 Version: Kernel Version: 4.1.6-coreos-r2 OS Image: CoreOS 801.0.0 Container Runtime Version: docker://1.8.1 Kubelet Version: v1.0.3 Kube-Proxy Version: v1.0.3 ExternalID: 172.17.8.102 Pods: (1 in total) Namespace Name default blog-lmj3c No events. Get system information about a node kelcecil@Kels-MBP ~/c/kube-talk> kubectl get nodes NAME LABELS STATUS 172.17.8.102 kubernetes.io/hostname=172.17.8.102 Ready 172.17.8.103 kubernetes.io/hostname=172.17.8.103 Ready
  • 35. Create a label kelcecil@Kels-MBP ~/c/kube-talk> kubectl label node 172.17.8.102 region=us-east-1 NAME LABELS STATUS 172.17.8.102 kubernetes.io/hostname=172.17.8.102,region=us-east-1 Ready kelcecil@Kels-MBP ~/c/kube-talk> kubectl get nodes NAME LABELS STATUS 172.17.8.102 kubernetes.io/hostname=172.17.8.102,region=us-east-1 Ready 172.17.8.103 kubernetes.io/hostname=172.17.8.103 Ready kelcecil@Kels-MBP ~/c/kube-talk> kubectl get -l region=us-east-1 nodes NAME LABELS STATUS 172.17.8.102 kubernetes.io/hostname=172.17.8.102,region=us-east-1 Ready Filter resources by label Remove a label kelcecil@Kels-MBP ~/c/kube-talk> kubectl label node 172.17.8.102 region- NAME LABELS STATUS 172.17.8.102 kubernetes.io/hostname=172.17.8.102 Ready
  • 36. Scale a Replication Controller to 3 Replicas kelcecil@Kels-MBP ~/c/kube-talk> kubectl get pods NAME READY STATUS RESTARTS AGE blog-controller-0g7ng 1/1 Running 0 3m blog-controller-a6729 1/1 Running 0 3m kelcecil@Kels-MBP ~/c/kube-talk> kubectl scale --replicas=3 rc blog-controller scaled kelcecil@Kels-MBP ~/c/kube-talk> kubectl get pods NAME READY STATUS RESTARTS AGE blog-controller-0g7ng 1/1 Running 0 3m blog-controller-a6729 1/1 Running 0 3m blog-controller-sems7 1/1 Running 0 18s
  • 37. Get logs from a pod > kubectl logs blog-controller-0g7ng 2015/09/14 03:07:32 [notice] 12#0: using the "epoll" event method 2015/09/14 03:07:32 [notice] 12#0: nginx/1.8.0 2015/09/14 03:07:32 [notice] 12#0: OS: Linux 4.1.6-coreos-r2 2015/09/14 03:07:32 [notice] 12#0: getrlimit(RLIMIT_NOFILE): 1048576:1048576 2015/09/14 03:07:32 [notice] 12#0: start worker processes 2015/09/14 03:07:32 [notice] 12#0: start worker process 13
  • 38. Executing a command inside a pod/container > kubectl exec blog-controller-0g7ng "ps" PID USER TIME COMMAND 1 root 0:00 /bin/sh -c nginx 12 root 0:00 nginx: master process nginx 13 nginx 0:00 nginx: worker process 82 root 0:00 ps Interact with a shell inside a container > kubectl exec -it blog-controller-0g7ng "sh" / # ps ax PID USER TIME COMMAND 1 root 0:00 /bin/sh -c nginx 12 root 0:00 nginx: master process nginx 13 nginx 0:00 nginx: worker process 98 root 0:00 sh 103 root 0:00 ps ax / # exit
  • 39. apiVersion: v1 kind: Service # Metadata about the service metadata: name: blog-service labels: name: blog-service spec: # Open a port on nodes using kube-proxy type: NodePort ports: # the port the container serves on - port: 80 # Match the labels for pods to be served selector: name: blog-pod Create a new service blog-service.yaml # Set your KUBERNETES_MASTER to your API Server export KUBERNETES_MASTER="http://127.0.0.1:8080" kubectl create -f blog-service.yaml In your terminal...
  • 40. Perform a rolling update on a container > kubectl rolling-update --image=quay.io/kelcecil/kelcecil-com:talks blog-controller Creating blog-controller-676be42f24a573bf0ee7733377bd5ea8 At beginning of loop: blog-controller replicas: 1, blog-controller-676be42f24a573bf0ee7733377bd5ea Updating blog-controller replicas: 1, blog-controller-676be42f24a573bf0ee7733377bd5ea8 replicas: 1 At end of loop: blog-controller replicas: 1, blog-controller-676be42f24a573bf0ee7733377bd5ea8 repl At beginning of loop: blog-controller replicas: 0, blog-controller-676be42f24a573bf0ee7733377bd5ea Updating blog-controller replicas: 0, blog-controller-676be42f24a573bf0ee7733377bd5ea8 replicas: 2 At end of loop: blog-controller replicas: 0, blog-controller-676be42f24a573bf0ee7733377bd5ea8 repl Update succeeded. Deleting old controller: blog-controller Renaming blog-controller-676be42f24a573bf0ee7733377bd5ea8 to blog-controller blog-controller