Question: What is Create the ResourceClaim?

Answer: I n   t h i s   s e c t i o n ,   y o u   c r e a t e   a   R e s o u r c e C l a i m   a n d   r e f e r e n c e   i t   i n   a   P o d .   W h a t e v e r   t h e   c l a i m ,   t h e   d e v i c e C l a s s N a m e   i s   a   r e q u i r e d   f i e l d ,   n a r r o w i n g   d o w n   t h e   s c o p e   o f   t h e   r e q u e s t   t o   a   s p e c i f i c   d e v i c e   c l a s s .   T h e   r e q u e s t   i t s e l f   c a n   i n c l u d e   a   C o m m o n   E x p r e s s i o n   L a n g u a g e   e x p r e s s i o n   t h a t   r e f e r e n c e s   a t t r i b u t e s   t h a t   m a y   b e   a d v e r t i s e d   b y   t h e   d r i v e r   m a n a g i n g   t h a t   d e v i c e   c l a s s .   I n   t h i s   e x a m p l e ,   y o u   w i l l   c r e a t e   a   r e q u e s t   f o r   a n y   G P U   a d v e r t i s i n g   o v e r   1 0 G i   m e m o r y   c a p a c i t y .   T h e   a t t r i b u t e   e x p o s i n g   c a p a c i t y   f r o m   t h e   e x a m p l e   d r i v e r   t a k e s   t h e   f o r m   d e v i c e . c a p a c i t y [ ' g p u . e x a m p l e . c o m ' ] . m e m o r y .   N o t e   a l s o   t h a t   t h e   n a m e   o f   t h e   c l a i m   i s   s e t   t o   s o m e - g p u .   a p i V e r s i o n :   r e s o u r c e . k 8 s . i o / v 1   k i n d :   R e s o u r c e C l a i m   m e t a d a t a :   n a m e :   s o m e - g p u   n a m e s p a c e :   d r a - t u t o r i a l   s p e c :   d e v i c e s :   r e q u e s t s :   -   n a m e :   s o m e - g p u   e x a c t l y :   d e v i c e C l a s s N a m e :   g p u . e x a m p l e . c o m   s e l e c t o r s :   -   c e l :   e x p r e s s i o n :   " d e v i c e . c a p a c i t y [ ' g p u . e x a m p l e . c o m ' ] . m e m o r y . c o m p a r e T o ( q u a n t i t y ( ' 1 0 G i ' ) )   > =   0 "   k u b e c t l   a p p l y   - - s e r v e r - s i d e   - f   h t t p : / / k 8 s . i o / e x a m p l e s / d r a / d r i v e r - i n s t a l l / e x a m p l e /


Question: What is Create the Pod that references that ResourceClaim?

Answer: B e l o w   i s   t h e   P o d   m a n i f e s t   r e f e r e n c i n g   t h e   R e s o u r c e C l a i m   y o u   j u s t   m a d e ,   s o m e - g p u ,   i n   t h e   s p e c . r e s o u r c e C l a i m s . r e s o u r c e C l a i m N a m e   f i e l d .   T h e   l o c a l   n a m e   f o r   t h a t   c l a i m ,   g p u ,   i s   t h e n   u s e d   i n   t h e   s p e c . c o n t a i n e r s . r e s o u r c e s . c l a i m s . n a m e   f i e l d   t o   a l l o c a t e   t h e   c l a i m   t o   t h e   P o d ' s   u n d e r l y i n g   c o n t a i n e r .   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 :   p o d 0   n a m e s p a c e :   d r a - t u t o r i a l   l a b e l s :   a p p :   p o d   s p e c :   c o n t a i n e r s :   -   n a m e :   c t r 0   i m a g e :   u b u n t u : 2 4 . 0 4   c o m m a n d :   [ " b a s h " ,   " - c " ]   a r g s :   [ " e x p o r t ;   t r a p   ' e x i t   0 '   T E R M ;   s l e e p   9 9 9 9   &   w a i t " ]   r e s o u r c e s :   c l a i m s :   -   n a m e :   g p u   r e s o u r c e C l a i m s :   -   n a m e :   g p u   r e s o u r c e C l a i m N a m e :   s o m e - g p u   k u b e c t l   a p p l y   - - s e r v e r - s i d e   - f   h t t p : / / k 8 s . i o / e x a m p l e s / d r a / d r i v e r - i n s t a l l / e x a m p l e / p o d . y a m l   C o n f i r m   t h e   p o d   h a s   d e p l o y e d : k u b e c t l   g e t   p o d   p o d 0   - n   d r a - t u t o r i a l   T h e   o u t p u t   i s   s i m i l a r   t o   t h i 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   p o d 0   1 / 1   R u n n i n g   0   9 s   C o n f i r m   t h e   p o d   h a s   d e p l o y e d :   k u b e c t l   g e t   p o d   p o d 0   - n   d r a - t u t o r i a l   T h e   o u t p u t   i s   s i m i l a r   t o   t h i 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   p o d 0   1 / 1   R u n n i n g   0   9 s


Question: What is Explore the DRA state?

Answer: A f t e r   y o u   c r e a t e   t h e   P o d ,   t h e   c l u s t e r   t r i e s   t o   s c h e d u l e   t h a t   P o d   t o   a   n o d e   w h e r e   K u b e r n e t e s   c a n   s a t i s f y   t h e   R e s o u r c e C l a i m .   I n   t h i s   t u t o r i a l ,   t h e   D R A   d r i v e r   i s   d e p l o y e d   o n   a l l   n o d e s ,   a n d   i s   a d v e r t i s i n g   m o c k   G P U s   o n   a l l   n o d e s ,   a l l   o f   w h i c h   h a v e   e n o u g h   c a p a c i t y   a d v e r t i s e d   t o   s a t i s f y   t h e   P o d ' s   c l a i m ,   s o   K u b e r n e t e s   c a n   s c h e d u l e   t h i s   P o d   o n   a n y   n o d e   a n d   c a n   a l l o c a t e   a n y   o f   t h e   m o c k   G P U s   o n   t h a t   n o d e .   W h e n   K u b e r n e t e s   a l l o c a t e s   a   m o c k   G P U   t o   a   P o d ,   t h e   e x a m p l e   d r i v e r   a d d s   e n v i r o n m e n t   v a r i a b l e s   i n   e a c h   c o n t a i n e r   i t   i s   a l l o c a t e d   t o   i n   o r d e r   t o   i n d i c a t e   w h i c h   G P U s   w o u l d   h a v e   b e e n   i n j e c t e d   i n t o   t h e m   b y   a   r e a l   r e s o u r c e   d r i v e r   a n d   h o w   t h e y   w o u l d   h a v e   b e e n   c o n f i g u r e d ,   s o   y o u   c a n   c h e c k   t h o s e   e n v i r o n m e n t   v a r i a b l e s   t o   s e e   h o w   t h e   P o d s   h a v e   b e e n   h a n d l e d   b y   t h e   s y s t e m .   C h e c k   t h e   P o d   l o g s ,   w h i c h   r e p o r t   t h e   n a m e   o f   t h e   m o c k   G P U   t h a t   w a s   a l l o c a t e d : k u b e c t l   l o g s   p o d 0   - c   c t r 0   - n   d r a - t u t o r i a l   |   g r e p   - E   " G P U _ D E V I C E _ [ 0 - 9 ] + = "   |   g r e p   - v   " R E S O U R C E _ C L A I M "   T h e   o u t p u t   i s   s i m i l a r   t o   t h i s : d e c l a r e   - x   G P U _ D E V I C E _ 0 = " g p u - 0 "   C


Question: What is Delete a Pod that has a claim?

Answer: W h e n   a   P o d   w i t h   a   c l a i m   i s   d e l e t e d ,   t h e   D R A   d r i v e r   d e a l l o c a t e s   t h e   r e s o u r c e   s o   i t   c a n   b e   a v a i l a b l e   f o r   f u t u r e   s c h e d u l i n g .   T o   v a l i d a t e   t h i s   b e h a v i o r ,   d e l e t e   t h e   P o d   t h a t   y o u   c r e a t e d   i n   t h e   p r e v i o u s   s t e p s   a n d   w a t c h   t h e   c o r r e s p o n d i n g   c h a n g e s   t o   t h e   R e s o u r c e C l a i m   a n d   d r i v e r .   D e l e t e   t h e   p o d 0   P o d : k u b e c t l   d e l e t e   p o d   p o d 0   - n   d r a - t u t o r i a l   T h e   o u t p u t   i s   s i m i l a r   t o   t h i s : p o d   " p o d 0 "   d e l e t e d   D e l e t e   t h e   p o d 0   P o d :   k u b e c t l   d e l e t e   p o d   p o d 0   - n   d r a - t u t o r i a l   T h e   o u t p u t   i s   s i m i l a r   t o   t h i s :   p o d   " p o d 0 "   d e l e t e d


Question: What is Observe the DRA state?

Answer: W h e n   t h e   P o d   i s   d e l e t e d ,   t h e   d r i v e r   d e a l l o c a t e s   t h e   d e v i c e   f r o m   t h e   R e s o u r c e C l a i m   a n d   u p d a t e s   t h e   R e s o u r c e C l a i m   r e s o u r c e   i n   t h e   K u b e r n e t e s   A P I .   T h e   R e s o u r c e C l a i m   h a s   a   p e n d i n g   s t a t e   u n t i l   i t ' s   r e f e r e n c e d   i n   a   n e w   P o d .   C h e c k   t h e   s t a t e   o f   t h e   s o m e - g p u   R e s o u r c e C l a i m : k u b e c t l   g e t   r e s o u r c e c l a i m s   - n   d r a - t u t o r i a l   T h e   o u t p u t   i s   s i m i l a r   t o   t h i s : N A M E   S T A T E   A G E   s o m e - g p u   p e n d i n g   7 6 s   V e r i f y   t h a t   t h e   d r i v e r   h a s   p r o c e s s e d   u n p r e p a r i n g   t h e   d e v i c e   f o r   t h i s   c l a i m   b y   c h e c k i n g   t h e   d r i v e r   l o g s : k u b e c t l   l o g s   - l   a p p . k u b e r n e t e s . i o / n a m e = d r a - e x a m p l e - d r i v e r   - n   d r a - t u t o r i a l   T h e   o u t p u t   i s   s i m i l a r   t o   t h i s : I 0 8 2 0   1 8 : 2 2 : 1 5 . 6 2 9 3 7 6   1   d r i v e r . g o : 1 3 8 ]   U n p r e p a r e R e s o u r c e C l a i m s   i s   c a l l e d :   n u m b e r   o f   c l a i m s :   1   C h e c k   t h e   s t a t e   o f   t h e   s o m e - g p u   R e s o u r c e C l a i m :   k u b e c t l   g e t   r e s o u r c e c l a i m s   - n   d r a - t u t o r i a l   T h e   o u t p u t   i s   s i m i l a r   t o   t h i s :   N A M E   S T A T E   A G E   s o m e - g p u   p e n d i n g   7 6 s   V e r i f y   t h a t   t h e   d r i v e r   h a s   p r o c e s s e d   u n p r e p a r i n g   t h e   d e v i c e   f o r   t h i s   c l a i m   b y   c h e c k i n g   t h e   d r i v e r   l o g s :   k u b e c t l   l o g s   - l   a p p . k u b e r n e t e s . i o / n a m e = d r a - e x a m p l e - d r i v e r   - n   d r a -


Question: What is Cleaning up?

Answer: T o   c l e a n   u p   t h e   r e s o u r c e s   t h a t   y o u   c r e a t e d   i n   t h i s   t u t o r i a l ,   f o l l o w   t h e s e   s t e p s :   k u b e c t l   d e l e t e   n a m e s p a c e   d r a - t u t o r i a l   k u b e c t l   d e l e t e   d e v i c e c l a s s   g p u . e x a m p l e . c o m   k u b e c t l   d e l e t e   c l u s t e r r o l e   d r a - e x a m p l e - d r i v e r - r o l e   k u b e c t l   d e l e t e   c l u s t e r r o l e b i n d i n g   d r a - e x a m p l e - d r i v e r - r o l e - b i n d i n g   k u b e c t l   d e l e t e   p r i o r i t y c l a s s   d r a - d r i v e r - h i g h - p r i o r i t y


Question: What is What's next?

Answer: L e a r n   m o r e   a b o u t   D R A A l l o c a t e   D e v i c e s   t o   W o r k l o a d s   w i t h   D R A


Question: What is 7.4 - Namespaces Walkthrough?

Answer: K u b e r n e t e s   n a m e s p a c e s   h e l p   d i f f e r e n t   p r o j e c t s ,   t e a m s ,   o r   c u s t o m e r s   t o   s h a r e   a   K u b e r n e t e s   c l u s t e r .   I t   d o e s   t h i s   b y   p r o v i d i n g   t h e   f o l l o w i n g :   A   s c o p e   f o r   N a m e s . A   m e c h a n i s m   t o   a t t a c h   a u t h o r i z a t i o n   a n d   p o l i c y   t o   a   s u b s e c t i o n   o f   t h e   c l u s t e r .   U s e   o f   m u l t i p l e   n a m e s p a c e s   i s   o p t i o n a l .   T h i s   e x a m p l e   d e m o n s t r a t e s   h o w   t o   u s e   K u b e r n e t e s   n a m e s p a c e s   t o   s u b d i v i d e   y o u r   c l u s t e r .


Question: What is Before you begin?

