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

Learning Kubernetes

Learning Kubernetes

Kubernetes Basics - Part 2
Introduction to Kubernetes
http://eueung.github.io/docker-stuff/learning-k8s

1ec13070abf6996a0bc06b9be103ea85?s=128

Eueung Mulyana

June 02, 2016
Tweet

Transcript

  1. Orchestrating Containers Kubernetes - Learning Continues Eueung Mulyana http://eueung.github.io/docker-stuff/learning-k8s CodeLabs

    | Attribution-ShareAlike CC BY-SA 1 / 37
  2. Outline Base Setup & OS Con g k8s Addons -

    DNS & Dashboard Remote Master & k8s Visualizer Test It All 2 / 37
  3. Base Setup & OS Config 3 / 37

  4. 4 / 37 node1 RPI 3 192.168.1.102 node2 RPI 2

    192.168.1.101 node3 RPI 2 192.168.1.100
  5. 5 / 37 HypriotOS 0.8.0 $ f l a s

    h - d / d e v / m m c b l k 0 h y p r i o t o s - r p i - v 0 . 8 . 0 . i m g $ f l a s h - d / d e v / m m c b l k 0 h y p r i o t o s - r p i - v 0 . 8 . 0 . i m g $ s s h - k e y g e n - f " / h o m e / e m / . s s h / k n o w n _ h o s t s " - R b l a c k - p e a r l . l o c $ s s h p i r a t e @ b l a c k - p e a r l . l o c a l # p i r a t e / h y p r i o t $ s u d o n a n o / e t c / n e t w o r k / i n t e r f a c e s . d / e t h 0 $ s u d o n a n o / e t c / h o s t s $ s u d o n a n o / e t c / h o s t n a m e # - - - $ s u d o n a n o / b o o t / d e v i c e - i n i t . y a m l # h o s t n a m e f o r y o u r H y p r i o t O S d e v i c e h o s t n a m e : n o d e 2 d o c k e r : i m a g e s : - " / v a r / l o c a l / r p i - c o n s u l _ v 0 . 6 . 4 . t a r . g z " - " / v a r / l o c a l / r p i - s w a r m _ v 1 . 2 . 2 . t a r . g z " c l u s t e r l a b : s e r v i c e : r u n _ o n _ b o o t : " f a l s e " # o p t i o n a l w i r e l e s s n e t w o r k s e t t i n g s w i f i : i n t e r f a c e s : # w l a n 0 : # s s i d : " M y N e t w o r k " # p a s s w o r d : " s e c r e t _ p a s s w o r d "
  6. 6 / 37 HypriotOS 0.8.0 $ s u d o

    s u $ m o u n t - o r e m o u n t , r w / s y s / f s / c g r o u p $ m k d i r / s y s / f s / c g r o u p / c p u s e t $ n a n o / b o o t / c m d l i n e . t x t # e d i t : c g r o u p _ e n a b l e = c p u s e t # - - - $ n a n o / e t c / r e s o l v . c o n f s e a r c h d e f a u l t . s v c . c l u s t e r . l o c a l s v c . c l u s t e r . l o c a l c l u s t e r . l o c n a m e s e r v e r 1 0 . 0 . 0 . 1 0 n a m e s e r v e r 1 9 2 . 1 6 8 . 1 . 1 # - - - # o p t i o n a l t o o l s $ a p t - g e t i n s t a l l d n s u t i l s z i p $ s h u t d o w n - r n o w # - - - $ s s h - k e y g e n - R 1 9 2 . 1 6 8 . 1 . 1 0 1 & & s s h - k e y g e n - R n o d e 2 . l o c a l $ s s h - c o p y - i d - o S t r i c t H o s t K e y C h e c k i n g = n o - o C h e c k H o s t I P = n o p i r a $ s f t p p i r a t e @ n o d e 2 . l o c a l # p u t i m a g e s . . . # p u t k u b e - s y s t e m d . . .
  7. 7 / 37 kubernetes-on-arm v0.7.0 $ 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 $ k u b e - c o n f i g e n a b l e - m a s t e r $ 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
  8. k8s Addons DNS & Dashboard 8 / 37

  9. $ s u d o k u b e -

    c o n f i g e n a b l e - a d d o n d a s h b o a r d $ s u d o k u b e - c o n f i g e n a b l e - a d d o n d n s n a m e s p a c e " k u b e - s y s t e m " c r e a t e d W a r n i n g : U n i t f i l e o f n e t w o r k i n g . s e r v i c e c h a n g e d o n d i s k , ' s y s t e m c t l d a e m o n - r e l o a d ' r e c o r e p l i c a t i o n c o n t r o l l e r " k u b e - d n s - v 8 " c r e a t e d s e r v i c e " k u b e - d n s " c r e a t e d S t a r t e d a d d o n : d n s $ 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 K u b e D N S 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 / a p i / v 1 / p r o x y / n a m e s p a c e s / k u b e - s y s t e m / s e r v i c e s D a s h b o a r d 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 / a p i / v 1 / p r o x y / n a m e s p a c e s / k u b e - s y s t e m / s e r v i c $ k u b e c t l - - n a m e s p a c e = k u b e - s y s t e m g e t p o d s , r c , s v c 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 u b e - d n s - v 8 - u v 6 r 5 4 / 4 R u n n i n g 0 1 h k u b e r n e t e s - d a s h b o a r d - h 5 g 8 4 1 / 1 R u n n i n g 0 1 h N A M E D E S I R E D C U R R E N T A G E k u b e - d n s - v 8 1 1 2 2 h k u b e r n e t e s - d a s h b o a r d 1 1 2 2 h 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 - d n s 1 0 . 0 . 0 . 1 0 < n o n e > 5 3 / U D P , 5 3 / T C P 2 2 h k u b e r n e t e s - d a s h b o a r d 1 0 . 0 . 0 . 2 4 9 < n o n e > 8 0 / T C P 2 2 h 9 / 37 Master
  10. # k s p - r e s t a

    r t . s h # - - - # ! / b i n / b a s h k u b e c t l d e l e t e p o $ ( k u b e c t l g e t p o - - n a m e s p a c e = k u b e - s y s t e m | g r e p k u b e - d n s | c u t - d ' ' k u b e c t l d e l e t e p o $ ( k u b e c t l g e t p o - - n a m e s p a c e = k u b e - s y s t e m | g r e p d a s h b o a r d | c u t - d ' ' 10 / 37 Restart Pods
  11. $ k u b e c t l - -

    n a m e s p a c e = k u b e - s y s t e m g e t p o 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 u b e - d n s - v 8 - 8 d k 0 a 4 / 4 R u n n i n g 0 1 1 s k u b e r n e t e s - d a s h b o a r d - e w 4 e c 1 / 1 R u n n i n g 0 2 1 s $ k u b e c t l l o g s - - n a m e s p a c e = k u b e - s y s t e m k u b e - d n s - v 8 - 8 d k 0 a - c k u b e 2 s k y I 0 5 3 1 2 3 : 2 9 : 0 1 . 1 3 1 6 1 3 1 k u b e 2 s k y . g o : 4 6 2 E t c d s e r v e r f o u n d : h t t p : / / 1 2 7 . 0 . 0 . 1 : 4 0 0 1 I 0 5 3 1 2 3 : 2 9 : 0 2 . 2 2 5 8 7 7 1 k u b e 2 s k y . g o : 5 2 9 U s i n g h t t p s : / / 1 0 . 0 . 0 . 1 : 4 4 3 f o r k u b e r n e t e s I 0 5 3 1 2 3 : 2 9 : 0 2 . 2 2 6 0 2 7 1 k u b e 2 s k y . g o : 5 3 0 U s i n g k u b e r n e t e s A P I < n i l > I 0 5 3 1 2 3 : 2 9 : 0 2 . 2 3 1 1 8 7 1 k u b e 2 s k y . g o : 5 9 8 W a i t i n g f o r s e r v i c e : d e f a u l t / k u b e r n e t e s I 0 5 3 1 2 3 : 2 9 : 0 3 . 4 3 1 2 3 3 1 k u b e 2 s k y . g o : 6 6 0 S u c c e s s f u l l y a d d e d D N S r e c o r d f o r K u b e r n e t $ k u b e c t l - - n a m e s p a c e = k u b e - s y s t e m e x e c - t i k u b e - d n s - v 8 - 8 d k 0 a - - n s l o o k u p k u b e r n e t e s . d e f a . . . $ k u b e c t l - - n a m e s p a c e = k u b e - s y s t e m e x e c - t i k u b e - d n s - v 8 - 8 d k 0 a - - c a t / e t c / h o s t s $ k u b e c t l - - n a m e s p a c e = k u b e - s y s t e m e x e c - t i k u b e - d n s - v 8 - 8 d k 0 a - - c a t / e t c / r e s o l v . c o n f 11 / 37 Check DNS Service
  12. # l u x a s / a d d

    o n s / s l e e p . y a m l a p i V e r s i o n : v 1 k i n d : P o d m e t a d a t a : n a m e : a l p i n e - s l e e p n a m e s p a c e : d e f a u l t s p e c : c o n t a i n e r s : - i m a g e : l u x a s / a l p i n e c o m m a n d : - s l e e p - " 3 6 0 0 " i m a g e P u l l P o l i c y : I f N o t P r e s e n t n a m e : a l p i n e - s l e e p r e s t a r t P o l i c y : A l w a y s - - - a p i V e r s i o n : v 1 k i n d : P o d m e t a d a t a : n a m e : r a s p b i a n - s l e e p n a m e s p a c e : d e f a u l t s p e c : c o n t a i n e r s : - i m a g e : r e s i n / r p i - r a s p b i a n : j e s s i e c o m m a n d : - s l e e p - " 3 6 0 0 " i m a g e P u l l P o l i c y : I f N o t P r e s e n t n a m e : r a s p b i a n - s l e e p r e s t a r t P o l i c y : A l w a y s 12 / 37 Test DNS Service
  13. $ k u b e c t l c r

    e a t e - f s l e e p . y a m l $ k u b e c t l e x e c - i t a l p i n e - s l e e p - - n s l o o k u p k u b e r n e t e s . d e f a u l t 1 0 . 0 . 0 . 1 0 $ k u b e c t l e x e c - i t a l p i n e - s l e e p - - n s l o o k u p k u b e r n e t e s 1 0 . 0 . 0 . 1 0 $ k u b e c t l e x e c - i t a l p i n e - s l e e p - - n s l o o k u p k u b e - d n s . k u b e - s y s t e m . s v c . c l u s t e r . l o c a l 1 0 . 0 $ k u b e c t l e x e c - i t a l p i n e - s l e e p - - n s l o o k u p k u b e r n e t e s - d a s h b o a r d . k u b e - s y s t e m . s v c . c l u s t e r S e r v e r : 1 0 . 0 . 0 . 1 0 A d d r e s s 1 : 1 0 . 0 . 0 . 1 0 N a m e : k u b e r n e t e s - d a s h b o a r d . k u b e - s y s t e m . s v c . c l u s t e r . l o c a l A d d r e s s 1 : 1 0 . 0 . 0 . 2 4 9 13 / 37 Test DNS Service
  14. # f r o m W o r k e

    r / M i n i o n p i r a t e @ n o d e 2 i n ~ $ c u r l - k h t t p s : / / k u b e r n e t e s . d e f a u l t . s v c . c l u s t e r . l o c a l $ c u r l - k h t t p s : / / k u b e r n e t e s { " p a t h s " : [ " / a p i " , " / a p i / v 1 " , " / a p i s " , " / a p i s / a u t o s c a l i n g " , " / a p i s / a u t o s c a l i n g / v 1 " , " / a p i s / b a t c h " , " / a p i s / b a t c h / v 1 " , " / a p i s / e x t e n s i o n s " , " / a p i s / e x t e n s i o n s / v 1 b e t a 1 " , " / h e a l t h z " , " / h e a l t h z / p i n g " , " / l o g s / " , " / m e t r i c s " , " / r e s e t M e t r i c s " , " / s w a g g e r - u i / " , " / s w a g g e r a p i / " , " / u i / " , " / v e r s i o n " ] } 14 / 37 Test DNS Service
  15. Dashboard 15 / 37

  16. Dashboard 16 / 37

  17. Dashboard 17 / 37

  18. Dashboard 18 / 37

  19. Dashboard 19 / 37

  20. Remote Master & k8s Visualizer 20 / 37

  21. $ w g e t h t t p s

    : / / s t o r a g e . g o o g l e a p i s . c o m / k u b e r n e t e s - r e l e a s e / r e l e a s e / v 1 . 2 . 0 / b i n / l i n u x / a m d 6 4 / k u b e c t l $ c h m o d + x k u b e c t l & & s u d o m v k u b e c t l / u s r / l o c a l / b i n / $ k u b e c t l c o n f i g s e t - c l u s t e r l k 8 - - s e r v e r = h t t p : / / 1 9 2 . 1 6 8 . 1 . 1 0 2 : 8 0 8 0 $ k u b e c t l c o n f i g s e t - c o n t e x t l k 8 - - c l u s t e r = l k 8 $ k u b e c t l c o n f i g u s e - c o n t e x t l k 8 $ 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 3 d 1 9 2 . 1 6 8 . 1 . 1 0 1 R e a d y 3 d 1 9 2 . 1 6 8 . 1 . 1 0 2 R e a d y 3 d 21 / 37 Remote Master
  22. $ g i t c l o n e h

    t t p s : / / g i t h u b . c o m / s a t u r n i s m / g c p - l i v e - k 8 s - v i s u a l i z e r . g i t k 8 s - v i s u a l i z e r $ c d k 8 s - v i s u a l i z e r $ k u b e c t l p r o x y - - w w w = . S t a r t i n g t o s e r v e o n 1 2 7 . 0 . 0 . 1 : 8 0 0 1 22 / 37 k8s Visualizer
  23. k8s Visualizer 23 / 37

  24. Test It All 24 / 37

  25. $ 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 - l v i s u a l i z e = t r u e , r u n 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 . 1 0 s e r v i c e " h e l l o - k u b e " e x p o s e d # a n y n o d e e t h 0 a d d r e s s : 1 0 2 , 1 0 1 , 1 0 0 $ 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 5 7 , 1 9 2 . 1 6 8 . 1 . 1 0 2 8 0 / T C P 3 7 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 3 d $ k u b e c t l g e t p o - 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 a l p i n e - s l e e p 1 / 1 R u n n i n g 0 1 h 1 9 2 . 1 6 8 . 1 . 1 0 2 h e l l o - k u b e - 6 5 8 9 3 4 8 2 9 - o 6 k a 3 1 / 1 R u n n i n g 0 2 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 3 2 h 1 9 2 . 1 6 8 . 1 . 1 0 2 r a s p b i a n - s l e e p 1 / 1 R u n n i n g 0 1 h 1 9 2 . 1 6 8 . 1 . 1 0 2 25 / 37 Test #1
  26. # f r o m n o d e 3

    $ c u r l 1 9 2 . 1 6 8 . 1 . 1 0 2 $ c u r l 1 0 . 0 . 0 . 1 5 7 $ c u r l h e l l o - k u b e < 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 p x < / d i v > < / b o d y > < / h t m l > 26 / 37 Test #1 Reachability
  27. hello-kube Visualized 27 / 37

  28. Test #2 via Dashboard 28 / 37

  29. Test #2 via Dashboard 29 / 37

  30. Test #2 - Take 2 30 / 37

  31. Test #2 - Take 2 31 / 37

  32. Test #2 - Visualizer 32 / 37

  33. $ k u b e c t l g e

    t p o - 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 a l p i n e - s l e e p 1 / 1 R u n n i n g 2 2 h 1 9 2 . 1 6 8 . 1 . 1 0 2 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 3 4 h 1 9 2 . 1 6 8 . 1 . 1 0 2 m y - n g i n x - a f a d x 1 / 1 R u n n i n g 0 1 9 m 1 9 2 . 1 6 8 . 1 . 1 0 0 m y - n g i n x - e 5 c o a 1 / 1 R u n n i n g 0 1 9 m 1 9 2 . 1 6 8 . 1 . 1 0 1 m y - n g i n x 2 - 6 8 r 7 o 1 / 1 R u n n i n g 0 6 m 1 9 2 . 1 6 8 . 1 . 1 0 1 m y - n g i n x 2 - p v i a k 1 / 1 R u n n i n g 0 6 m 1 9 2 . 1 6 8 . 1 . 1 0 0 r a s p b i a n - s l e e p 1 / 1 R u n n i n g 2 2 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 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 3 d m y - n g i n x 2 1 0 . 0 . 0 . 1 3 8 8 3 0 0 / T C P 6 m $ c u r l m y - n g i n x 2 : 8 3 0 0 < p > W E L C O M E T O N G I N X < / p > H y p r i o t O S / a r m v 7 : p i r a t e @ n o d e 1 i n ~ 33 / 37 Test #2 Reachability
  34. 34 / 37

  35. Refs 35 / 37

  36. Refs 1. Docker Pirates ARMed with explosive stu 2. kubernetes-on-arm

    - by @luxas 3. k8s-visualizer @brendandburns @saturnism 4. Setting up Kubernetes visualization of a cluster - @rpicloud 36 / 37
  37. END Eueung Mulyana http://eueung.github.io/docker-stuff/learning-k8s CodeLabs | Attribution-ShareAlike CC BY-SA 37

    / 37