Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Kubernetes Basics

Kubernetes Basics

Kubernetes Basics
Introduction to Kubernetes
http://eueung.github.io/docker-stuff/kubernetes

Eueung Mulyana

May 27, 2016
Tweet

More Decks by Eueung Mulyana

Other Decks in Technology

Transcript

  1. Kubernetes is an open-source platform for automating deployment, scaling, and

    operations of application containers across clusters of hosts, providing container-centric infrastructure. With Kubernetes, you are able to quickly and e ciently respond to customer demand: Deploy your applications quickly and predictably. Scale your applications on the y. Seamlessly roll out new features. Optimize use of your hardware by using only the resources you need Kubernetes is: portable: public, private, hybrid, multi-cloud extensible: modular, pluggable, hookable, composable self-healing: auto-placement, auto-restart, auto- replication, auto-scaling Ref: kubernetes.io 4 / 40 What is Kubernetes? The name Kubernetes originates from Greek, meaning "helmsman" or "pilot", and is the root of "governor" and "cybernetic". K8s is an abbreviation derived by replacing the 8 letters "ubernete" with 8. With Kubernetes you can deploy a full cluster of multi-tiered containers (frontend, backend, etc.) with a single con guration le and a single command (Ref).
  2. Kubernetes Container orchestrator Runs and manages containers Supports multiple cloud

    and bare-metal environments Inspired and informed by Google's experiences and internal systems 100% Open source, written in Go Manage applications, not machines Ref: Kubernetes Intro and Update @thockin 5 / 40
  3. 6 / 40 Architecture A running Kubernetes cluster contains node

    agents (kubelet) and master components (apiserver, scheduler, etc), on top of a distributed storage solution.
  4. 7 / 40 K8s Node Worker / Minion The Kubernetes

    node has the services necessary to run application containers and be managed from the master systems. Each node runs container engine e.g. Docker. This engine takes care of the details of downloading images and running containers. kubelet kube-proxy
  5. 8 / 40 K8s Node kubelet The kubelet manages pods

    and their containers, their images, their volumes, etc. kube-proxy Each node also runs a simple network proxy and load balancer. This re ects services as de ned in the Kubernetes API (apiserver) on each node and can do simple TCP and UDP stream forwarding (round robin) across a set of backends.
  6. 9 / 40 K8s Master Control Plane The Kubernetes control

    plane is split into a set of components. Currently they all run on a single master node. These components work together to provide a uni ed view of the cluster. etcd All persistent master state is stored in an instance of etcd. This provides a great way to store con guration data reliably. With watch support, coordinating components can be noti ed very quickly of changes.
  7. 10 / 40 K8s Master etcd API Server The apiserver

    serves up the Kubernetes API. It is intended to be a CRUD-y server, with most/all business logic implemented in separate components or in plug-ins. It mainly processes REST operations, validates them, and updates the corresponding objects in etcd (and eventually other stores).
  8. 11 / 40 Scheduler The scheduler binds unscheduled pods to

    nodes via the /binding API. The scheduler is pluggable, support for multiple cluster schedulers and user-provided schedulers in the plan. Controller Manager All other cluster-level functions are currently performed by the Controller Manager. For instance, Endpoints objects are created and updated by the endpoints controller, and nodes are discovered, managed, and monitored by the node controller. These could eventually be split into separate components to make them independently pluggable. The replicationcontroller is a mechanism that is layered on top of the simple pod API.
  9. 15 / 40 Containers Pods Pods with Volumes A pod

    is a co-located group of containers and volumes. A volume is a directory, possibly with some data in it, which is accessible to a Container as part of its lesystem. Kubernetes volumes build upon Docker Volumes, adding provisioning of the volume directory and/or device.
  10. 16 / 40 Containers Pods Pods with Volumes Labels A

    label is a key/value pair that is attached to a resource, such as a pod, to convey a user-de ned identifying attribute. Labels can be used to organize and to select subsets of resources.
  11. 17 / 40 Containers Pods Pods with Volumes Labels Replication

    Controllers A replication controller ensures that a speci ed number of pod replicas are running at any one time. It both allows for easy scaling of replicated systems and handles re- creation of a pod when the machine it is on reboots or otherwise fails.
  12. 18 / 40 Containers Pods Pods with Volumes Labels Replication

    Controllers Creating labeled pods with a (labeled) RC
  13. 19 / 40 Containers Pods Pods with Volumes Labels Replication

    Controllers Services Services & labeled Services A service de nes a set of pods and a means by which to access them, such as single stable IP address and corresponding DNS name.
  14. 22 / 40 node1 RPI 3 192.168.1.102 node2 RPI 2

    192.168.1.101 node3 RPI 2 192.168.1.100
  15. 23 / 40 kubernetes-on-arm v0.7.0 by @luxas $ d p

    k g - i k u b e - s y s t e m d . d e b $ k u b e - c o n f i g i n s t a l l # r p i o r r p i - 2 , h y p r i o t o s $ g z i p - d c i m a g e s . t a r . g z | d o c k e r l o a d $ k u b e - c o n f i g i n f o A r c h i t e c t u r e : a r m v 7 l K e r n e l : L i n u x 4 . 1 . 1 7 C P U : 4 c o r e s x 1 2 0 0 M H z U s e d R A M M e m o r y : 1 1 1 M i B - R A M M e m o r y : 9 2 5 M i B U s e d d i s k s p a c e : 2 . 4 G B ( 2 4 2 4 0 4 4 K B ) F r e e d i s k s p a c e : 1 1 G B ( 1 1 3 8 2 4 7 2 K B ) S D C a r d / d e b p a c k a g e w a s b u i l t : 2 1 - 0 3 - 2 0 1 6 2 1 : 0 6 k u b e r n e t e s - o n - a r m : L a t e s t c o m m i t : 1 d 0 b b e 1 - V e r s i o n : 0 . 7 . 0 s y s t e m d v e r s i o n : v 2 1 5 d o c k e r v e r s i o n : v 1 . 1 0 . 3 k u b e r n e t e s c l i e n t v e r s i o n : v 1 . 2 . 0
  16. 24 / 40 $ d o c k e r

    i m a g e s R E P O S I T O R Y T A G I M A G E I D C R E A T E D k u b e r n e t e s o n a r m / e t c d 0 . 7 . 0 3 5 5 0 c 0 c 4 f 2 0 5 8 w e e k s a g o k u b e r n e t e s o n a r m / e t c d l a t e s t 3 5 5 0 c 0 c 4 f 2 0 5 8 w e e k s a g o k u b e r n e t e s o n a r m / g r a f a n a 0 . 7 . 0 8 e a 2 6 f 4 e f 5 a 3 8 w e e k s a g o k u b e r n e t e s o n a r m / g r a f a n a l a t e s t 8 e a 2 6 f 4 e f 5 a 3 8 w e e k s a g o k u b e r n e t e s o n a r m / i n f l u x d b 0 . 7 . 0 4 4 7 9 5 1 a 6 8 7 c 6 8 w e e k s a g o k u b e r n e t e s o n a r m / i n f l u x d b l a t e s t 4 4 7 9 5 1 a 6 8 7 c 6 8 w e e k s a g o k u b e r n e t e s o n a r m / h e a p s t e r 0 . 7 . 0 1 d 0 3 4 6 7 4 f c 0 e 8 w e e k s a g o k u b e r n e t e s o n a r m / h e a p s t e r l a t e s t 1 d 0 3 4 6 7 4 f c 0 e 8 w e e k s a g o k u b e r n e t e s o n a r m / l o a d b a l a n c e r 0 . 7 . 0 6 b 2 6 2 f 2 f d 3 1 8 8 w e e k s a g o k u b e r n e t e s o n a r m / l o a d b a l a n c e r l a t e s t 6 b 2 6 2 f 2 f d 3 1 8 8 w e e k s a g o k u b e r n e t e s o n a r m / r e g i s t r y 0 . 7 . 0 4 c 9 c 9 6 4 f 8 9 e 9 8 w e e k s a g o k u b e r n e t e s o n a r m / r e g i s t r y l a t e s t 4 c 9 c 9 6 4 f 8 9 e 9 8 w e e k s a g o k u b e r n e t e s o n a r m / e x e c h e a l t h z 0 . 7 . 0 5 7 f 7 7 5 4 2 a c 5 c 8 w e e k s a g o k u b e r n e t e s o n a r m / e x e c h e a l t h z l a t e s t 5 7 f 7 7 5 4 2 a c 5 c 8 w e e k s a g o k u b e r n e t e s o n a r m / k u b e 2 s k y 0 . 7 . 0 7 7 0 c c c a c 4 2 3 6 8 w e e k s a g o k u b e r n e t e s o n a r m / k u b e 2 s k y l a t e s t 7 7 0 c c c a c 4 2 3 6 8 w e e k s a g o k u b e r n e t e s o n a r m / s k y d n s 0 . 7 . 0 3 0 e a 4 9 5 8 f 9 3 9 8 w e e k s a g o k u b e r n e t e s o n a r m / s k y d n s l a t e s t 3 0 e a 4 9 5 8 f 9 3 9 8 w e e k s a g o k u b e r n e t e s o n a r m / p a u s e 0 . 7 . 0 0 5 e d c 9 6 9 2 5 6 e 8 w e e k s a g o k u b e r n e t e s o n a r m / p a u s e l a t e s t 0 5 e d c 9 6 9 2 5 6 e 8 w e e k s a g o k u b e r n e t e s o n a r m / h y p e r k u b e 0 . 7 . 0 3 8 0 d e f 0 4 9 4 6 7 8 w e e k s a g o k u b e r n e t e s o n a r m / h y p e r k u b e l a t e s t 3 8 0 d e f 0 4 9 4 6 7 8 w e e k s a g o k u b e r n e t e s o n a r m / f l a n n e l 0 . 7 . 0 8 a 3 5 c 6 2 9 3 9 9 f 8 w e e k s a g o k u b e r n e t e s o n a r m / f l a n n e l l a t e s t 8 a 3 5 c 6 2 9 3 9 9 f 8 w e e k s a g o h y p r i o t / r p i - s w a r m l a t e s t c 2 9 8 d e 0 6 2 1 9 0 1 0 w e e k s a g o
  17. $ k u b e - c o n f

    i g e n a b l e - m a s t e r D i s a b l i n g k 8 s i f i t i s r u n n i n g C h e c k s s o a l l i m a g e s a r e p r e s e n t T r a n s f e r r i n g i m a g e s t o s y s t e m - d o c k e r , i f n e c e s s a r y C o p y i n g k u b e r n e t e s o n a r m / e t c d t o s y s t e m - d o c k e r . . . K u b e r n e t e s m a s t e r s e r v i c e s e n a b l e d $ d o c k e r p s C O N T A I N E R I D I M A G E C O M M A N D C R E A T E D 7 b f 7 3 6 d 8 4 4 5 1 k u b e r n e t e s o n a r m / h y p e r k u b e " / h y p e r k u b e c o n t r o l l e " 2 m i n u t e s a g o 5 5 6 0 f 0 6 b c f 4 7 k u b e r n e t e s o n a r m / h y p e r k u b e " / h y p e r k u b e p r o x y - - m " 2 m i n u t e s a g o 0 f b 1 6 9 5 6 7 9 4 6 k u b e r n e t e s o n a r m / h y p e r k u b e " / h y p e r k u b e s c h e d u l e r " 2 m i n u t e s a g o 1 1 c 0 3 a 4 0 4 1 2 c k u b e r n e t e s o n a r m / h y p e r k u b e " / h y p e r k u b e a p i s e r v e r " 2 m i n u t e s a g o e d e 8 5 8 b 3 5 d f a k u b e r n e t e s o n a r m / p a u s e " / p a u s e " 2 m i n u t e s a g o 5 e 3 8 d a c 4 f d 1 9 k u b e r n e t e s o n a r m / h y p e r k u b e " / h y p e r k u b e k u b e l e t - " 3 m i n u t e s a g o 25 / 40 Master
  18. $ k u b e - c o n f

    i g e n a b l e - w o r k e r 1 9 2 . 1 6 8 . 1 . 1 0 2 D i s a b l i n g k 8 s i f i t i s r u n n i n g U s i n g m a s t e r i p : 1 9 2 . 1 6 8 . 1 . 1 0 2 C h e c k s s o a l l i m a g e s a r e p r e s e n t T r a n s f e r r i n g i m a g e s t o s y s t e m - d o c k e r , i f n e c e s s a r y C o p y i n g k u b e r n e t e s o n a r m / f l a n n e l t o s y s t e m - d o c k e r C r e a t e d s y m l i n k f r o m / e t c / s y s t e m d / s y s t e m / m u l t i - u s e r . t a r g e t . w a n t s / f l a n n e l . s e r v i c e t o / u S t a r t i n g w o r k e r c o m p o n e n t s i n d o c k e r c o n t a i n e r s C r e a t e d s y m l i n k f r o m / e t c / s y s t e m d / s y s t e m / m u l t i - u s e r . t a r g e t . w a n t s / k 8 s - w o r k e r . s e r v i c e t o K u b e r n e t e s w o r k e r s e r v i c e s e n a b l e d 26 / 40 Worker
  19. $ k u b e c t l g e

    t n o d e s N A M E S T A T U S A G E 1 9 2 . 1 6 8 . 1 . 1 0 0 R e a d y 2 6 s 1 9 2 . 1 6 8 . 1 . 1 0 1 R e a d y 7 m 1 9 2 . 1 6 8 . 1 . 1 0 2 R e a d y 4 h $ k u b e c t l c l u s t e r - i n f o K u b e r n e t e s m a s t e r i s r u n n i n g a t h t t p : / / l o c a l h o s t : 8 0 8 0 27 / 40 Check
  20. $ k u b e c t l r u

    n m y - n g i n x - - i m a g e = l u x a s / n g i n x - t e s t - - r e p l i c a s = 3 - - e x p o s e - - p o r t = 8 0 s e r v i c e " m y - n g i n x " c r e a t e d d e p l o y m e n t " m y - n g i n x " c r e a t e d $ k u b e c t l g e t p o d s N A M E R E A D Y S T A T U S R E S T A R T S A G E k 8 s - m a s t e r - 1 9 2 . 1 6 8 . 1 . 1 0 2 4 / 4 R u n n i n g 1 5 h m y - n g i n x - 3 7 9 5 0 2 6 5 7 5 - 9 w 8 m w 0 / 1 C o n t a i n e r C r e a t i n g 0 1 4 s m y - n g i n x - 3 7 9 5 0 2 6 5 7 5 - m i z 3 d 0 / 1 C o n t a i n e r C r e a t i n g 0 1 4 s m y - n g i n x - 3 7 9 5 0 2 6 5 7 5 - z y 2 d 4 0 / 1 C o n t a i n e r C r e a t i n g 0 1 4 s $ k u b e c t l g e t s v c N A M E C L U S T E R - I P E X T E R N A L - I P P O R T ( S ) A G E k u b e r n e t e s 1 0 . 0 . 0 . 1 < n o n e > 4 4 3 / T C P 5 h m y - n g i n x 1 0 . 0 . 0 . 1 2 9 < n o n e > 8 0 / T C P 3 6 s $ k u b e c t l g e t d e p l o y m e n t s N A M E D E S I R E D C U R R E N T U P - T O - D A T E A V A I L A B L E A G E m y - n g i n x 3 3 3 1 1 m $ c u r l 1 0 . 0 . 0 . 1 2 9 < p > W E L C O M E T O N G I N X < / p > 28 / 40 Test #1
  21. $ k u b e c t l r u

    n h e l l o - k u b e - - i m a g e = h y p r i o t / r p i - n a n o - h t t p d - - p o r t = 8 0 d e p l o y m e n t " h e l l o - k u b e " c r e a t e d $ k u b e c t l e x p o s e d e p l o y m e n t h e l l o - k u b e - - t y p e = " L o a d B a l a n c e r " - - e x t e r n a l - i p = " 1 9 2 . 1 6 8 . 1 . s e r v i c e " h e l l o - k u b e " e x p o s e d $ k u b e c t l g e t p o d s - o w i d e N A M E R E A D Y S T A T U S R E S T A R T S A G E N O D E h e l l o - k u b e - 1 0 7 9 3 4 6 7 4 3 - 2 k n j 3 0 / 1 I m a g e P u l l B a c k O f f 0 5 5 s 1 9 2 . 1 6 k 8 s - m a s t e r - 1 9 2 . 1 6 8 . 1 . 1 0 2 4 / 4 R u n n i n g 1 8 h 1 9 2 . 1 6 $ k u b e c t l g e t d e p l o y m e n t s N A M E D E S I R E D C U R R E N T U P - T O - D A T E A V A I L A B L E A G E h e l l o - k u b e 1 1 1 1 1 m $ k u b e c t l g e t p o d s - o w i d e N A M E R E A D Y S T A T U S R E S T A R T S A G E N O D E h e l l o - k u b e - 1 0 7 9 3 4 6 7 4 3 - 2 k n j 3 1 / 1 R u n n i n g 0 1 m 1 9 2 . 1 6 8 . 1 . 1 0 0 k 8 s - m a s t e r - 1 9 2 . 1 6 8 . 1 . 1 0 2 4 / 4 R u n n i n g 1 8 h 1 9 2 . 1 6 8 . 1 . 1 0 2 $ k u b e c t l g e t s v c N A M E C L U S T E R - I P E X T E R N A L - I P P O R T ( S ) A G E h e l l o - k u b e 1 0 . 0 . 0 . 1 9 7 , 1 9 2 . 1 6 8 . 1 . 1 0 2 8 0 / T C P 4 4 s k u b e r n e t e s 1 0 . 0 . 0 . 1 < n o n e > 4 4 3 / T C P 8 h $ c u r l 1 0 . 0 . 0 . 1 9 7 < h t m l > < h e a d > < t i t l e > P i a r m e d w i t h D o c k e r b y H y p r i o t < / t i t l e > < b o d y s t y l e = " w i d t h : 1 0 0 % ; b a c k g r o u n d - c o l o r : b l a c k ; " > < d i v i d = " m a i n " s t y l e = " m a r g i n : 1 0 0 p x a u t o 0 a u t o ; w i d t h : 8 0 0 p x ; " > < i m g s r c = " p i _ a r m e d _ w i t h _ d o c k e r . j p g " a l t = " p i a r m e d w i t h d o c k e r " s t y l e = " w i d t h : 8 0 0 < / d i v > < / b o d y > < / h t m l > 29 / 40 Test #2
  22. $ k u b e c t l r u

    n h e l l o - k u b e - - i m a g e = h y p r i o t / r p i - n a n o - h t t p d - - r e p l i c a s = 2 - - p o r t = 8 0 d e p l o y m e n t " h e l l o - k u b e " c r e a t e d $ k u b e c t l e x p o s e d e p l o y m e n t h e l l o - k u b e - - t y p e = " L o a d B a l a n c e r " - - e x t e r n a l - i p = " 1 9 2 . 1 6 8 . 1 . s e r v i c e " h e l l o - k u b e " e x p o s e d $ k u b e c t l g e t s v c N A M E C L U S T E R - I P E X T E R N A L - I P P O R T ( S ) A G E h e l l o - k u b e 1 0 . 0 . 0 . 2 2 1 , 1 9 2 . 1 6 8 . 1 . 1 0 2 8 0 / T C P 1 0 s k u b e r n e t e s 1 0 . 0 . 0 . 1 < n o n e > 4 4 3 / T C P 8 h $ k u b e c t l g e t p o d s - o w i d e N A M E R E A D Y S T A T U S R E S T A R T S A G E N O D E h e l l o - k u b e - 1 0 7 9 3 4 6 7 4 3 - 4 4 y i g 1 / 1 R u n n i n g 0 1 m 1 9 2 . 1 6 8 . 1 . 1 0 0 h e l l o - k u b e - 1 0 7 9 3 4 6 7 4 3 - u p z x y 1 / 1 R u n n i n g 0 1 m 1 9 2 . 1 6 8 . 1 . 1 0 1 k 8 s - m a s t e r - 1 9 2 . 1 6 8 . 1 . 1 0 2 4 / 4 R u n n i n g 1 8 h 1 9 2 . 1 6 8 . 1 . 1 0 2 $ c u r l 1 0 . 0 . 0 . 2 2 1 $ c u r l 1 9 2 . 1 6 8 . 1 . 1 0 2 < h t m l > < h e a d > < t i t l e > P i a r m e d w i t h D o c k e r b y H y p r i o t < / t i t l e > < b o d y s t y l e = " w i d t h : 1 0 0 % ; b a c k g r o u n d - c o l o r : b l a c k ; " > < d i v i d = " m a i n " s t y l e = " m a r g i n : 1 0 0 p x a u t o 0 a u t o ; w i d t h : 8 0 0 p x ; " > < i m g s r c = " p i _ a r m e d _ w i t h _ d o c k e r . j p g " a l t = " p i a r m e d w i t h d o c k e r " s t y l e = " w i d t h : 8 0 0 < / d i v > < / b o d y > < / h t m l > 30 / 40 Test #3
  23. $ k u b e c t l r u

    n h e l l o - k u b e - - i m a g e = h y p r i o t / r p i - n a n o - h t t p d - - r e p l i c a s = 3 - - p o r t = 8 0 d e p l o y m e n t " h e l l o - k u b e " c r e a t e d $ k u b e c t l e x p o s e d e p l o y m e n t h e l l o - k u b e - - p o r t = 8 3 0 0 - - t a r g e t - p o r t = 8 0 - - t y p e = " L o a d B a l a n c s e r v i c e " h e l l o - k u b e " e x p o s e d $ k u b e c t l g e t s v c N A M E C L U S T E R - I P E X T E R N A L - I P P O R T ( S ) A G E h e l l o - k u b e 1 0 . 0 . 0 . 1 2 4 , 1 9 2 . 1 6 8 . 1 . 1 0 2 8 3 0 0 / T C P 8 s k u b e r n e t e s 1 0 . 0 . 0 . 1 < n o n e > 4 4 3 / T C P 7 h $ k u b e c t l d e l e t e s e r v i c e , d e p l o y m e n t h e l l o - k u b e 31 / 40 Test #4
  24. Refs 1. Tim Hockin, Kubernetes: One Year Later 2. Ray

    Tsang @saturnism, Kubernetes with Java-based Microservices 3. Stefan Schimanski, Kubernetes Architecture & Introduction 4. @luxas - kubernetes-on-arm 5. Daniel Smith, What's new in Kubernetes 6. Kubernetes - What is Kubernetes? 7. Kubernetes - User Guide 8. Learn the Kubernetes Key Concepts 9. Kubernetes Intro and Update @thockin 10. kubernetes/architecture.md at release-1.2 - kubernetes/kubernetes 11. Kubernetes - User Guide 12. An Introduction to Kubernetes 39 / 40