Answer: Y o u   n e e d   t o   h a v e   a   K u b e r n e t e s   c l u s t e r ,   a n d   t h e   k u b e c t l   c o m m a n d - l i n e   t o o l   m u s t   b e   c o n f i g u r e d   t o   c o m m u n i c a t e   w i t h   y o u r   c l u s t e r .   I t   i s   r e c o m m e n d e d   t o   r u n   t h i s   t u t o r i a l   o n   a   c l u s t e r   w i t h   a t   l e a s t   t w o   n o d e s   t h a t   a r e   n o t   a c t i n g   a s   c o n t r o l   p l a n e   h o s t s .   I f   y o u   d o   n o t   a l r e a d y   h a v e   a   c l u s t e r ,   y o u   c a n   c r e a t e   o n e   b y   u s i n g   m i n i k u b e   o r   y o u   c a n   u s e   o n e   o f   t h e s e   K u b e r n e t e s   p l a y g r o u n d s : i x i m i u z   L a b s K i l l e r c o d a K o d e K l o u d P l a y   w i t h   K u b e r n e t e s T o   c h e c k   t h e   v e r s i o n ,   e n t e r   k u b e c t l   v e r s i o n .   Y o u   n e e d   t o   h a v e   a   K u b e r n e t e s   c l u s t e r ,   a n d   t h e   k u b e c t l   c o m m a n d - l i n e   t o o l   m u s t   b e   c o n f i g u r e d   t o   c o m m u n i c a t e   w i t h   y o u r   c l u s t e r .   I t   i s   r e c o m m e n d e d   t o   r u n   t h i s   t u t o r i a l   o n   a   c l u s t e r   w i t h   a t   l e a s t   t w o   n o d e s   t h a t   a r e   n o t   a c t i n g   a s   c o n t r o l   p l a n e   h o s t s .   I f   y o u   d o   n o t   a l r e a d y   h a v e   a   c l u s t e r ,   y o u   c a n   c r e a t e   o n e   b y   u s i n g   m i n i k u b e   o r   y o u   c a n   u s e   o n e   o f   t h e s e   K u b e r n e t e s   p l a y g r o u n d s :   i x i m i u z   L a b s K i l l e r c o d a K o d e K l o u d P l a y   w i t h   K u b e r n e t e s   T o   c h e c k   t h e   v e r s i o n ,   e n t e r   k u b e c t l   v e r s i o n .


Question: What is Prerequisites?

Answer: T h i s   e x a m p l e   a s s u m e s   t h e   f o l l o w i n g :   Y o u   h a v e   a n   e x i s t i n g   K u b e r n e t e s   c l u s t e r . Y o u   h a v e   a   b a s i c   u n d e r s t a n d i n g   o f   K u b e r n e t e s   P o d s ,   S e r v i c e s ,   a n d   D e p l o y m e n t s .


Question: What is Understand the default namespace?

Answer: B y   d e f a u l t ,   a   K u b e r n e t e s   c l u s t e r   w i l l   i n s t a n t i a t e   a   d e f a u l t   n a m e s p a c e   w h e n   p r o v i s i o n i n g   t h e   c l u s t e r   t o   h o l d   t h e   d e f a u l t   s e t   o f   P o d s ,   S e r v i c e s ,   a n d   D e p l o y m e n t s   u s e d   b y   t h e   c l u s t e r .   A s s u m i n g   y o u   h a v e   a   f r e s h   c l u s t e r ,   y o u   c a n   i n s p e c t   t h e   a v a i l a b l e   n a m e s p a c e s   b y   d o i n g   t h e   f o l l o w i n g :   k u b e c t l   g e t   n a m e s p a c e s   N A M E   S T A T U S   A G E   d e f a u l t   A c t i v e   1 3 m


Question: What is Create new namespaces?

Answer: F o r   t h i s   e x e r c i s e ,   w e   w i l l   c r e a t e   t w o   a d d i t i o n a l   K u b e r n e t e s   n a m e s p a c e s   t o   h o l d   o u r   c o n t e n t .   L e t ' s   i m a g i n e   a   s c e n a r i o   w h e r e   a n   o r g a n i z a t i o n   i s   u s i n g   a   s h a r e d   K u b e r n e t e s   c l u s t e r   f o r   d e v e l o p m e n t   a n d   p r o d u c t i o n   u s e   c a s e s .   T h e   d e v e l o p m e n t   t e a m   w o u l d   l i k e   t o   m a i n t a i n   a   s p a c e   i n   t h e   c l u s t e r   w h e r e   t h e y   c a n   g e t   a   v i e w   o n   t h e   l i s t   o f   P o d s ,   S e r v i c e s ,   a n d   D e p l o y m e n t s   t h e y   u s e   t o   b u i l d   a n d   r u n   t h e i r   a p p l i c a t i o n .   I n   t h i s   s p a c e ,   K u b e r n e t e s   r e s o u r c e s   c o m e   a n d   g o ,   a n d   t h e   r e s t r i c t i o n s   o n   w h o   c a n   o r   c a n n o t   m o d i f y   r e s o u r c e s   a r e   r e l a x e d   t o   e n a b l e   a g i l e   d e v e l o p m e n t .   T h e   o p e r a t i o n s   t e a m   w o u l d   l i k e   t o   m a i n t a i n   a   s p a c e   i n   t h e   c l u s t e r   w h e r e   t h e y   c a n   e n f o r c e   s t r i c t   p r o c e d u r e s   o n   w h o   c a n   o r   c a n n o t   m a n i p u l a t e   t h e   s e t   o f   P o d s ,   S e r v i c e s ,   a n d   D e p l o y m e n t s   t h a t   r u n   t h e   p r o d u c t i o n   s i t e .   O n e   p a t t e r n   t h i s   o r g a n i z a t i o n   c o u l d   f o l l o w   i s   t o   p a r t i t i o n   t h e   K u b e r n e t e s   c l u s t e r   i n t o   t w o   n a m e s p a c e s :   d e v e l o p m e n t   a n d   p r o d u c t i o n .   L e t ' s   c r e a t e   t w o   n e w   n a m e s p a c e s   t o   h o l d   o u r   w o r k .   U s e   t h e   f i l e   n a m e s p a c e - d e v . y a m l   w h i c h   d e s c r i b e s   a   d e v e l


Question: What is Create pods in each namespace?

Answer: A   K u b e r n e t e s   n a m e s p a c e   p r o v i d e s   t h e   s c o p e   f o r   P o d s ,   S e r v i c e s ,   a n d   D e p l o y m e n t s   i n   t h e   c l u s t e r .   U s e r s   i n t e r a c t i n g   w i t h   o n e   n a m e s p a c e   d o   n o t   s e e   t h e   c o n t e n t   i n   a n o t h e r   n a m e s p a c e .   T o   d e m o n s t r a t e   t h i s ,   l e t ' s   s p i n   u p   a   s i m p l e   D e p l o y m e n t   a n d   P o d s   i n   t h e   d e v e l o p m e n t   n a m e s p a c e .   W e   f i r s t   c h e c k   w h a t   i s   t h e   c u r r e n t   c o n t e x t :   k u b e c t l   c o n f i g   v i e w   a p i V e r s i o n :   v 1   c l u s t e r s :   -   c l u s t e r :   c e r t i f i c a t e - a u t h o r i t y - d a t a :   R E D A C T E D   s e r v e r :   h t t p s : / / 1 3 0 . 2 1 1 . 1 2 2 . 1 8 0   n a m e :   l i t h e - c o c o a - 9 2 1 0 3 _ k u b e r n e t e s   c o n t e x t s :   -   c o n t e x t :   c l u s t e r :   l i t h e - c o c o a - 9 2 1 0 3 _ k u b e r n e t e s   u s e r :   l i t h e - c o c o a - 9 2 1 0 3 _ k u b e r n e t e s   n a m e :   l i t h e - c o c o a - 9 2 1 0 3 _ k u b e r n e t e s   c u r r e n t - c o n t e x t :   l i t h e - c o c o a - 9 2 1 0 3 _ k u b e r n e t e s   k i n d :   C o n f i g   p r e f e r e n c e s :   { }   u s e r s :   -   n a m e :   l i t h e - c o c o a - 9 2 1 0 3 _ k u b e r n e t e s   u s e r :   c l i e n t - c e r t i f i c a t e - d a t a :   R E D A C T E D   c l i e n t - k e y - d a t a :   R E D A C T E D   t o k e n :   6 5 r Z W 7 8 y 8 H b w X X t S X u U w 9 D b P 4 F L j H i 4 b   -   n a m e :   l i t h e - c o c o a - 9 2 1 0 3 _ k u b e r n e t e s - b a s i c - a u t h   u s e r :   p a s s w o r d :   h 5 M 0 F t U U I f l B S d I 7   u s e r n a m e :   a d m i n   k u b e c t l   c o n f i g   c u r r e n t - c o n t e x t   l i t h e - c o c o a - 9 2 1 0 3 _ k u b e r n e t e s   T h e   n e x t   s t e p   i


Question: What is The Kubernetes model for connecting containers?

Answer: N o w   t h a t   y o u   h a v e   a   c o n t i n u o u s l y   r u n n i n g ,   r e p l i c a t e d   a p p l i c a t i o n   y o u   c a n   e x p o s e   i t   o n   a   n e t w o r k .   K u b e r n e t e s   a s s u m e s   t h a t   p o d s   c a n   c o m m u n i c a t e   w i t h   o t h e r   p o d s ,   r e g a r d l e s s   o f   w h i c h   h o s t   t h e y   l a n d   o n .   K u b e r n e t e s   g i v e s   e v e r y   p o d   i t s   o w n   c l u s t e r - p r i v a t e   I P   a d d r e s s ,   s o   y o u   d o   n o t   n e e d   t o   e x p l i c i t l y   c r e a t e   l i n k s   b e t w e e n   p o d s   o r   m a p   c o n t a i n e r   p o r t s   t o   h o s t   p o r t s .   T h i s   m e a n s   t h a t   c o n t a i n e r s   w i t h i n   a   P o d   c a n   a l l   r e a c h   e a c h   o t h e r ' s   p o r t s   o n   l o c a l h o s t ,   a n d   a l l   p o d s   i n   a   c l u s t e r   c a n   s e e   e a c h   o t h e r   w i t h o u t   N A T .   T h e   r e s t   o f   t h i s   d o c u m e n t   e l a b o r a t e s   o n   h o w   y o u   c a n   r u n   r e l i a b l e   s e r v i c e s   o n   s u c h   a   n e t w o r k i n g   m o d e l .   T h i s   t u t o r i a l   u s e s   a   s i m p l e   n g i n x   w e b   s e r v e r   t o   d e m o n s t r a t e   t h e   c o n c e p t .


Question: What is Exposing pods to the cluster?

Answer: W e   d i d   t h i s   i n   a   p r e v i o u s   e x a m p l e ,   b u t   l e t ' s   d o   i t   o n c e   a g a i n   a n d   f o c u s   o n   t h e   n e t w o r k i n g   p e r s p e c t i v e .   C r e a t e   a n   n g i n x   P o d ,   a n d   n o t e   t h a t   i t   h a s   a   c o n t a i n e r   p o r t   s p e c i f i c a t i o n :   a p i V e r s i o n :   a p p s / v 1   k i n d :   D e p l o y m e n t   m e t a d a t a :   n a m e :   m y - n g i n x   s p e c :   s e l e c t o r :   m a t c h L a b e l s :   r u n :   m y - n g i n x   r e p l i c a s :   2   t e m p l a t e :   m e t a d a t a :   l a b e l s :   r u n :   m y - n g i n x   s p e c :   c o n t a i n e r s :   -   n a m e :   m y - n g i n x   i m a g e :   n g i n x   p o r t s :   -   c o n t a i n e r P o r t :   8 0   T h i s   m a k e s   i t   a c c e s s i b l e   f r o m   a n y   n o d e   i n   y o u r   c l u s t e r .   C h e c k   t h e   n o d e s   t h e   P o d   i s   r u n n i n g   o n :   k u b e c t l   a p p l y   - f   . / r u n - m y - n g i n x . y a m l   k u b e c t l   g e t   p o d s   - l   r u n = m y - n g i n x   - 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   I P   N O D E   m y - n g i n x - 3 8 0 0 8 5 8 1 8 2 - j r 4 a 2   1 / 1   R u n n i n g   0   1 3 s   1 0 . 2 4 4 . 3 . 4   k u b e r n e t e s - m i n i o n - 9 0 5 m   m y - n g i n x - 3 8 0 0 8 5 8 1 8 2 - k n a 2 y   1 / 1   R u n n i n g   0   1 3 s   1 0 . 2 4 4 . 2 . 5   k u b e r n e t e s - m i n i o n - l j y d   C h e c k   y o u r   p o d s '   I P s :   k u b e c t l   g e t   p o d s   - l   r u n = m y - n g i n x   - o   c u s t o m - c o l u m n s = P O D _ I P : . s t a t u s . p o d I P s   P O D _ I P   [ m a p [ i p : 1 0 . 2 4 4 . 3 . 4 ] ]   [ m a p [ i p : 1 0 . 2 4 4 . 2 . 5 ] ]   Y o u   s h o u l d   b e   a b l e   t o   s s h   i n t o   a n y   n o d e   i n   y o u r   c l u s t e r   a n d   u s e   a   t o o l   s u c h   a


Question: What is Creating a Service?

Answer: S o   w e   h a v e   p o d s   r u n n i n g   n g i n x   i n   a   f l a t ,   c l u s t e r   w i d e ,   a d d r e s s   s p a c e .   I n   t h e o r y ,   y o u   c o u l d   t a l k   t o   t h e s e   p o d s   d i r e c t l y ,   b u t   w h a t   h a p p e n s   w h e n   a   n o d e   d i e s ?   T h e   p o d s   d i e   w i t h   i t ,   a n d   t h e   R e p l i c a S e t   i n s i d e   t h e   D e p l o y m e n t   w i l l   c r e a t e   n e w   o n e s ,   w i t h   d i f f e r e n t   I P s .   T h i s   i s   t h e   p r o b l e m   a   S e r v i c e   s o l v e s .   A   K u b e r n e t e s   S e r v i c e   i s   a n   a b s t r a c t i o n   w h i c h   d e f i n e s   a   l o g i c a l   s e t   o f   P o d s   r u n n i n g   s o m e w h e r e   i n   y o u r   c l u s t e r ,   t h a t   a l l   p r o v i d e   t h e   s a m e   f u n c t i o n a l i t y .   W h e n   c r e a t e d ,   e a c h   S e r v i c e   i s   a s s i g n e d   a   u n i q u e   I P   a d d r e s s   ( a l s o   c a l l e d   c l u s t e r I P ) .   T h i s   a d d r e s s   i s   t i e d   t o   t h e   l i f e s p a n   o f   t h e   S e r v i c e ,   a n d   w i l l   n o t   c h a n g e   w h i l e   t h e   S e r v i c e   i s   a l i v e .   P o d s   c a n   b e   c o n f i g u r e d   t o   t a l k   t o   t h e   S e r v i c e ,   a n d   k n o w   t h a t   c o m m u n i c a t i o n   t o   t h e   S e r v i c e   w i l l   b e   a u t o m a t i c a l l y   l o a d - b a l a n c e d   o u t   t o   s o m e   p o d   t h a t   i s   a   m e m b e r   o f   t h e   S e r v i c e .   Y o u   c a n   c r e a t e   a   S e r v i c e   f o r   y o u r   2   n g i n x   r e p l i c a s   w i t h   k u b e c t l   e x p o s e :   k u b e c t l   e x p o s e   d e p l o y m e n t / m y - n g i n x   s e r v i c e / m y - n g i n x   e x p o s e d   T h i s   i s   e q u i v a l e n t   t o   k u b e c t l   a p p l y   - f   i n   t h e   f o l l o w i n g   y a m


