39
Kubernetes Introdution Production-Grade Container Orchestration Jan 2017, Peng Xiao Network Consulting Engineer Cisco Systems 8

Kubernetes Introduction

Embed Size (px)

Citation preview

Page 1: Kubernetes Introduction

Kubernetes IntrodutionProduction-GradeContainerOrchestration

Jan 2017, Peng Xiao

Network Consulting Engineer

Cisco Systems

8

Page 2: Kubernetes Introduction

https://research.google.com/pubs/pub35290.html

Page 3: Kubernetes Introduction

In The Very Beginning…

Hardware

Application

Operating System

Page 4: Kubernetes Introduction

Scale & High Availability

Hardware

App

Operating System

Hardware

App

Operating System

Hardware

App

Operating System

Page 5: Kubernetes Introduction

Hardware Virtualization

Infratructure

App

Operating System

App

Operating System

App

Operating System

Machine Machine Machine

Page 6: Kubernetes Introduction

Containerized

Infratructure

App

Operating System

App

Operating System

App

Operating System

Machine Machine Machine

Container Runtime Container Runtime Container Runtime

Page 7: Kubernetes Introduction

ContainerOrchestration

Infratructure

App

Operating System Operating System Operating System

Machine Machine Machine

Container Runtime Container Runtime Container Runtime

Container Orchestration

App App App App

Page 8: Kubernetes Introduction

ContainerOrchestration

Infratructure

Operating System Operating System Operating System

Machine Machine Machine

Container Runtime Container Runtime Container Runtime

Resource Management

Scheduling

Service Management

AppsOrche

stratio

n

Page 9: Kubernetes Introduction

ContainerOrchestration

• Schedule containers to physical/virtual machines• Restart containers if they stop• Provide private container network• Scale up and down• Service discovery

Page 10: Kubernetes Introduction

ContainerOrchestration War?

Page 11: Kubernetes Introduction

Kubernetes

• Greek for “Helmsman”; also the root ofthe word “governor” and “cybernetic”• Orchestrator for containers• Builds on Docker containers

• Also supporting other container technologies• Multi-cloud and bare-metal environments• Inspired and informed by Google’sexperiences and internal systems• 100% Open Source, written in Go.• Release 1.0 21th July 2015

Large-scaleclustermanagementatGooglewithBorg https://research.google.com/pubs/pub43438.html

Page 12: Kubernetes Introduction

Velocity

1.0

1.1

1.2

1.3

Tot

al C

omm

its

1.5

Commits Since July 2014

1.4

Page 13: Kubernetes Introduction

Kubernetes Architecture

Page 14: Kubernetes Introduction

Quick Recap

• Docker• Docker Compose• Docker Swarm

Page 15: Kubernetes Introduction

KubernetesArchitecture

Page 16: Kubernetes Introduction

Setup Kubernetes Environment

• Minikube• Simplest way to get Kubernetes cluster up and running• Support Microsoft Windows and Mac OSX

• Kubernetes Multi-Node Cluster• Emulates production environment• Good for testing advanced scenarios

• Google Container Engine• Hosted and managed by Google• Powered by Google Compute Engine

Page 17: Kubernetes Introduction

Getting Started with Minikube

• Install Oracle VirtualBox for Mac• Install Docker Toolbox for Mac• Install Docker Version Manager• Install the latest version of Minikube for Mac OSX• Download the latest version of kubectl from this link• Run the following commands from the directory where kubectl is downloaded

• chmod +x ./kubectl• sudo mv kubectl /usr/local/bin

• Launch minikube with the following command:• minikube start –wm-driver=virtualbox

• Test minikube installation with the following commands• minikube status• kubectl get cs

Page 18: Kubernetes Introduction

kubeadm

master.myco.com# apt-get install -y kubelet kubeadm kubectl kubernetes-cnimaster.myco.com# kubeadm initKubernetes master initialized successfully!You can now join any number of nodes by running the following command:kubeadm join --token 48b69e.b61e2d0dd5c 10.140.0.3

node-01.myco.com# apt-get install -y kubelet kubeadm kubectl kubernetes-cninode-01.myco.com# kubeadm join --token 48b69e.b61e2d0dd5c 10.140.0.3Node join complete.

master.myco.com# kubectl apply -f https://git.io/weave-kubeNetwork setup complete.

Page 19: Kubernetes Introduction

KubernetesMaster

Page 20: Kubernetes Introduction

Kubernetes Node

Page 21: Kubernetes Introduction

Kubernetes Pod