Question: What is Accessing the Service?

Answer: K u b e r n e t e s   s u p p o r t s   2   p r i m a r y   m o d e s   o f   f i n d i n g   a   S e r v i c e   -   e n v i r o n m e n t   v a r i a b l e s   a n d   D N S .   T h e   f o r m e r   w o r k s   o u t   o f   t h e   b o x   w h i l e   t h e   l a t t e r   r e q u i r e s   t h e   C o r e D N S   c l u s t e r   a d d o n .


Question: What is Environment Variables?

Answer: W h e n   a   P o d   r u n s   o n   a   N o d e ,   t h e   k u b e l e t   a d d s   a   s e t   o f   e n v i r o n m e n t   v a r i a b l e s   f o r   e a c h   a c t i v e   S e r v i c e .   T h i s   i n t r o d u c e s   a n   o r d e r i n g   p r o b l e m .   T o   s e e   w h y ,   i n s p e c t   t h e   e n v i r o n m e n t   o f   y o u r   r u n n i n g   n g i n x   P o d s   ( y o u r   P o d   n a m e   w i l l   b e   d i f f e r e n t ) :   k u b e c t l   e x e c   m y - n g i n x - 3 8 0 0 8 5 8 1 8 2 - j r 4 a 2   - -   p r i n t e n v   |   g r e p   S E R V I C E   K U B E R N E T E S _ S E R V I C E _ H O S T = 1 0 . 0 . 0 . 1   K U B E R N E T E S _ S E R V I C E _ P O R T = 4 4 3   K U B E R N E T E S _ S E R V I C E _ P O R T _ H T T P S = 4 4 3   N o t e   t h e r e ' s   n o   m e n t i o n   o f   y o u r   S e r v i c e .   T h i s   i s   b e c a u s e   y o u   c r e a t e d   t h e   r e p l i c a s   b e f o r e   t h e   S e r v i c e .   A n o t h e r   d i s a d v a n t a g e   o f   d o i n g   t h i s   i s   t h a t   t h e   s c h e d u l e r   m i g h t   p u t   b o t h   P o d s   o n   t h e   s a m e   m a c h i n e ,   w h i c h   w i l l   t a k e   y o u r   e n t i r e   S e r v i c e   d o w n   i f   i t   d i e s .   W e   c a n   d o   t h i s   t h e   r i g h t   w a y   b y   k i l l i n g   t h e   2   P o d s   a n d   w a i t i n g   f o r   t h e   D e p l o y m e n t   t o   r e c r e a t e   t h e m .   T h i s   t i m e   t h e   S e r v i c e   e x i s t s   b e f o r e   t h e   r e p l i c a s .   T h i s   w i l l   g i v e   y o u   s c h e d u l e r - l e v e l   S e r v i c e   s p r e a d i n g   o f   y o u r   P o d s   ( p r o v i d e d   a l l   y o u r   n o d e s   h a v e   e q u a l   c a p a c i t y ) ,   a s   w e l l   a s   t h e   r i g h t   e n v i r o n m e n t   v a r i a b l e s :   k u b e c t l   s c a l e   d e p l o y m e n t   m y - n g i n x   - - r e p l i c a s


Question: What is DNS?

Answer: K u b e r n e t e s   o f f e r s   a   D N S   c l u s t e r   a d d o n   S e r v i c e   t h a t   a u t o m a t i c a l l y   a s s i g n s   d n s   n a m e s   t o   o t h e r   S e r v i c e s .   Y o u   c a n   c h e c k   i f   i t ' s   r u n n i n g   o n   y o u r   c l u s t e r :   k u b e c t l   g e t   s e r v i c e s   k u b e - d n s   - - n a m e s p a c e = k u b e - s y s t e m   N A M E   T Y P 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   C l u s t e r I P   1 0 . 0 . 0 . 1 0   < n o n e >   5 3 / U D P , 5 3 / T C P   8 m   T h e   r e s t   o f   t h i s   s e c t i o n   w i l l   a s s u m e   y o u   h a v e   a   S e r v i c e   w i t h   a   l o n g   l i v e d   I P   ( m y - n g i n x ) ,   a n d   a   D N S   s e r v e r   t h a t   h a s   a s s i g n e d   a   n a m e   t o   t h a t   I P .   H e r e   w e   u s e   t h e   C o r e D N S   c l u s t e r   a d d o n   ( a p p l i c a t i o n   n a m e   k u b e - d n s ) ,   s o   y o u   c a n   t a l k   t o   t h e   S e r v i c e   f r o m   a n y   p o d   i n   y o u r   c l u s t e r   u s i n g   s t a n d a r d   m e t h o d s   ( e . g .   g e t h o s t b y n a m e ( ) ) .   I f   C o r e D N S   i s n ' t   r u n n i n g ,   y o u   c a n   e n a b l e   i t   r e f e r r i n g   t o   t h e   C o r e D N S   R E A D M E   o r   I n s t a l l i n g   C o r e D N S .   L e t ' s   r u n   a n o t h e r   c u r l   a p p l i c a t i o n   t o   t e s t   t h i s :   k u b e c t l   r u n   c u r l   - - i m a g e = r a d i a l / b u s y b o x p l u s : c u r l   - i   - - t t y   - - r m   W a i t i n g   f o r   p o d   d e f a u l t / c u r l - 1 3 1 5 5 6 2 1 8 - 9 f n c h   t o   b e   r u n n i n g ,   s t a t u s   i s   P e n d i n g ,   p o d   r e a d y :   f a l s e   H i t   e n t e r   f o r   c o m m a n d   p r o m p t   T h e n ,   h i t   e n t e r   a n d   r u n   n s l o o k u p   m y - n g i n x :   [   r


Question: What is Securing the Service?

Answer: T i l l   n o w   w e   h a v e   o n l y   a c c e s s e d   t h e   n g i n x   s e r v e r   f r o m   w i t h i n   t h e   c l u s t e r .   B e f o r e   e x p o s i n g   t h e   S e r v i c e   t o   t h e   i n t e r n e t ,   y o u   w a n t   t o   m a k e   s u r e   t h e   c o m m u n i c a t i o n   c h a n n e l   i s   s e c u r e .   F o r   t h i s ,   y o u   w i l l   n e e d :   S e l f   s i g n e d   c e r t i f i c a t e s   f o r   h t t p s   ( u n l e s s   y o u   a l r e a d y   h a v e   a n   i d e n t i t y   c e r t i f i c a t e ) A n   n g i n x   s e r v e r   c o n f i g u r e d   t o   u s e   t h e   c e r t i f i c a t e s A   s e c r e t   t h a t   m a k e s   t h e   c e r t i f i c a t e s   a c c e s s i b l e   t o   p o d s   Y o u   c a n   a c q u i r e   a l l   t h e s e   f r o m   t h e   n g i n x   h t t p s   e x a m p l e .   T h i s   r e q u i r e s   h a v i n g   g o   a n d   m a k e   t o o l s   i n s t a l l e d .   I f   y o u   d o n ' t   w a n t   t o   i n s t a l l   t h o s e ,   t h e n   f o l l o w   t h e   m a n u a l   s t e p s   l a t e r .   I n   s h o r t :   m a k e   k e y s   K E Y = / t m p / n g i n x . k e y   C E R T = / t m p / n g i n x . c r t   k u b e c t l   c r e a t e   s e c r e t   t l s   n g i n x s e c r e t   - - k e y   / t m p / n g i n x . k e y   - - c e r t   / t m p / n g i n x . c r t   s e c r e t / n g i n x s e c r e t   c r e a t e d   k u b e c t l   g e t   s e c r e t s   N A M E   T Y P E   D A T A   A G E   n g i n x s e c r e t   k u b e r n e t e s . i o / t l s   2   1 m   A n d   a l s o   t h e   c o n f i g m a p :   k u b e c t l   c r e a t e   c o n f i g m a p   n g i n x c o n f i g m a p   - - f r o m - f i l e = d e f a u l t . c o n f   Y o u   c a n   f i n d   a n   e x a m p l e   f o r   d e f a u l t . c o n f   i n   t h e   K u b e r n e t e s   e x a m p l e s   p r o j e c t   r e p o .   c o n f i g m a p / n g i n x c o n


Question: What is Exposing the Service?

Answer: F o r   s o m e   p a r t s   o f   y o u r   a p p l i c a t i o n s   y o u   m a y   w a n t   t o   e x p o s e   a   S e r v i c e   o n t o   a n   e x t e r n a l   I P   a d d r e s s .   K u b e r n e t e s   s u p p o r t s   t w o   w a y s   o f   d o i n g   t h i s :   N o d e P o r t s   a n d   L o a d B a l a n c e r s .   T h e   S e r v i c e   c r e a t e d   i n   t h e   l a s t   s e c t i o n   a l r e a d y   u s e d   N o d e P o r t ,   s o   y o u r   n g i n x   H T T P S   r e p l i c a   i s   r e a d y   t o   s e r v e   t r a f f i c   o n   t h e   i n t e r n e t   i f   y o u r   n o d e   h a s   a   p u b l i c   I P .   k u b e c t l   g e t   s v c   m y - n g i n x   - o   y a m l   |   g r e p   n o d e P o r t   - C   5   u i d :   0 7 1 9 1 f b 3 - f 6 1 a - 1 1 e 5 - 8 a e 5 - 4 2 0 1 0 a f 0 0 0 0 2   s p e c :   c l u s t e r I P :   1 0 . 0 . 1 6 2 . 1 4 9   p o r t s :   -   n a m e :   h t t p   n o d e P o r t :   3 1 7 0 4   p o r t :   8 0 8 0   p r o t o c o l :   T C P   t a r g e t P o r t :   8 0   -   n a m e :   h t t p s   n o d e P o r t :   3 2 4 5 3   p o r t :   4 4 3   p r o t o c o l :   T C P   t a r g e t P o r t :   4 4 3   s e l e c t o r :   r u n :   m y - n g i n x   k u b e c t l   g e t   n o d e s   - o   y a m l   |   g r e p   E x t e r n a l I P   - C   1   -   a d d r e s s :   1 0 4 . 1 9 7 . 4 1 . 1 1   t y p e :   E x t e r n a l I P   a l l o c a t a b l e :   - -   -   a d d r e s s :   2 3 . 2 5 1 . 1 5 2 . 5 6   t y p e :   E x t e r n a l I P   a l l o c a t a b l e :   . . .   $   c u r l   h t t p s : / / < E X T E R N A L - I P > : < N O D E - P O R T >   - k   . . .   < h 1 > W e l c o m e   t o   n g i n x ! < / h 1 >   L e t ' s   n o w   r e c r e a t e   t h e   S e r v i c e   t o   u s e   a   c l o u d   l o a d   b a l a n c e r .   C h a n g e   t h e   T y p e   o f   m y - n g i n x   S e r v i c e   f r o m   N o d e P o r t   t o   L o a d B a l a n c e r :   k


Question: What is What's next?

Answer: L e a r n   m o r e   a b o u t   U s i n g   a   S e r v i c e   t o   A c c e s s   a n   A p p l i c a t i o n   i n   a   C l u s t e r L e a r n   m o r e   a b o u t   C o n n e c t i n g   a   F r o n t   E n d   t o   a   B a c k   E n d   U s i n g   a   S e r v i c e L e a r n   m o r e   a b o u t   C r e a t i n g   a n   E x t e r n a l   L o a d   B a l a n c e r


Question: What is 8.2 - Using Source IP?

Answer: A p p l i c a t i o n s   r u n n i n g   i n   a   K u b e r n e t e s   c l u s t e r   f i n d   a n d   c o m m u n i c a t e   w i t h   e a c h   o t h e r ,   a n d   t h e   o u t s i d e   w o r l d ,   t h r o u g h   t h e   S e r v i c e   a b s t r a c t i o n .   T h i s   d o c u m e n t   e x p l a i n s   w h a t   h a p p e n s   t o   t h e   s o u r c e   I P   o f   p a c k e t s   s e n t   t o   d i f f e r e n t   t y p e s   o f   S e r v i c e s ,   a n d   h o w   y o u   c a n   t o g g l e   t h i s   b e h a v i o r   a c c o r d i n g   t o   y o u r   n e e d s .


Question: What is Terminology?

Answer: T h i s   d o c u m e n t   m a k e s   u s e   o f   t h e   f o l l o w i n g   t e r m s :


Question: What is Prerequisites?

Answer: Y o u   n e e d   t o   h a v e   a   K u b e r n e t e s   c l u s t e r ,   a n d   t h e   k u b e c t l   c o m m a n d - l i n e   t o o l   m u s t   b e   c o n f i g u r e d   t o   c o m m u n i c a t e   w i t h   y o u r   c l u s t e r .   I t   i s   r e c o m m e n d e d   t o   r u n   t h i s   t u t o r i a l   o n   a   c l u s t e r   w i t h   a t   l e a s t   t w o   n o d e s   t h a t   a r e   n o t   a c t i n g   a s   c o n t r o l   p l a n e   h o s t s .   I f   y o u   d o   n o t   a l r e a d y   h a v e   a   c l u s t e r ,   y o u   c a n   c r e a t e   o n e   b y   u s i n g   m i n i k u b e   o r   y o u   c a n   u s e   o n e   o f   t h e s e   K u b e r n e t e s   p l a y g r o u n d s :   i x i m i u z   L a b s K i l l e r c o d a K o d e K l o u d P l a y   w i t h   K u b e r n e t e s   T h e   e x a m p l e s   u s e   a   s m a l l   n g i n x   w e b s e r v e r   t h a t   e c h o e s   b a c k   t h e   s o u r c e   I P   o f   r e q u e s t s   i t   r e c e i v e s   t h r o u g h   a n   H T T P   h e a d e r .   Y o u   c a n   c r e a t e   i t   a s   f o l l o w s :


Question: What is Note:?

Answer: k u b e c t l   c r e a t e   d e p l o y m e n t   s o u r c e - i p - a p p   - - i m a g e = r e g i s t r y . k 8 s . i o / e c h o s e r v e r : 1 . 1 0   T h e   o u t p u t   i s :   d e p l o y m e n t . a p p s / s o u r c e - i p - a p p   c r e a t e d


Question: What is Objectives?

Answer: E x p o s e   a   s i m p l e   a p p l i c a t i o n   t h r o u g h   v a r i o u s   t y p e s   o f   S e r v i c e s U n d e r s t a n d   h o w   e a c h   S e r v i c e   t y p e   h a n d l e s   s o u r c e   I P   N A T U n d e r s t a n d   t h e   t r a d e o f f s   i n v o l v e d   i n   p r e s e r v i n g   s o u r c e   I P


Question: What is Source IP for Services with Type=ClusterIP?

Answer: P a c k e t s   s e n t   t o   C l u s t e r I P   f r o m   w i t h i n   t h e   c l u s t e r   a r e   n e v e r   s o u r c e   N A T ' d   i f   y o u ' r e   r u n n i n g   k u b e - p r o x y   i n   i p t a b l e s   m o d e ,   ( t h e   d e f a u l t ) .   Y o u   c a n   q u e r y   t h e   k u b e - p r o x y   m o d e   b y   f e t c h i n g   h t t p : / / l o c a l h o s t : 1 0 2 4 9 / p r o x y M o d e   o n   t h e   n o d e   w h e r e   k u b e - p r o x y   i s   r u n n i n g .   k u b e c t l   g e t   n o d e s   T h e   o u t p u t   i s   s i m i l a r   t o   t h i s :   N A M E   S T A T U S   R O L E S   A G E   V E R S I O N   k u b e r n e t e s - n o d e - 6 j s t   R e a d y   < n o n e >   2 h   v 1 . 1 3 . 0   k u b e r n e t e s - n o d e - c x 3 1   R e a d y   < n o n e >   2 h   v 1 . 1 3 . 0   k u b e r n e t e s - n o d e - j j 1 t   R e a d y   < n o n e >   2 h   v 1 . 1 3 . 0   G e t   t h e   p r o x y   m o d e   o n   o n e   o f   t h e   n o d e s   ( k u b e - p r o x y   l i s t e n s   o n   p o r t   1 0 2 4 9 ) :   #   R u n   t h i s   i n   a   s h e l l   o n   t h e   n o d e   y o u   w a n t   t o   q u e r y .   c u r l   h t t p : / / l o c a l h o s t : 1 0 2 4 9 / p r o x y M o d e   T h e   o u t p u t   i s :   i p t a b l e s   Y o u   c a n   t e s t   s o u r c e   I P   p r e s e r v a t i o n   b y   c r e a t i n g   a   S e r v i c e   o v e r   t h e   s o u r c e   I P   a p p :   k u b e c t l   e x p o s e   d e p l o y m e n t   s o u r c e - i p - a p p   - - n a m e = c l u s t e r i p   - - p o r t = 8 0   - - t a r g e t - p o r t = 8 0 8 0   T h e   o u t p u t   i s :   s e r v i c e / c l u s t e r i p   e x p o s e d   k u b e c t l   g e t   s v c   c l u s t e r i p   T h e   o u t p u t   i s   s i m i l a r   t o :   N A M E   T Y P 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   c l u s t e r i p   C l u s t e r I P   1 0 . 0 . 1 7 0 . 9 2   < n o


Question: What is Source IP for Services with Type=NodePort?

Answer: P a c k e t s   s e n t   t o   S e r v i c e s   w i t h   T y p e = N o d e P o r t   a r e   s o u r c e   N A T ' d   b y   d e f a u l t .   Y o u   c a n   t e s t   t h i s   b y   c r e a t i n g   a   N o d e P o r t   S e r v i c e :   k u b e c t l   e x p o s e   d e p l o y m e n t   s o u r c e - i p - a p p   - - n a m e = n o d e p o r t   - - p o r t = 8 0   - - t a r g e t - p o r t = 8 0 8 0   - - t y p e = N o d e P o r t   T h e   o u t p u t   i s :   s e r v i c e / n o d e p o r t   e x p o s e d   N O D E P O R T = $ ( k u b e c t l   g e t   - o   j s o n p a t h = " { . s p e c . p o r t s [ 0 ] . n o d e P o r t } "   s e r v i c e s   n o d e p o r t )   N O D E S = $ ( k u b e c t l   g e t   n o d e s   - o   j s o n p a t h = ' {   $ . i t e m s [ * ] . s t a t u s . a d d r e s s e s [ ? ( @ . t y p e = = " I n t e r n a l I P " ) ] . a d d r e s s   } ' )   I f   y o u ' r e   r u n n i n g   o n   a   c l o u d   p r o v i d e r ,   y o u   m a y   n e e d   t o   o p e n   u p   a   f i r e w a l l - r u l e   f o r   t h e   n o d e s : n o d e p o r t   r e p o r t e d   a b o v e .   N o w   y o u   c a n   t r y   r e a c h i n g   t h e   S e r v i c e   f r o m   o u t s i d e   t h e   c l u s t e r   t h r o u g h   t h e   n o d e   p o r t   a l l o c a t e d   a b o v e .   f o r   n o d e   i n   $ N O D E S ;   d o   c u r l   - s   $ n o d e : $ N O D E P O R T   |   g r e p   - i   c l i e n t _ a d d r e s s ;   d o n e   T h e   o u t p u t   i s   s i m i l a r   t o :   c l i e n t _ a d d r e s s = 1 0 . 1 8 0 . 1 . 1   c l i e n t _ a d d r e s s = 1 0 . 2 4 0 . 0 . 5   c l i e n t _ a d d r e s s = 1 0 . 2 4 0 . 0 . 3   N o t e   t h a t   t h e s e   a r e   n o t   t h e   c o r r e c t   c l i e n t   I P s ,   t h e y ' r e   c l u s t e r   i n t e r n a l   I P s .   T h i s   i s   w h a t   h a p p e n s :   C l i e n t   s e n d s   p a c k e t   t o   n o d e 2 : n o d e P o r t n o d e 2   r e p l


Question: What is Source IP for Services with Type=LoadBalancer?

Answer: P a c k e t s   s e n t   t o   S e r v i c e s   w i t h   T y p e = L o a d B a l a n c e r   a r e   s o u r c e   N A T ' d   b y   d e f a u l t ,   b e c a u s e   a l l   s c h e d u l a b l e   K u b e r n e t e s   n o d e s   i n   t h e   R e a d y   s t a t e   a r e   e l i g i b l e   f o r   l o a d - b a l a n c e d   t r a f f i c .   S o   i f   p a c k e t s   a r r i v e   a t   a   n o d e   w i t h o u t   a n   e n d p o i n t ,   t h e   s y s t e m   p r o x i e s   i t   t o   a   n o d e   w i t h   a n   e n d p o i n t ,   r e p l a c i n g   t h e   s o u r c e   I P   o n   t h e   p a c k e t   w i t h   t h e   I P   o f   t h e   n o d e   ( a s   d e s c r i b e d   i n   t h e   p r e v i o u s   s e c t i o n ) .   Y o u   c a n   t e s t   t h i s   b y   e x p o s i n g   t h e   s o u r c e - i p - a p p   t h r o u g h   a   l o a d   b a l a n c e r :   k u b e c t l   e x p o s e   d e p l o y m e n t   s o u r c e - i p - a p p   - - n a m e = l o a d b a l a n c e r   - - p o r t = 8 0   - - t a r g e t - p o r t = 8 0 8 0   - - t y p e = L o a d B a l a n c e r   T h e   o u t p u t   i s :   s e r v i c e / l o a d b a l a n c e r   e x p o s e d   P r i n t   o u t   t h e   I P   a d d r e s s e s   o f   t h e   S e r v i c e :   k u b e c t l   g e t   s v c   l o a d b a l a n c e r   T h e   o u t p u t   i s   s i m i l a r   t o   t h i s :   N A M E   T Y P 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   l o a d b a l a n c e r   L o a d B a l a n c e r   1 0 . 0 . 6 5 . 1 1 8   2 0 3 . 0 . 1 1 3 . 1 4 0   8 0 / T C P   5 m   N e x t ,   s e n d   a   r e q u e s t   t o   t h i s   S e r v i c e ' s   e x t e r n a l - i p :   c u r l   2 0 3 . 0 . 1 1 3 . 1 4 0   T h e   o u t p u t   i s   s i m i l a r   t o   t h i s :   C L I E N T   V A L U E S :   c l i e n t _ a d d r e s s = 1 0 . 2 4 0 . 0 . 5   . . .   H o w e v e r ,   i f   y o u ' r e   r u n n i n g   o n   G o o g l e


Question: What is Cross-platform support?

Answer: O n l y   s o m e   c l o u d   p r o v i d e r s   o f f e r   s u p p o r t   f o r   s o u r c e   I P   p r e s e r v a t i o n   t h r o u g h   S e r v i c e s   w i t h   T y p e = L o a d B a l a n c e r .   T h e   c l o u d   p r o v i d e r   y o u ' r e   r u n n i n g   o n   m i g h t   f u l f i l l   t h e   r e q u e s t   f o r   a   l o a d b a l a n c e r   i n   a   f e w   d i f f e r e n t   w a y s :   W i t h   a   p r o x y   t h a t   t e r m i n a t e s   t h e   c l i e n t   c o n n e c t i o n   a n d   o p e n s   a   n e w   c o n n e c t i o n   t o   y o u r   n o d e s / e n d p o i n t s .   I n   s u c h   c a s e s   t h e   s o u r c e   I P   w i l l   a l w a y s   b e   t h a t   o f   t h e   c l o u d   L B ,   n o t   t h a t   o f   t h e   c l i e n t . W i t h   a   p a c k e t   f o r w a r d e r ,   s u c h   t h a t   r e q u e s t s   f r o m   t h e   c l i e n t   s e n t   t o   t h e   l o a d b a l a n c e r   V I P   e n d   u p   a t   t h e   n o d e   w i t h   t h e   s o u r c e   I P   o f   t h e   c l i e n t ,   n o t   a n   i n t e r m e d i a t e   p r o x y .   W i t h   a   p r o x y   t h a t   t e r m i n a t e s   t h e   c l i e n t   c o n n e c t i o n   a n d   o p e n s   a   n e w   c o n n e c t i o n   t o   y o u r   n o d e s / e n d p o i n t s .   I n   s u c h   c a s e s   t h e   s o u r c e   I P   w i l l   a l w a y s   b e   t h a t   o f   t h e   c l o u d   L B ,   n o t   t h a t   o f   t h e   c l i e n t .   W i t h   a   p a c k e t   f o r w a r d e r ,   s u c h   t h a t   r e q u e s t s   f r o m   t h e   c l i e n t   s e n t   t o   t h e   l o a d b a l a n c e r   V I P   e n d   u p   a t   t h e   n o d e   w i t h   t h e   s o u r c e   I P   o f   t h e   c l i e n t ,   n o t   a n   i n t e r m e d i a t e   p r o x y .   L o a d   b a l a n c e r s   i n   t h e   f i r s t   c a t e g o r y   m u s t   u s e   a n   a g r e e d   u p o n   p r o


Question: What is Cleaning up?

Answer: D e l e t e   t h e   S e r v i c e s :   k u b e c t l   d e l e t e   s v c   - l   a p p = s o u r c e - i p - a p p   D e l e t e   t h e   D e p l o y m e n t ,   R e p l i c a S e t   a n d   P o d :   k u b e c t l   d e l e t e   d e p l o y m e n t   s o u r c e - i p - a p p


Question: What is What's next?

Answer: L e a r n   m o r e   a b o u t   c o n n e c t i n g   a p p l i c a t i o n s   v i a   s e r v i c e s R e a d   h o w   t o   C r e a t e   a n   E x t e r n a l   L o a d   B a l a n c e r


Question: What is 8.3 - Explore Termination Behavior for Pods And Their Endpoints?

Answer: O n c e   y o u   c o n n e c t e d   y o u r   A p p l i c a t i o n   w i t h   S e r v i c e   f o l l o w i n g   s t e p s   l i k e   t h o s e   o u t l i n e d   i n   C o n n e c t i n g   A p p l i c a t i o n s   w i t h   S e r v i c e s ,   y o u   h a v e   a   c o n t i n u o u s l y   r u n n i n g ,   r e p l i c a t e d   a p p l i c a t i o n ,   t h a t   i s   e x p o s e d   o n   a   n e t w o r k .   T h i s   t u t o r i a l   h e l p s   y o u   l o o k   a t   t h e   t e r m i n a t i o n   f l o w   f o r   P o d s   a n d   t o   e x p l o r e   w a y s   t o   i m p l e m e n t   g r a c e f u l   c o n n e c t i o n   d r a i n i n g .


Question: What is Termination process for Pods and their endpoints?

Answer: T h e r e   a r e   o f t e n   c a s e s   w h e n   y o u   n e e d   t o   t e r m i n a t e   a   P o d   -   b e   i t   t o   u p g r a d e   o r   s c a l e   d o w n .   I n   o r d e r   t o   i m p r o v e   a p p l i c a t i o n   a v a i l a b i l i t y ,   i t   m a y   b e   i m p o r t a n t   t o   i m p l e m e n t   a   p r o p e r   a c t i v e   c o n n e c t i o n s   d r a i n i n g .   T h i s   t u t o r i a l   e x p l a i n s   t h e   f l o w   o f   P o d   t e r m i n a t i o n   i n   c o n n e c t i o n   w i t h   t h e   c o r r e s p o n d i n g   e n d p o i n t   s t a t e   a n d   r e m o v a l   b y   u s i n g   a   s i m p l e   n g i n x   w e b   s e r v e r   t o   d e m o n s t r a t e   t h e   c o n c e p t .