• Groupofoneormorecontainersthatarealwaysco-located,co-scheduled,andruninasharedcontext• Containersinthesamepodhavethesamehostname• Eachpodisisolatedby• ○ ProcessID(PID)namespace• ○ Networknamespace• ○ Interprocess Communication(IPC)namespace• ○ UnixTimeSharing(UTS)namespace

• AlternativetoaVMwithmultipleprocesses

Page 22: Kubernetes Introduction

Kubernetes Pod

• ContainerswithinthesamepodcommunicatewitheachotherusingIPC• Containerscanfindeachothervialocalhost• Eachcontainerinheritsthenameofthepod• EachpodhasanIPaddressinaflatsharednetworkingspace• Volumesaresharedbycontainersinapod

Page 23: Kubernetes Introduction

Deploying a pod

Page 24: Kubernetes Introduction

Services

• AnabstractiontodefinealogicalsetofPodsboundbyapolicybytoaccessthem• Servicesareexposedthroughinternalandexternalendpoints• Servicescanalsopointtonon-KubernetesendpointsthroughaVirtual-IP-Bridge• SupportsTCPandUDP• Interfaceswithkube-proxytomanipulateiptables• Servicecanbeexposedinternalorexternaltothecluster

Page 25: Kubernetes Introduction

Service Types

• ClusterIP• Service is reachable only from inside of the cluster

• NodePort• Service is reachable through <NodeIP>:NodePort address.

• LoadBalancer• Service is reachable through an external load balancer mapped to<NodeIP>:NodePort address

Page 26: Kubernetes Introduction

Service Discovery -Environmentvariables

• KubernetescreatesDockerLinkcompatibleenvironmentvariablesinallPods• Containerscanusetheenvironmentvariabletotalktotheserviceendpoint

Page 27: Kubernetes Introduction

Service Discovery - DNS

• TheDNSserverwatchesKubernetesAPIfornewServices• TheDNSservercreatesasetofDNSrecordsforeachService• Servicescanberesolvedbythenamewithinthesamenamespace• PodsinothernamespacescanaccesstheServicebyaddingthenamespacetotheDNSpath• my-service.my-namespace

Page 28: Kubernetes Introduction

Replication Controller

• EnsuresthataPodorhomogeneoussetofPodsarealwaysupandavailable• AlwaysmaintainsdesirednumberofPods• IfthereareexcessPods,theygetkilled• Newpodsarelaunchedwhentheyfail,getdeleted,orterminated

• Creatingareplicationcontrollerwithacountof1ensuresthataPodisalwaysavailable• ReplicationControllerandPodsareassociatedthroughLabels

Page 29: Kubernetes Introduction

Scaling Pods with Replication Controller

Page 30: Kubernetes Introduction

Replica Set

• ReplicaSetsarethenextgenerationReplicationControllers• Ensuresspecifiednumberofpodsarealwaysrunning• PodsarereplacedbyReplicaSetswhenafailureoccurs• Newpodsareautomaticallyscheduled

• LabelsandSelectorsareusedforassociatingPodswithReplicaSets• UsuallycombinedwithPodswhendefiningthedeployment

Page 31: Kubernetes Introduction

Kubernetes Networking

Page 32: Kubernetes Introduction

Docker Networking

Page 33: Kubernetes Introduction

Kubernetes Networking

• Highly-coupledcontainer-to-container communications• Pod-to-Pod communications• Pod-to-Service communications• External-to-internal communications

Page 34: Kubernetes Introduction

Container to Container

• All containers within a pod can reach each other’s port on localhost

Page 35: Kubernetes Introduction

Pod to Pod

• Kubernetesimposesthefollowingfundamentalrequirementsonanynetworkingimplementation• allpods (containers) cancommunicatewithallothercontainerswithoutNAT

• allnodescancommunicatewithallcontainers(andvice-versa)withoutNAT

• theIPthatacontainerseesitselfasisthesameIPthatothersseeitas

• Network model• Can be L3 routed• Can be underlayed (cloud)• Can be overlayed (SDN)

Page 36: Kubernetes Introduction

Pod to Pod: How?

• OnGCE/GKE• GCEAdvancedRoutes(programthefabric)• “Everythingto10.1.1.0/24,sendtothisVM”

• Plentyofotherways• AWS:RouteTables• Weave• Calico• Flannel• OVS• OpenContrail• CiscoContiv• Others...

Page 37: Kubernetes Introduction

Pod to Service

Page 38: Kubernetes Introduction

Adoption

~4k Commitsin 1.5

+25% UniqueContributors

Top 0.01% of all Github Projects

3500+ ExternalProjects Based

on K8s

Companies Contributing

Companies Using

Page 39: Kubernetes Introduction

Thanks for your time