Question: What is Example flow with endpoint termination?

Answer: T h e   f o l l o w i n g   i s   t h e   e x a m p l e   f l o w   d e s c r i b e d   i n   t h e   T e r m i n a t i o n   o f   P o d s   d o c u m e n t .   L e t ' s   s a y   y o u   h a v e   a   D e p l o y m e n t   c o n t a i n i n g   a   s i n g l e   n g i n x   r e p l i c a   ( s a y   j u s t   f o r   t h e   s a k e   o f   d e m o n s t r a t i o n   p u r p o s e s )   a n d   a   S e r v i c e :   a p i V e r s i o n :   a p p s / v 1   k i n d :   D e p l o y m e n t   m e t a d a t a :   n a m e :   n g i n x - d e p l o y m e n t   l a b e l s :   a p p :   n g i n x   s p e c :   r e p l i c a s :   1   s e l e c t o r :   m a t c h L a b e l s :   a p p :   n g i n x   t e m p l a t e :   m e t a d a t a :   l a b e l s :   a p p :   n g i n x   s p e c :   t e r m i n a t i o n G r a c e P e r i o d S e c o n d s :   1 2 0   #   e x t r a   l o n g   g r a c e   p e r i o d   c o n t a i n e r s :   -   n a m e :   n g i n x   i m a g e :   n g i n x : l a t e s t   p o r t s :   -   c o n t a i n e r P o r t :   8 0   l i f e c y c l e :   p r e S t o p :   e x e c :   #   R e a l   l i f e   t e r m i n a t i o n   m a y   t a k e   a n y   t i m e   u p   t o   t e r m i n a t i o n G r a c e P e r i o d S e c o n d s .   #   I n   t h i s   e x a m p l e   -   j u s t   h a n g   a r o u n d   f o r   a t   l e a s t   t h e   d u r a t i o n   o f   t e r m i n a t i o n G r a c e P e r i o d S e c o n d s ,   #   a t   1 2 0   s e c o n d s   c o n t a i n e r   w i l l   b e   f o r c i b l y   t e r m i n a t e d .   #   N o t e ,   a l l   t h i s   t i m e   n g i n x   w i l l   k e e p   p r o c e s s i n g   r e q u e s t s .   c o m m a n d :   [   " / b i n / s h " ,   " - c " ,   " s l e e p   1 8 0 "   ]   a p i V e r s i o n :   v 1   k i n d :   S e r v i c e   m e t a d a t a :   n a m e :   n g i n x - s e r v i c e   s p e c :   s e l e c t o r :   a p p :   n g i n x   p o r t s :   -   p r o t o c o l :   T C P


Question: What is What's next?

Answer: L e a r n   h o w   t o   C o n n e c t   A p p l i c a t i o n s   w i t h   S e r v i c e s L e a r n   m o r e   a b o u t   U s i n g   a   S e r v i c e   t o   A c c e s s   a n   A p p l i c a t i o n   i n   a   C l u s t e r L e a r n   m o r e   a b o u t   C o n n e c t i n g   a   F r o n t   E n d   t o   a   B a c k   E n d   U s i n g   a   S e r v i c e L e a r n   m o r e   a b o u t   C r e a t i n g   a n   E x t e r n a l   L o a d   B a l a n c e r   ©   2 0 2 5   T h e   K u b e r n e t e s   A u t h o r s   |   D o c u m e n t a t i o n   D i s t r i b u t e d   u n d e r   C C   B Y   4 . 0   ©   2 0 2 5   T h e   L i n u x   F o u n d a t i o n   ® .   A l l   r i g h t s   r e s e r v e d .   T h e   L i n u x   F o u n d a t i o n   h a s   r e g i s t e r e d   t r a d e m a r k s   a n d   u s e s   t r a d e m a r k s .   F o r   a   l i s t   o f   t r a d e m a r k s   o f   T h e   L i n u x   F o u n d a t i o n ,   p l e a s e   s e e   o u r   T r a d e m a r k   U s a g e   p a g e   I C P   l i c e n s e :   京 I C P 备 1 7 0 7 4 2 6 6 号 - 3


Question: What is Stateful Applications?

Answer: This is the multi-page printable view of this section. Click here to print.Return to the regular view of this page.Stateful Applications1: StatefulSet Basics2: Example: Deploying WordPress and MySQL with Persistent Volumes3: Example: Deploying Cassandra with a StatefulSet4: Running ZooKeeper, A Distributed System Coordinator1 - StatefulSet BasicsThis tutorial provides an introduction to managing applications with StatefulSets. It demonstrates how to create, delete, scale, and update the Pods of StatefulSets.Before you beginBefore you begin this tutorial, you should familiarize yourself with the following Kubernetes concepts:PodsCluster DNSHeadless ServicesPersistentVolumesPersistentVolume ProvisioningThe kubectl command line toolYou need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. It is recommended to run this tutorial on a cluster with at least two nodes that are not acting as control plane hosts. If you do not already have a cluster, you can create one by using minikube or you can use one of these Kubernetes playgrounds:iximiuz LabsKillercodaKodeKloudPlay with KubernetesYou should configure kubectl to use a context that uses the default namespace. If you are using an existing cluster, make sure that it's OK to use that cluster's default namespace to practice. Ideally, practice in a cluster that doesn't run any real workloads.It's also useful to read the concept page about StatefulSets.Note:This tutorial assumes that your cluster is configured to dynamically provision PersistentVolumes. You'll also need to have a default StorageClass. If your cluster is not configured to provision storage dynamically, you will have to manually provision two 1 GiB volumes prior to starting this tutorial and set up your cluster so that those PersistentVolumes map to the PersistentVolumeClaim templates that the StatefulSet defines.ObjectivesStatefulSets are intended to be used with stateful applications and distributed systems. However, the administration of stateful applications and distributed systems on Kubernetes is a broad, complex topic. In order to demonstrate the basic features of a StatefulSet, and not to conflate the former topic with the latter, you will deploy a simple web application using a StatefulSet.After this tutorial, you will be familiar with the following.How to create a StatefulSetHow a StatefulSet manages its PodsHow to delete a StatefulSetHow to scale a StatefulSetHow to update a StatefulSet's PodsCreating a StatefulSetBegin by creating a StatefulSet (and the Service that it relies upon) using the example below. It is similar to the example presented in the StatefulSets concept. It creates a headless Service, nginx, to publish the IP addresses of Pods in the StatefulSet, web.application/web/web.yaml apiVersion: v1 kind: Service metadata: name: nginx labels: app: nginx spec: ports: - port: 80 name: web clusterIP: None selector: app: nginx --- apiVersion: apps/v1 kind: St


Question: How does Stateful Applications work?

Answer: This is the multi-page printable view of this section. Click here to print.Return to the regular view of this page.Stateful Applications1: StatefulSet Basics2: Example: Deploying WordPress and MySQL with Persistent Volumes3: Example: Deploying Cassandra with a StatefulSet4: Running ZooKeeper, A Distributed System Coordinator1 - StatefulSet BasicsThis tutorial provides an introduction to managing applications with StatefulSets. It demonstrates how to create, delete, scale, and update the Pods of StatefulSets.Before you beginBefore you begin this tutorial, you should familiarize yourself with the following Kubernetes concepts:PodsCluster DNSHeadless ServicesPersistentVolumesPersistentVolume ProvisioningThe kubectl command line toolYou need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. It is recommended to run this tutorial on a cluster with at least two nodes that are not acting as control plane hosts. If you do not already have a cluster, you can create one by using minikube or you can use one of these Kubernetes playgrounds:iximiuz LabsKillercodaKodeKloudPlay with KubernetesYou should configure kubectl to use a context that uses the default namespace. If you are using an existing cluster, make sure that it's OK to use that cluster's default namespace to practice. Ideally, practice in a cluster that doesn't run any real workloads.It's also useful to read the concept page about StatefulSets.Note:This tutorial assumes that your cluster is configured to dynamically provision PersistentVolumes. You'll also need to have a default StorageClass. If your cluster is not configured to provision storage dynamically, you will have to manually provision two 1 GiB volumes prior to starting this tutorial and set up your cluster so that those PersistentVolumes map to the PersistentVolumeClaim templates that the StatefulSet defines.ObjectivesStatefulSets are intended to be used with stateful applications and distributed systems. However, the administration of stateful applications and distributed systems on Kubernetes is a broad, complex topic. In order to demonstrate the basic features of a StatefulSet, and not to conflate the former topic with the latter, you will deploy a simple web application using a StatefulSet.After this tutorial, you will be familiar with the following.How to create a StatefulSetHow a StatefulSet manages its PodsHow to delete a StatefulSetHow to scale a StatefulSetHow to update a StatefulSet's PodsCreating a StatefulSetBegin by creating a StatefulSet (and the Service that it relies upon) using the example below. It is similar to the example presented in the StatefulSets concept. It creates a headless Service, nginx, to publish the IP addresses of Pods in the StatefulSet, web.application/web/web.yaml apiVersion: v1 kind: Service metadata: name: nginx labels: app: nginx spec: ports: - port: 80 name: web clusterIP: None selector: app: nginx --- apiVersion: apps/v1 kind: St


Question: When would you use Stateful Applications?

Answer: This is the multi-page printable view of this section. Click here to print.Return to the regular view of this page.Stateful Applications1: StatefulSet Basics2: Example: Deploying WordPress and MySQL with Persistent Volumes3: Example: Deploying Cassandra with a StatefulSet4: Running ZooKeeper, A Distributed System Coordinator1 - StatefulSet BasicsThis tutorial provides an introduction to managing applications with StatefulSets. It demonstrates how to create, delete, scale, and update the Pods of StatefulSets.Before you beginBefore you begin this tutorial, you should familiarize yourself with the following Kubernetes concepts:PodsCluster DNSHeadless ServicesPersistentVolumesPersistentVolume ProvisioningThe kubectl command line toolYou need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. It is recommended to run this tutorial on a cluster with at least two nodes that are not acting as control plane hosts. If you do not already have a cluster, you can create one by using minikube or you can use one of these Kubernetes playgrounds:iximiuz LabsKillercodaKodeKloudPlay with KubernetesYou should configure kubectl to use a context that uses the default namespace. If you are using an existing cluster, make sure that it's OK to use that cluster's default namespace to practice. Ideally, practice in a cluster that doesn't run any real workloads.It's also useful to read the concept page about StatefulSets.Note:This tutorial assumes that your cluster is configured to dynamically provision PersistentVolumes. You'll also need to have a default StorageClass. If your cluster is not configured to provision storage dynamically, you will have to manually provision two 1 GiB volumes prior to starting this tutorial and set up your cluster so that those PersistentVolumes map to the PersistentVolumeClaim templates that the StatefulSet defines.ObjectivesStatefulSets are intended to be used with stateful applications and distributed systems. However, the administration of stateful applications and distributed systems on Kubernetes is a broad, complex topic. In order to demonstrate the basic features of a StatefulSet, and not to conflate the former topic with the latter, you will deploy a simple web application using a StatefulSet.After this tutorial, you will be familiar with the following.How to create a StatefulSetHow a StatefulSet manages its PodsHow to delete a StatefulSetHow to scale a StatefulSetHow to update a StatefulSet's PodsCreating a StatefulSetBegin by creating a StatefulSet (and the Service that it relies upon) using the example below. It is similar to the example presented in the StatefulSets concept. It creates a headless Service, nginx, to publish the IP addresses of Pods in the StatefulSet, web.application/web/web.yaml apiVersion: v1 kind: Service metadata: name: nginx labels: app: nginx spec: ports: - port: 80 name: web clusterIP: None selector: app: nginx --- apiVersion: apps/v1 kind: St


Question: What are the benefits of Stateful Applications?

Answer: This is the multi-page printable view of this section. Click here to print.Return to the regular view of this page.Stateful Applications1: StatefulSet Basics2: Example: Deploying WordPress and MySQL with Persistent Volumes3: Example: Deploying Cassandra with a StatefulSet4: Running ZooKeeper, A Distributed System Coordinator1 - StatefulSet BasicsThis tutorial provides an introduction to managing applications with StatefulSets. It demonstrates how to create, delete, scale, and update the Pods of StatefulSets.Before you beginBefore you begin this tutorial, you should familiarize yourself with the following Kubernetes concepts:PodsCluster DNSHeadless ServicesPersistentVolumesPersistentVolume ProvisioningThe kubectl command line toolYou need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. It is recommended to run this tutorial on a cluster with at least two nodes that are not acting as control plane hosts. If you do not already have a cluster, you can create one by using minikube or you can use one of these Kubernetes playgrounds:iximiuz LabsKillercodaKodeKloudPlay with KubernetesYou should configure kubectl to use a context that uses the default namespace. If you are using an existing cluster, make sure that it's OK to use that cluster's default namespace to practice. Ideally, practice in a cluster that doesn't run any real workloads.It's also useful to read the concept page about StatefulSets.Note:This tutorial assumes that your cluster is configured to dynamically provision PersistentVolumes. You'll also need to have a default StorageClass. If your cluster is not configured to provision storage dynamically, you will have to manually provision two 1 GiB volumes prior to starting this tutorial and set up your cluster so that those PersistentVolumes map to the PersistentVolumeClaim templates that the StatefulSet defines.ObjectivesStatefulSets are intended to be used with stateful applications and distributed systems. However, the administration of stateful applications and distributed systems on Kubernetes is a broad, complex topic. In order to demonstrate the basic features of a StatefulSet, and not to conflate the former topic with the latter, you will deploy a simple web application using a StatefulSet.After this tutorial, you will be familiar with the following.How to create a StatefulSetHow a StatefulSet manages its PodsHow to delete a StatefulSetHow to scale a StatefulSetHow to update a StatefulSet's PodsCreating a StatefulSetBegin by creating a StatefulSet (and the Service that it relies upon) using the example below. It is similar to the example presented in the StatefulSets concept. It creates a headless Service, nginx, to publish the IP addresses of Pods in the StatefulSet, web.application/web/web.yaml apiVersion: v1 kind: Service metadata: name: nginx labels: app: nginx spec: ports: - port: 80 name: web clusterIP: None selector: app: nginx --- apiVersion: apps/v1 kind: St


Question: What is Stateful Applications?

Answer: 1 :   S t a t e f u l S e t   B a s i c s 2 :   E x a m p l e :   D e p l o y i n g   W o r d P r e s s   a n d   M y S Q L   w i t h   P e r s i s t e n t   V o l u m e s 3 :   E x a m p l e :   D e p l o y i n g   C a s s a n d r a   w i t h   a   S t a t e f u l S e t 4 :   R u n n i n g   Z o o K e e p e r ,   A   D i s t r i b u t e d   S y s t e m   C o o r d i n a t o r


Question: What is 1 - StatefulSet Basics?

Answer: T h i s   t u t o r i a l   p r o v i d e s   a n   i n t r o d u c t i o n   t o   m a n a g i n g   a p p l i c a t i o n s   w i t h   S t a t e f u l S e t s .   I t   d e m o n s t r a t e s   h o w   t o   c r e a t e ,   d e l e t e ,   s c a l e ,   a n d   u p d a t e   t h e   P o d s   o f   S t a t e f u l S e t s .


Question: What is Before you begin?

Answer: B e f o r e   y o u   b e g i n   t h i s   t u t o r i a l ,   y o u   s h o u l d   f a m i l i a r i z e   y o u r s e l f   w i t h   t h e   f o l l o w i n g   K u b e r n e t e s   c o n c e p t s :   P o d s C l u s t e r   D N S H e a d l e s s   S e r v i c e s P e r s i s t e n t V o l u m e s P e r s i s t e n t V o l u m e   P r o v i s i o n i n g T h e   k u b e c t l   c o m m a n d   l i n e   t o o l   Y o u   n e e d   t o   h a v e   a   K u b e r n e t e s   c l u s t e r ,   a n d   t h e   k u b e c t l   c o m m a n d - l i n e   t o o l   m u s t   b e   c o n f i g u r e d   t o   c o m m u n i c a t e   w i t h   y o u r   c l u s t e r .   I t   i s   r e c o m m e n d e d   t o   r u n   t h i s   t u t o r i a l   o n   a   c l u s t e r   w i t h   a t   l e a s t   t w o   n o d e s   t h a t   a r e   n o t   a c t i n g   a s   c o n t r o l   p l a n e   h o s t s .   I f   y o u   d o   n o t   a l r e a d y   h a v e   a   c l u s t e r ,   y o u   c a n   c r e a t e   o n e   b y   u s i n g   m i n i k u b e   o r   y o u   c a n   u s e   o n e   o f   t h e s e   K u b e r n e t e s   p l a y g r o u n d s :   i x i m i u z   L a b s K i l l e r c o d a K o d e K l o u d P l a y   w i t h   K u b e r n e t e s   Y o u   s h o u l d   c o n f i g u r e   k u b e c t l   t o   u s e   a   c o n t e x t   t h a t   u s e s   t h e   d e f a u l t   n a m e s p a c e .   I f   y o u   a r e   u s i n g   a n   e x i s t i n g   c l u s t e r ,   m a k e   s u r e   t h a t   i t ' s   O K   t o   u s e   t h a t   c l u s t e r ' s   d e f a u l t   n a m e s p a c e   t o   p r a c t i c e .   I d e a l l y ,   p r a c t i c e   i n   a   c l u s t e r   t h a t   d o e s n ' t   r u n   a n y   r e a l   w o r k l o a d s .   I t ' s   a l s o   u s e f u l   t o   r e a d   t h e   c o n c e p t   p a g e   a b o u t   S t a t e f u l S e t s .


Question: What is Objectives?

Answer: S t a t e f u l S e t s   a r e   i n t e n d e d   t o   b e   u s e d   w i t h   s t a t e f u l   a p p l i c a t i o n s   a n d   d i s t r i b u t e d   s y s t e m s .   H o w e v e r ,   t h e   a d m i n i s t r a t i o n   o f   s t a t e f u l   a p p l i c a t i o n s   a n d   d i s t r i b u t e d   s y s t e m s   o n   K u b e r n e t e s   i s   a   b r o a d ,   c o m p l e x   t o p i c .   I n   o r d e r   t o   d e m o n s t r a t e   t h e   b a s i c   f e a t u r e s   o f   a   S t a t e f u l S e t ,   a n d   n o t   t o   c o n f l a t e   t h e   f o r m e r   t o p i c   w i t h   t h e   l a t t e r ,   y o u   w i l l   d e p l o y   a   s i m p l e   w e b   a p p l i c a t i o n   u s i n g   a   S t a t e f u l S e t .   A f t e r   t h i s   t u t o r i a l ,   y o u   w i l l   b e   f a m i l i a r   w i t h   t h e   f o l l o w i n g .   H o w   t o   c r e a t e   a   S t a t e f u l S e t H o w   a   S t a t e f u l S e t   m a n a g e s   i t s   P o d s H o w   t o   d e l e t e   a   S t a t e f u l S e t H o w   t o   s c a l e   a   S t a t e f u l S e t H o w   t o   u p d a t e   a   S t a t e f u l S e t ' s   P o d s


Question: What is Creating a StatefulSet?

Answer: B e g i n   b y   c r e a t i n g   a   S t a t e f u l S e t   ( a n d   t h e   S e r v i c e   t h a t   i t   r e l i e s   u p o n )   u s i n g   t h e   e x a m p l e   b e l o w .   I t   i s   s i m i l a r   t o   t h e   e x a m p l e   p r e s e n t e d   i n   t h e   S t a t e f u l S e t s   c o n c e p t .   I t   c r e a t e s   a   h e a d l e s s   S e r v i c e ,   n g i n x ,   t o   p u b l i s h   t h e   I P   a d d r e s s e s   o f   P o d s   i n   t h e   S t a t e f u l S e t ,   w e b .   a p i V e r s i o n :   v 1   k i n d :   S e r v i c e   m e t a d a t a :   n a m e :   n g i n x   l a b e l s :   a p p :   n g i n x   s p e c :   p o r t s :   -   p o r t :   8 0   n a m e :   w e b   c l u s t e r I P :   N o n e   s e l e c t o r :   a p p :   n g i n x   - - -   a p i V e r s i o n :   a p p s / v 1   k i n d :   S t a t e f u l S e t   m e t a d a t a :   n a m e :   w e b   s p e c :   s e r v i c e N a m e :   " n g i n x "   r e p l i c a s :   2   s e l e c t o r :   m a t c h L a b e l s :   a p p :   n g i n x   t e m p l a t e :   m e t a d a t a :   l a b e l s :   a p p :   n g i n x   s p e c :   c o n t a i n e r s :   -   n a m e :   n g i n x   i m a g e :   r e g i s t r y . k 8 s . i o / n g i n x - s l i m : 0 . 2 1   p o r t s :   -   c o n t a i n e r P o r t :   8 0   n a m e :   w e b   v o l u m e M o u n t s :   -   n a m e :   w w w   m o u n t P a t h :   / u s r / s h a r e / n g i n x / h t m l   v o l u m e C l a i m T e m p l a t e s :   -   m e t a d a t a :   n a m e :   w w w   s p e c :   a c c e s s M o d e s :   [   " R e a d W r i t e O n c e "   ]   r e s o u r c e s :   r e q u e s t s :   s t o r a g e :   1 G i   Y o u   w i l l   n e e d   t o   u s e   a t   l e a s t   t w o   t e r m i n a l   w i n d o w s .   I n   t h e   f i r s t   t e r m i n a l ,   u s e   k u b e c t l   g e t   t o   w a t c h   t h e   c r e a t i o n   o f   t h e   S t a t e f u l S e t ' s   P o d s .


Question: What is Ordered Pod creation?

Answer: A   S t a t e f u l S e t   d e f a u l t s   t o   c r e a t i n g   i t s   P o d s   i n   a   s t r i c t   o r d e r .   F o r   a   S t a t e f u l S e t   w i t h   n   r e p l i c a s ,   w h e n   P o d s   a r e   b e i n g   d e p l o y e d ,   t h e y   a r e   c r e a t e d   s e q u e n t i a l l y ,   o r d e r e d   f r o m   { 0 . . n - 1 } .   E x a m i n e   t h e   o u t p u t   o f   t h e   k u b e c t l   g e t   c o m m a n d   i n   t h e   f i r s t   t e r m i n a l .   E v e n t u a l l y ,   t h e   o u t p u t   w i l l   l o o k   l i k e   t h e   e x a m p l e   b e l o w .   #   D o   n o t   s t a r t   a   n e w   w a t c h ;   #   t h i s   s h o u l d   a l r e a d y   b e   r u n n i n g   k u b e c t l   g e t   p o d s   - - w a t c h   - l   a p p = n g i n x   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   w e b - 0   0 / 1   P e n d i n g   0   0 s   w e b - 0   0 / 1   P e n d i n g   0   0 s   w e b - 0   0 / 1   C o n t a i n e r C r e a t i n g   0   0 s   w e b - 0   1 / 1   R u n n i n g   0   1 9 s   w e b - 1   0 / 1   P e n d i n g   0   0 s   w e b - 1   0 / 1   P e n d i n g   0   0 s   w e b - 1   0 / 1   C o n t a i n e r C r e a t i n g   0   0 s   w e b - 1   1 / 1   R u n n i n g   0   1 8 s   N o t i c e   t h a t   t h e   w e b - 1   P o d   i s   n o t   l a u n c h e d   u n t i l   t h e   w e b - 0   P o d   i s   R u n n i n g   ( s e e   P o d   P h a s e )   a n d   R e a d y   ( s e e   t y p e   i n   P o d   C o n d i t i o n s ) .   L a t e r   i n   t h i s   t u t o r i a l   y o u   w i l l   p r a c t i c e   p a r a l l e l   s t a r t u p .


Question: What is Pods in a StatefulSet?

Answer: P o d s   i n   a   S t a t e f u l S e t   h a v e   a   u n i q u e   o r d i n a l   i n d e x   a n d   a   s t a b l e   n e t w o r k   i d e n t i t y .


Question: What is Examining the Pod's ordinal index?

Answer: G e t   t h e   S t a t e f u l S e t ' s   P o d s :   k u b e c t l   g e t   p o d s   - l   a p p = n g i n x   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   w e b - 0   1 / 1   R u n n i n g   0   1 m   w e b - 1   1 / 1   R u n n i n g   0   1 m   A s   m e n t i o n e d   i n   t h e   S t a t e f u l S e t s   c o n c e p t ,   t h e   P o d s   i n   a   S t a t e f u l S e t   h a v e   a   s t i c k y ,   u n i q u e   i d e n t i t y .   T h i s   i d e n t i t y   i s   b a s e d   o n   a   u n i q u e   o r d i n a l   i n d e x   t h a t   i s   a s s i g n e d   t o   e a c h   P o d   b y   t h e   S t a t e f u l S e t   c o n t r o l l e r . T h e   P o d s '   n a m e s   t a k e   t h e   f o r m   < s t a t e f u l s e t   n a m e > - < o r d i n a l   i n d e x > .   S i n c e   t h e   w e b   S t a t e f u l S e t   h a s   t w o   r e p l i c a s ,   i t   c r e a t e s   t w o   P o d s ,   w e b - 0   a n d   w e b - 1 .


Question: What is Using stable network identities?

Answer: E a c h   P o d   h a s   a   s t a b l e   h o s t n a m e   b a s e d   o n   i t s   o r d i n a l   i n d e x .   U s e   k u b e c t l   e x e c   t o   e x e c u t e   t h e   h o s t n a m e   c o m m a n d   i n   e a c h   P o d :   f o r   i   i n   0   1 ;   d o   k u b e c t l   e x e c   " w e b - $ i "   - -   s h   - c   ' h o s t n a m e ' ;   d o n e   w e b - 0   w e b - 1   U s e   k u b e c t l   r u n   t o   e x e c u t e   a   c o n t a i n e r   t h a t   p r o v i d e s   t h e   n s l o o k u p   c o m m a n d   f r o m   t h e   d n s u t i l s   p a c k a g e .   U s i n g   n s l o o k u p   o n   t h e   P o d s '   h o s t n a m e s ,   y o u   c a n   e x a m i n e   t h e i r   i n - c l u s t e r   D N S   a d d r e s s e s :   k u b e c t l   r u n   - i   - - t t y   - - i m a g e   b u s y b o x : 1 . 2 8   d n s - t e s t   - - r e s t a r t = N e v e r   - - r m   w h i c h   s t a r t s   a   n e w   s h e l l .   I n   t h a t   n e w   s h e l l ,   r u n :   #   R u n   t h i s   i n   t h e   d n s - t e s t   c o n t a i n e r   s h e l l   n s l o o k u p   w e b - 0 . n g i n x   T h e   o u t p u t   i s   s i m i l a r   t o :   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   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   N a m e :   w e b - 0 . n g i n x   A d d r e s s   1 :   1 0 . 2 4 4 . 1 . 6   n s l o o k u p   w e b - 1 . n g i n x   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   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   N a m e :   w e b - 1 . n g i n x   A d d r e s s   1 :   1 0 . 2 4 4 . 2 . 6   ( a n d   n o w   e x i t   t h e   c o n t a i n e r   s h e l l :   e x i t )   T h e   C N A M E   o f   t h e   h e a d l e s s   s e r v i c e   p o i n t s   t o   S R V   r e c o r d s   ( o n e   f o r   e a c h   P o d   t h a t   i s   R u n n i n g   a n d   R e a d y ) .   T h


Question: What is Discovery for specific Pods in a StatefulSet?

Answer: I f   y o u   n e e d   t o   f i n d   a n d   c o n n e c t   t o   t h e   a c t i v e   m e m b e r s   o f   a   S t a t e f u l S e t ,   y o u   s h o u l d   q u e r y   t h e   C N A M E   o f   t h e   h e a d l e s s   S e r v i c e   ( n g i n x . d e f a u l t . s v c . c l u s t e r . l o c a l ) .   T h e   S R V   r e c o r d s   a s s o c i a t e d   w i t h   t h e   C N A M E   w i l l   c o n t a i n   o n l y   t h e   P o d s   i n   t h e   S t a t e f u l S e t   t h a t   a r e   R u n n i n g   a n d   R e a d y .   I f   y o u r   a p p l i c a t i o n   a l r e a d y   i m p l e m e n t s   c o n n e c t i o n   l o g i c   t h a t   t e s t s   f o r   l i v e n e s s   a n d   r e a d i n e s s ,   y o u   c a n   u s e   t h e   S R V   r e c o r d s   o f   t h e   P o d s   (   w e b - 0 . n g i n x . d e f a u l t . s v c . c l u s t e r . l o c a l ,   w e b - 1 . n g i n x . d e f a u l t . s v c . c l u s t e r . l o c a l ) ,   a s   t h e y   a r e   s t a b l e ,   a n d   y o u r   a p p l i c a t i o n   w i l l   b e   a b l e   t o   d i s c o v e r   t h e   P o d s '   a d d r e s s e s   w h e n   t h e y   t r a n s i t i o n   t o   R u n n i n g   a n d   R e a d y .   I f   y o u r   a p p l i c a t i o n   w a n t s   t o   f i n d   a n y   h e a l t h y   P o d   i n   a   S t a t e f u l S e t ,   a n d   t h e r e f o r e   d o e s   n o t   n e e d   t o   t r a c k   e a c h   s p e c i f i c   P o d ,   y o u   c o u l d   a l s o   c o n n e c t   t o   t h e   I P   a d d r e s s   o f   a   t y p e :   C l u s t e r I P   S e r v i c e ,   b a c k e d   b y   t h e   P o d s   i n   t h a t   S t a t e f u l S e t .   Y o u   c a n   u s e   t h e   s a m e   S e r v i c e   t h a t   t r a c k s   t h e   S t a t e f u l S e t   ( s p e c i f i e d   i n   t h e   s e r v i c e N a m e   o f   t h e   S t a t e f u l S e t )   o r   a   s e p a r a t e   S e r v i c e   t h a t   s e l e c t s   t h e


Question: What is Writing to stable storage?

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


Question: What is Note:?

Answer: I f   y o u   i n s t e a d   s e e   4 0 3   F o r b i d d e n   r e s p o n s e s   f o r   t h e   a b o v e   c u r l   c o m m a n d ,   y o u   w i l l   n e e d   t o   f i x   t h e   p e r m i s s i o n s   o f   t h e   d i r e c t o r y   m o u n t e d   b y   t h e   v o l u m e M o u n t s   ( d u e   t o   a   b u g   w h e n   u s i n g   h o s t P a t h   v o l u m e s ) ,   b y   r u n n i n g :   f o r   i   i n   0   1 ;   d o   k u b e c t l   e x e c   w e b - $ i   - -   c h m o d   7 5 5   / u s r / s h a r e / n g i n x / h t m l ;   d o n e   b e f o r e   r e t r y i n g   t h e   c u r l   c o m m a n d   a b o v e .   I n   o n e   t e r m i n a l ,   w a t c h   t h e   S t a t e f u l S e t ' s   P o d s :   #   E n d   t h i s   w a t c h   w h e n   y o u ' v e   r e a c h e d   t h e   e n d   o f   t h e   s e c t i o n .   #   A t   t h e   s t a r t   o f   " S c a l i n g   a   S t a t e f u l S e t "   y o u ' l l   s t a r t   a   n e w   w a t c h .   k u b e c t l   g e t   p o d   - - w a t c h   - l   a p p = n g i n x   I n   a   s e c o n d   t e r m i n a l ,   d e l e t e   a l l   o f   t h e   S t a t e f u l S e t ' s   P o d s :   k u b e c t l   d e l e t e   p o d   - l   a p p = n g i n x   p o d   " w e b - 0 "   d e l e t e d   p o d   " w e b - 1 "   d e l e t e d   E x a m i n e   t h e   o u t p u t   o f   t h e   k u b e c t l   g e t   c o m m a n d   i n   t h e   f i r s t   t e r m i n a l ,   a n d   w a i t   f o r   a l l   o f   t h e   P o d s   t o   t r a n s i t i o n   t o   R u n n i n g   a n d   R e a d y .   #   T h i s   s h o u l d   a l r e a d y   b e   r u n n i n g   k u b e c t l   g e t   p o d   - - w a t c h   - l   a p p = n g i n x   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   w e b - 0   0 / 1   C o n t a i n e r C r e a t i n g   0   0 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   w e b - 0   1 / 1   R u n n i n g   0   2 s   w e b - 1


Question: What is Scaling a StatefulSet?

Answer: S c a l i n g   a   S t a t e f u l S e t   r e f e r s   t o   i n c r e a s i n g   o r   d e c r e a s i n g   t h e   n u m b e r   o f   r e p l i c a s   ( h o r i z o n t a l   s c a l i n g ) .   T h i s   i s   a c c o m p l i s h e d   b y   u p d a t i n g   t h e   r e p l i c a s   f i e l d .   Y o u   c a n   u s e   e i t h e r   k u b e c t l   s c a l e   o r   k u b e c t l   p a t c h   t o   s c a l e   a   S t a t e f u l S e t .


Question: What is Scaling up?

Answer: S c a l i n g   u p   m e a n s   a d d i n g   m o r e   r e p l i c a s .   P r o v i d e d   t h a t   y o u r   a p p   i s   a b l e   t o   d i s t r i b u t e   w o r k   a c r o s s   t h e   S t a t e f u l S e t ,   t h e   n e w   l a r g e r   s e t   o f   P o d s   c a n   p e r f o r m   m o r e   o f   t h a t   w o r k .   I n   o n e   t e r m i n a l   w i n d o w ,   w a t c h   t h e   P o d s   i n   t h e   S t a t e f u l S e t :   #   I f   y o u   a l r e a d y   h a v e   a   w a t c h   r u n n i n g ,   y o u   c a n   c o n t i n u e   u s i n g   t h a t .   #   O t h e r w i s e ,   s t a r t   o n e .   #   E n d   t h i s   w a t c h   w h e n   t h e r e   a r e   5   h e a l t h y   P o d s   f o r   t h e   S t a t e f u l S e t   k u b e c t l   g e t   p o d s   - - w a t c h   - l   a p p = n g i n x   I n   a n o t h e r   t e r m i n a l   w i n d o w ,   u s e   k u b e c t l   s c a l e   t o   s c a l e   t h e   n u m b e r   o f   r e p l i c a s   t o   5 :   k u b e c t l   s c a l e   s t s   w e b   - - r e p l i c a s = 5   s t a t e f u l s e t . a p p s / w e b   s c a l e d   E x a m i n e   t h e   o u t p u t   o f   t h e   k u b e c t l   g e t   c o m m a n d   i n   t h e   f i r s t   t e r m i n a l ,   a n d   w a i t   f o r   t h e   t h r e e   a d d i t i o n a l   P o d s   t o   t r a n s i t i o n   t o   R u n n i n g   a n d   R e a d y .   #   T h i s   s h o u l d   a l r e a d y   b e   r u n n i n g   k u b e c t l   g e t   p o d   - - w a t c h   - l   a p p = n g i n x   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   w e b - 0   1 / 1   R u n n i n g   0   2 h   w e b - 1   1 / 1   R u n n i n g   0   2 h   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   w e b - 2   0 / 1   P e n d i n g   0   0 s   w e b - 2   0 / 1   P e n d i n g   0   0 s   w e b - 2   0 / 1   C o n t a i n e r C r e a t i n g   0   0 s   w e b - 2   1 / 1   R u n n i n g   0   1 9 s   w


Question: What is Scaling down?

Answer: S c a l i n g   d o w n   m e a n s   r e d u c i n g   t h e   n u m b e r   o f   r e p l i c a s .   F o r   e x a m p l e ,   y o u   m i g h t   d o   t h i s   b e c a u s e   t h e   l e v e l   o f   t r a f f i c   t o   a   s e r v i c e   h a s   d e c r e a s e d ,   a n d   a t   t h e   c u r r e n t   s c a l e   t h e r e   a r e   i d l e   r e s o u r c e s .   I n   o n e   t e r m i n a l ,   w a t c h   t h e   S t a t e f u l S e t ' s   P o d s :   #   E n d   t h i s   w a t c h   w h e n   t h e r e   a r e   o n l y   3   P o d s   f o r   t h e   S t a t e f u l S e t   k u b e c t l   g e t   p o d   - - w a t c h   - l   a p p = n g i n x   I n   a n o t h e r   t e r m i n a l ,   u s e   k u b e c t l   p a t c h   t o   s c a l e   t h e   S t a t e f u l S e t   b a c k   d o w n   t o   t h r e e   r e p l i c a s :   k u b e c t l   p a t c h   s t s   w e b   - p   ' { " s p e c " : { " r e p l i c a s " : 3 } } '   s t a t e f u l s e t . a p p s / w e b   p a t c h e d   W a i t   f o r   w e b - 4   a n d   w e b - 3   t o   t r a n s i t i o n   t o   T e r m i n a t i n g .   #   T h i s   s h o u l d   a l r e a d y   b e   r u n n i n g   k u b e c t l   g e t   p o d s   - - w a t c h   - l   a p p = n g i n x   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   w e b - 0   1 / 1   R u n n i n g   0   3 h   w e b - 1   1 / 1   R u n n i n g   0   3 h   w e b - 2   1 / 1   R u n n i n g   0   5 5 s   w e b - 3   1 / 1   R u n n i n g   0   3 6 s   w e b - 4   0 / 1   C o n t a i n e r C r e a t i n g   0   1 8 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   w e b - 4   1 / 1   R u n n i n g   0   1 9 s   w e b - 4   1 / 1   T e r m i n a t i n g   0   2 4 s   w e b - 4   1 / 1   T e r m i n a t i n g   0   2 4 s   w e b - 3   1 / 1   T e r m i n a t i n g   0   4 2 s   w e b - 3   1 / 1   T e r m i n a t i n g   0   4 2 s


Question: What is Ordered Pod termination?

Answer: T h e   c o n t r o l   p l a n e   d e l e t e d   o n e   P o d   a t   a   t i m e ,   i n   r e v e r s e   o r d e r   w i t h   r e s p e c t   t o   i t s   o r d i n a l   i n d e x ,   a n d   i t   w a i t e d   f o r   e a c h   P o d   t o   b e   c o m p l e t e l y   s h u t   d o w n   b e f o r e   d e l e t i n g   t h e   n e x t   o n e .   G e t   t h e   S t a t e f u l S e t ' s   P e r s i s t e n t V o l u m e C l a i m s :   k u b e c t l   g e t   p v c   - l   a p p = n g i n x   N A M E   S T A T U S   V O L U M E   C A P A C I T Y   A C C E S S M O D E S   A G E   w w w - w e b - 0   B o u n d   p v c - 1 5 c 2 6 8 c 7 - b 5 0 7 - 1 1 e 6 - 9 3 2 f - 4 2 0 1 0 a 8 0 0 0 0 2   1 G i   R W O   1 3 h   w w w - w e b - 1   B o u n d   p v c - 1 5 c 7 9 3 0 7 - b 5 0 7 - 1 1 e 6 - 9 3 2 f - 4 2 0 1 0 a 8 0 0 0 0 2   1 G i   R W O   1 3 h   w w w - w e b - 2   B o u n d   p v c - e 1 1 2 5 b 2 7 - b 5 0 8 - 1 1 e 6 - 9 3 2 f - 4 2 0 1 0 a 8 0 0 0 0 2   1 G i   R W O   1 3 h   w w w - w e b - 3   B o u n d   p v c - e 1 1 7 6 d f 6 - b 5 0 8 - 1 1 e 6 - 9 3 2 f - 4 2 0 1 0 a 8 0 0 0 0 2   1 G i   R W O   1 3 h   w w w - w e b - 4   B o u n d   p v c - e 1 1 b b 5 f 8 - b 5 0 8 - 1 1 e 6 - 9 3 2 f - 4 2 0 1 0 a 8 0 0 0 0 2   1 G i   R W O   1 3 h   T h e r e   a r e   s t i l l   f i v e   P e r s i s t e n t V o l u m e C l a i m s   a n d   f i v e   P e r s i s t e n t V o l u m e s .   W h e n   e x p l o r i n g   a   P o d ' s   s t a b l e   s t o r a g e ,   y o u   s a w   t h a t   t h e   P e r s i s t e n t V o l u m e s   m o u n t e d   t o   t h e   P o d s   o f   a   S t a t e f u l S e t   a r e   n o t   d e l e t e d   w h e n   t h e   S t a t e f u l S e t ' s   P o d s   a r e   d e l e t e d .   T h i s   i s   s t i l l   t r u e   w h e n   P o d   d e l e t i o n   i s   c a u s e d   b y   s c a l i n g   t h e   S t a t e f u l S e t   d o w n .


Question: What is Updating StatefulSets?

Answer: T h e   S t a t e f u l S e t   c o n t r o l l e r   s u p p o r t s   a u t o m a t e d   u p d a t e s .   T h e   s t r a t e g y   u s e d   i s   d e t e r m i n e d   b y   t h e   s p e c . u p d a t e S t r a t e g y   f i e l d   o f   t h e   S t a t e f u l S e t   A P I   o b j e c t .   T h i s   f e a t u r e   c a n   b e   u s e d   t o   u p g r a d e   t h e   c o n t a i n e r   i m a g e s ,   r e s o u r c e   r e q u e s t s   a n d / o r   l i m i t s ,   l a b e l s ,   a n d   a n n o t a t i o n s   o f   t h e   P o d s   i n   a   S t a t e f u l S e t .   T h e r e   a r e   t w o   v a l i d   u p d a t e   s t r a t e g i e s ,   R o l l i n g U p d a t e   ( t h e   d e f a u l t )   a n d   O n D e l e t e .


Question: What is RollingUpdate?

Answer: T h e   R o l l i n g U p d a t e   u p d a t e   s t r a t e g y   w i l l   u p d a t e   a l l   P o d s   i n   a   S t a t e f u l S e t ,   i n   r e v e r s e   o r d i n a l   o r d e r ,   w h i l e   r e s p e c t i n g   t h e   S t a t e f u l S e t   g u a r a n t e e s .   Y o u   c a n   s p l i t   u p d a t e s   t o   a   S t a t e f u l S e t   t h a t   u s e s   t h e   R o l l i n g U p d a t e   s t r a t e g y   i n t o   p a r t i t i o n s ,   b y   s p e c i f y i n g   . s p e c . u p d a t e S t r a t e g y . r o l l i n g U p d a t e . p a r t i t i o n .   Y o u ' l l   p r a c t i c e   t h a t   l a t e r   i n   t h i s   t u t o r i a l .   F i r s t ,   t r y   a   s i m p l e   r o l l i n g   u p d a t e .   I n   o n e   t e r m i n a l   w i n d o w ,   p a t c h   t h e   w e b   S t a t e f u l S e t   t o   c h a n g e   t h e   c o n t a i n e r   i m a g e   a g a i n :   k u b e c t l   p a t c h   s t a t e f u l s e t   w e b   - - t y p e = ' j s o n '   - p = ' [ { " o p " :   " r e p l a c e " ,   " p a t h " :   " / s p e c / t e m p l a t e / s p e c / c o n t a i n e r s / 0 / i m a g e " ,   " v a l u e " : " r e g i s t r y . k 8 s . i o / n g i n x - s l i m : 0 . 2 4 " } ] '   s t a t e f u l s e t . a p p s / w e b   p a t c h e d   I n   a n o t h e r   t e r m i n a l ,   w a t c h   t h e   P o d s   i n   t h e   S t a t e f u l S e t :   #   E n d   t h i s   w a t c h   w h e n   t h e   r o l l o u t   i s   c o m p l e t e   #   #   I f   y o u ' r e   n o t   s u r e ,   l e a v e   i t   r u n n i n g   o n e   m o r e   m i n u t e   k u b e c t l   g e t   p o d   - l   a p p = n g i n x   - - w a t c h   T h e   o u t p u t   i s   s i m i l a r   t 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   w e b - 0   1 / 1   R u n n i n g   0   7 m   w e b - 1   1 / 1   R u n n i n g   0   7 m   w e b - 2   1 / 1   R u n n i n g   0   8 m   w e b - 2   1 / 1   T e r m i n a t i n g


Question: What is Staging an update?

Answer: Y o u   c a n   s p l i t   u p d a t e s   t o   a   S t a t e f u l S e t   t h a t   u s e s   t h e   R o l l i n g U p d a t e   s t r a t e g y   i n t o   p a r t i t i o n s ,   b y   s p e c i f y i n g   . s p e c . u p d a t e S t r a t e g y . r o l l i n g U p d a t e . p a r t i t i o n .   F o r   m o r e   c o n t e x t ,   y o u   c a n   r e a d   P a r t i t i o n e d   r o l l i n g   u p d a t e s   i n   t h e   S t a t e f u l S e t   c o n c e p t   p a g e .   Y o u   c a n   s t a g e   a n   u p d a t e   t o   a   S t a t e f u l S e t   b y   u s i n g   t h e   p a r t i t i o n   f i e l d   w i t h i n   . s p e c . u p d a t e S t r a t e g y . r o l l i n g U p d a t e .   F o r   t h i s   u p d a t e ,   y o u   w i l l   k e e p   t h e   e x i s t i n g   P o d s   i n   t h e   S t a t e f u l S e t   u n c h a n g e d   w h i l s t   y o u   c h a n g e   t h e   p o d   t e m p l a t e   f o r   t h e   S t a t e f u l S e t .   T h e n   y o u   -   o r ,   o u t s i d e   o f   a   t u t o r i a l ,   s o m e   e x t e r n a l   a u t o m a t i o n   -   c a n   t r i g g e r   t h a t   p r e p a r e d   u p d a t e .   F i r s t ,   p a t c h   t h e   w e b   S t a t e f u l S e t   t o   a d d   a   p a r t i t i o n   t o   t h e   u p d a t e S t r a t e g y   f i e l d :   #   T h e   v a l u e   o f   " p a r t i t i o n "   d e t e r m i n e s   w h i c h   o r d i n a l s   a   c h a n g e   a p p l i e s   t o   #   M a k e   s u r e   t o   u s e   a   n u m b e r   b i g g e r   t h a n   t h e   l a s t   o r d i n a l   f o r   t h e   #   S t a t e f u l S e t   k u b e c t l   p a t c h   s t a t e f u l s e t   w e b   - p   ' { " s p e c " : { " u p d a t e S t r a t e g y " : { " t y p e " : " R o l l i n g U p d a t e " , " r o l l i n g U p d a t e " : { " p a r t i t i o n " : 3 } } } } '   s t a t e f u l s e t . a p p s / w e b   p a t c h e d   P a t c h   t h e   S t a t e f u l S e t   a g a i n


Question: What is Rolling out a canary?

Answer: Y o u ' r e   n o w   g o i n g   t o   t r y   a   c a n a r y   r o l l o u t   o f   t h a t   s t a g e d   c h a n g e .   Y o u   c a n   r o l l   o u t   a   c a n a r y   ( t o   t e s t   t h e   m o d i f i e d   t e m p l a t e )   b y   d e c r e m e n t i n g   t h e   p a r t i t i o n   y o u   s p e c i f i e d   a b o v e .   P a t c h   t h e   S t a t e f u l S e t   t o   d e c r e m e n t   t h e   p a r t i t i o n :   #   T h e   v a l u e   o f   " p a r t i t i o n "   s h o u l d   m a t c h   t h e   h i g h e s t   e x i s t i n g   o r d i n a l   f o r   #   t h e   S t a t e f u l S e t   k u b e c t l   p a t c h   s t a t e f u l s e t   w e b   - p   ' { " s p e c " : { " u p d a t e S t r a t e g y " : { " t y p e " : " R o l l i n g U p d a t e " , " r o l l i n g U p d a t e " : { " p a r t i t i o n " : 2 } } } } '   s t a t e f u l s e t . a p p s / w e b   p a t c h e d   T h e   c o n t r o l   p l a n e   t r i g g e r s   r e p l a c e m e n t   f o r   w e b - 2   ( i m p l e m e n t e d   b y   a   g r a c e f u l   d e l e t e   f o l l o w e d   b y   c r e a t i n g   a   n e w   P o d   o n c e   t h e   d e l e t i o n   i s   c o m p l e t e ) .   W a i t   f o r   t h e   n e w   w e b - 2   P o d   t o   b e   R u n n i n g   a n d   R e a d y .   #   T h i s   s h o u l d   a l r e a d y   b e   r u n n i n g   k u b e c t l   g e t   p o d   - l   a p p = n g i n x   - - w a t c h   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   w e b - 0   1 / 1   R u n n i n g   0   4 m   w e b - 1   1 / 1   R u n n i n g   0   4 m   w e b - 2   0 / 1   C o n t a i n e r C r e a t i n g   0   1 1 s   w e b - 2   1 / 1   R u n n i n g   0   1 8 s   G e t   t h e   P o d ' s   c o n t a i n e r :   k u b e c t l   g e t   p o d   w e b - 2   - - t e m p l a t e   ' { { r a n g e   $ i ,   $ c   : =   . s p e c . c o n t a i n e r s } } { { $ c . i m a g e } } { { e n d } } '   r e g i s t r y . k 8 s . i o / n g


Question: What is Phased roll outs?

Answer: Y o u   c a n   p e r f o r m   a   p h a s e d   r o l l   o u t   ( e . g .   a   l i n e a r ,   g e o m e t r i c ,   o r   e x p o n e n t i a l   r o l l   o u t )   u s i n g   a   p a r t i t i o n e d   r o l l i n g   u p d a t e   i n   a   s i m i l a r   m a n n e r   t o   h o w   y o u   r o l l e d   o u t   a   c a n a r y .   T o   p e r f o r m   a   p h a s e d   r o l l   o u t ,   s e t   t h e   p a r t i t i o n   t o   t h e   o r d i n a l   a t   w h i c h   y o u   w a n t   t h e   c o n t r o l l e r   t o   p a u s e   t h e   u p d a t e .   T h e   p a r t i t i o n   i s   c u r r e n t l y   s e t   t o   2 .   S e t   t h e   p a r t i t i o n   t o   0 :   k u b e c t l   p a t c h   s t a t e f u l s e t   w e b   - p   ' { " s p e c " : { " u p d a t e S t r a t e g y " : { " t y p e " : " R o l l i n g U p d a t e " , " r o l l i n g U p d a t e " : { " p a r t i t i o n " : 0 } } } } '   s t a t e f u l s e t . a p p s / w e b   p a t c h e d   W a i t   f o r   a l l   o f   t h e   P o d s   i n   t h e   S t a t e f u l S e t   t o   b e c o m e   R u n n i n g   a n d   R e a d y .   #   T h i s   s h o u l d   a l r e a d y   b e   r u n n i n g   k u b e c t l   g e t   p o d   - l   a p p = n g i n x   - - w a t c h   T h e   o u t p u t   i s   s i m i l a r   t 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   w e b - 0   1 / 1   R u n n i n g   0   3 m   w e b - 1   0 / 1   C o n t a i n e r C r e a t i n g   0   1 1 s   w e b - 2   1 / 1   R u n n i n g   0   2 m   w e b - 1   1 / 1   R u n n i n g   0   1 8 s   w e b - 0   1 / 1   T e r m i n a t i n g   0   3 m   w e b - 0   1 / 1   T e r m i n a t i n g   0   3 m   w e b - 0   0 / 1   T e r m i n a t i n g   0   3 m   w e b - 0   0 / 1   T e r m i n a t i n g   0   3 m   w e b - 0   0 / 1   T e r m i n a t i n g   0   3 m   w e b - 0   0 / 1   T e r m i n a t i n g   0   3 m   w e b - 0   0 / 1   P e n d i n g   0   0 s   w e b - 0   0 / 1   P


Question: What is OnDelete?

Answer: Y o u   s e l e c t   t h i s   u p d a t e   s t r a t e g y   f o r   a   S t a t e f u l S e t   b y   s e t t i n g   t h e   . s p e c . t e m p l a t e . u p d a t e S t r a t e g y . t y p e   t o   O n D e l e t e .   P a t c h   t h e   w e b   S t a t e f u l S e t   t o   u s e   t h e   O n D e l e t e   u p d a t e   s t r a t e g y :   k u b e c t l   p a t c h   s t a t e f u l s e t   w e b   - p   ' { " s p e c " : { " u p d a t e S t r a t e g y " : { " t y p e " : " O n D e l e t e " ,   " r o l l i n g U p d a t e " :   n u l l } } } '   s t a t e f u l s e t . a p p s / w e b   p a t c h e d   W h e n   y o u   s e l e c t   t h i s   u p d a t e   s t r a t e g y ,   t h e   S t a t e f u l S e t   c o n t r o l l e r   d o e s   n o t   a u t o m a t i c a l l y   u p d a t e   P o d s   w h e n   a   m o d i f i c a t i o n   i s   m a d e   t o   t h e   S t a t e f u l S e t ' s   . s p e c . t e m p l a t e   f i e l d .   Y o u   n e e d   t o   m a n a g e   t h e   r o l l o u t   y o u r s e l f   -   e i t h e r   m a n u a l l y ,   o r   u s i n g   s e p a r a t e   a u t o m a t i o n .


Question: What is Deleting StatefulSets?

Answer: S t a t e f u l S e t   s u p p o r t s   b o t h   n o n - c a s c a d i n g   a n d   c a s c a d i n g   d e l e t i o n .   I n   a   n o n - c a s c a d i n g   d e l e t e ,   t h e   S t a t e f u l S e t ' s   P o d s   a r e   n o t   d e l e t e d   w h e n   t h e   S t a t e f u l S e t   i s   d e l e t e d .   I n   a   c a s c a d i n g   d e l e t e ,   b o t h   t h e   S t a t e f u l S e t   a n d   i t s   P o d s   a r e   d e l e t e d .   R e a d   U s e   C a s c a d i n g   D e l e t i o n   i n   a   C l u s t e r   t o   l e a r n   a b o u t   c a s c a d i n g   d e l e t i o n   g e n e r a l l y .


Question: What is Non-cascading delete?

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


Question: What is Cascading delete?

Answer: I n   o n e   t e r m i n a l   w i n d o w ,   w a t c h   t h e   P o d s   i n   t h e   S t a t e f u l S e t .   #   L e a v e   t h i s   r u n n i n g   u n t i l   t h e   n e x t   p a g e   s e c t i o n   k u b e c t l   g e t   p o d s   - - w a t c h   - l   a p p = n g i n x   I n   a n o t h e r   t e r m i n a l ,   d e l e t e   t h e   S t a t e f u l S e t   a g a i n .   T h i s   t i m e ,   o m i t   t h e   - - c a s c a d e = o r p h a n   p a r a m e t e r .   k u b e c t l   d e l e t e   s t a t e f u l s e t   w e b   s t a t e f u l s e t . a p p s   " w e b "   d e l e t e d   E x a m i n e   t h e   o u t p u t   o f   t h e   k u b e c t l   g e t   c o m m a n d   r u n n i n g   i n   t h e   f i r s t   t e r m i n a l ,   a n d   w a i t   f o r   a l l   o f   t h e   P o d s   t o   t r a n s i t i o n   t o   T e r m i n a t i n g .   #   T h i s   s h o u l d   a l r e a d y   b e   r u n n i n g   k u b e c t l   g e t   p o d s   - - w a t c h   - l   a p p = n g i n x   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   w e b - 0   1 / 1   R u n n i n g   0   1 1 m   w e b - 1   1 / 1   R u n n i n g   0   2 7 m   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   w e b - 0   1 / 1   T e r m i n a t i n g   0   1 2 m   w e b - 1   1 / 1   T e r m i n a t i n g   0   2 9 m   w e b - 0   0 / 1   T e r m i n a t i n g   0   1 2 m   w e b - 0   0 / 1   T e r m i n a t i n g   0   1 2 m   w e b - 0   0 / 1   T e r m i n a t i n g   0   1 2 m   w e b - 1   0 / 1   T e r m i n a t i n g   0   2 9 m   w e b - 1   0 / 1   T e r m i n a t i n g   0   2 9 m   w e b - 1   0 / 1   T e r m i n a t i n g   0   2 9 m   A s   y o u   s a w   i n   t h e   S c a l i n g   D o w n   s e c t i o n ,   t h e   P o d s   a r e   t e r m i n a t e d   o n e   a t   a   t i m e ,   w i t h   r e s p e c t   t o   t h e   r e v e r s e   o r d e r   o f   t h e i r   o r d i n a l   i n d i c e s .   B e f o r e   t e r m i n