Question: What is Alternatives?

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


Question: What is Caveats?

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


Question: What is 3 - Fine Parallel Processing Using a Work Queue?

Answer: I n   t h i s   e x a m p l e ,   y o u   w i l l   r u n   a   K u b e r n e t e s   J o b   t h a t   r u n s   m u l t i p l e   p a r a l l e l   t a s k s   a s   w o r k e r   p r o c e s s e s ,   e a c h   r u n n i n g   a s   a   s e p a r a t e   P o d .   I n   t h i s   e x a m p l e ,   a s   e a c h   p o d   i s   c r e a t e d ,   i t   p i c k s   u p   o n e   u n i t   o f   w o r k   f r o m   a   t a s k   q u e u e ,   p r o c e s s e s   i t ,   a n d   r e p e a t s   u n t i l   t h e   e n d   o f   t h e   q u e u e   i s   r e a c h e d .   H e r e   i s   a n   o v e r v i e w   o f   t h e   s t e p s   i n   t h i s   e x a m p l e :   S t a r t   a   s t o r a g e   s e r v i c e   t o   h o l d   t h e   w o r k   q u e u e .   I n   t h i s   e x a m p l e ,   y o u   w i l l   u s e   R e d i s   t o   s t o r e   w o r k   i t e m s .   I n   t h e   p r e v i o u s   e x a m p l e ,   y o u   u s e d   R a b b i t M Q .   I n   t h i s   e x a m p l e ,   y o u   w i l l   u s e   R e d i s   a n d   a   c u s t o m   w o r k - q u e u e   c l i e n t   l i b r a r y ;   t h i s   i s   b e c a u s e   A M Q P   d o e s   n o t   p r o v i d e   a   g o o d   w a y   f o r   c l i e n t s   t o   d e t e c t   w h e n   a   f i n i t e - l e n g t h   w o r k   q u e u e   i s   e m p t y .   I n   p r a c t i c e   y o u   w o u l d   s e t   u p   a   s t o r e   s u c h   a s   R e d i s   o n c e   a n d   r e u s e   i t   f o r   t h e   w o r k   q u e u e s   o f   m a n y   j o b s ,   a n d   o t h e r   t h i n g s . C r e a t e   a   q u e u e ,   a n d   f i l l   i t   w i t h   m e s s a g e s .   E a c h   m e s s a g e   r e p r e s e n t s   o n e   t a s k   t o   b e   d o n e .   I n   t h i s   e x a m p l e ,   a   m e s s a g e   i s   a n   i n t e g e r   t h a t   w e   w i l l   d o   a   l e n g t h y   c o m p u t a t i o n   o n . S t a r t   a   J o b   t h a t   w o r k s   o n   t a s k s   f 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   Y o u   w i l l   n e e d   a   c o n t a i n e r   i m a g e   r e g i s t r y   w h e r e   y o u   c a n   u p l o a d   i m a g e s   t o   r u n   i n   y o u r   c l u s t e r .   T h e   e x a m p l e   u s e s   D o c k e r   H u b ,   b u t   y o u   c o u l d   a d a p t   i t   t o   a   d i f f e r e n t   c o n t a i n e r   i m a g e   r e g i s t r y .   T h i s   t a s k   e x a m p l e   a l s o   a s s u m e s   t h a t   y o u   h a v e   D o c k e r   i n s t a l l e d   l o c a l l y .   Y o u   u s e   D o c k e r   t o   b u i l d   c o n t a i n e r   i m a g e s .   B e   f a m i l i a r   w i t h   t h e   b a s i c ,   n o n - p a r a l l e l ,   u s e   o f   J o b .


Question: What is Starting Redis?

Answer: F o r   t h i s   e x a m p l e ,   f o r   s i m p l i c i t y ,   y o u   w i l l   s t a r t   a   s i n g l e   i n s t a n c e   o f   R e d i s .   S e e   t h e   R e d i s   E x a m p l e   f o r   a n   e x a m p l e   o f   d e p l o y i n g   R e d i s   s c a l a b l y   a n d   r e d u n d a n t l y .   Y o u   c o u l d   a l s o   d o w n l o a d   t h e   f o l l o w i n g   f i l e s   d i r e c t l y :   r e d i s - p o d . y a m l r e d i s - s e r v i c e . y a m l D o c k e r f i l e j o b . y a m l r e d i s w q . p y w o r k e r . p y   T o   s t a r t   a   s i n g l e   i n s t a n c e   o f   R e d i s ,   y o u   n e e d   t o   c r e a t e   t h e   r e d i s   p o d   a n d   r e d i s   s e r v i c e :   k u b e c t l   a p p l y   - f   h t t p s : / / k 8 s . i o / e x a m p l e s / a p p l i c a t i o n / j o b / r e d i s / r e d i s - p o d . y a m l   k u b e c t l   a p p l y   - f   h t t p s : / / k 8 s . i o / e x a m p l e s / a p p l i c a t i o n / j o b / r e d i s / r e d i s - s e r v i c e . y a m l


Question: What is Filling the queue with tasks?

Answer: N o w   l e t ' s   f i l l   t h e   q u e u e   w i t h   s o m e   " t a s k s " .   I n   t h i s   e x a m p l e ,   t h e   t a s k s   a r e   s t r i n g s   t o   b e   p r i n t e d .   S t a r t   a   t e m p o r a r y   i n t e r a c t i v e   p o d   f o r   r u n n i n g   t h e   R e d i s   C L I .   k u b e c t l   r u n   - i   - - t t y   t e m p   - - i m a g e   r e d i s   - - c o m m a n d   " / b i n / s h "   W a i t i n g   f o r   p o d   d e f a u l t / r e d i s 2 - c 7 h 7 8   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   N o w   h i t   e n t e r ,   s t a r t   t h e   R e d i s   C L I ,   a n d   c r e a t e   a   l i s t   w i t h   s o m e   w o r k   i t e m s   i n   i t .   r e d i s - c l i   - h   r e d i s   r e d i s : 6 3 7 9 >   r p u s h   j o b 2   " a p p l e "   ( i n t e g e r )   1   r e d i s : 6 3 7 9 >   r p u s h   j o b 2   " b a n a n a "   ( i n t e g e r )   2   r e d i s : 6 3 7 9 >   r p u s h   j o b 2   " c h e r r y "   ( i n t e g e r )   3   r e d i s : 6 3 7 9 >   r p u s h   j o b 2   " d a t e "   ( i n t e g e r )   4   r e d i s : 6 3 7 9 >   r p u s h   j o b 2   " f i g "   ( i n t e g e r )   5   r e d i s : 6 3 7 9 >   r p u s h   j o b 2   " g r a p e "   ( i n t e g e r )   6   r e d i s : 6 3 7 9 >   r p u s h   j o b 2   " l e m o n "   ( i n t e g e r )   7   r e d i s : 6 3 7 9 >   r p u s h   j o b 2   " m e l o n "   ( i n t e g e r )   8   r e d i s : 6 3 7 9 >   r p u s h   j o b 2   " o r a n g e "   ( i n t e g e r )   9   r e d i s : 6 3 7 9 >   l r a n g e   j o b 2   0   - 1   1 )   " a p p l e "   2 )   " b a n a n a "   3 )   " c h e r r y "   4 )   " d a t e "   5 )   " f i g "   6 )   " g r a p e "   7 )   " l e m o n "   8 )   " m e l o n "   9 )   " o r a n g e "   S o ,   t h e   l i s t   w i t h   k e y   j o b 2   w i l l   b e   t h e   w o r k   q u e u


Question: What is Create a container image?

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


Question: What is Push the image?

Answer: F o r   t h e   D o c k e r   H u b ,   t a g   y o u r   a p p   i m a g e   w i t h   y o u r   u s e r n a m e   a n d   p u s h   t o   t h e   H u b   w i t h   t h e   b e l o w   c o m m a n d s .   R e p l a c e   < u s e r n a m e >   w i t h   y o u r   H u b   u s e r n a m e .   d o c k e r   t a g   j o b - w q - 2   < u s e r n a m e > / j o b - w q - 2   d o c k e r   p u s h   < u s e r n a m e > / j o b - w q - 2   Y o u   n e e d   t o   p u s h   t o   a   p u b l i c   r e p o s i t o r y   o r   c o n f i g u r e   y o u r   c l u s t e r   t o   b e   a b l e   t o   a c c e s s   y o u r   p r i v a t e   r e p o s i t o r y .


Question: What is Defining a Job?

Answer: H e r e   i s   a   m a n i f e s t   f o r   t h e   J o b   y o u   w i l l   c r e a t e :   a p i V e r s i o n :   b a t c h / v 1   k i n d :   J o b   m e t a d a t a :   n a m e :   j o b - w q - 2   s p e c :   p a r a l l e l i s m :   2   t e m p l a t e :   m e t a d a t a :   n a m e :   j o b - w q - 2   s p e c :   c o n t a i n e r s :   -   n a m e :   c   i m a g e :   g c r . i o / m y p r o j e c t / j o b - w q - 2   r e s t a r t P o l i c y :   O n F a i l u r e


Question: What is Note:?

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


Question: What is Running the Job?

Answer: S o ,   n o w   r u n   t h e   J o b :   #   t h i s   a s s u m e s   y o u   d o w n l o a d e d   a n d   t h e n   e d i t e d   t h e   m a n i f e s t   a l r e a d y   k u b e c t l   a p p l y   - f   . / j o b . y a m l   N o w   w a i t   a   b i t ,   t h e n   c h e c k   o n   t h e   J o b :   k u b e c t l   d e s c r i b e   j o b s / j o b - w q - 2   N a m e :   j o b - w q - 2   N a m e s p a c e :   d e f a u l t   S e l e c t o r :   c o n t r o l l e r - u i d = b 1 c 7 e 4 e 3 - 9 2 e 1 - 1 1 e 7 - b 8 5 e - f a 1 6 3 e e 3 c 1 1 f   L a b e l s :   c o n t r o l l e r - u i d = b 1 c 7 e 4 e 3 - 9 2 e 1 - 1 1 e 7 - b 8 5 e - f a 1 6 3 e e 3 c 1 1 f   j o b - n a m e = j o b - w q - 2   A n n o t a t i o n s :   < n o n e >   P a r a l l e l i s m :   2   C o m p l e t i o n s :   < u n s e t >   S t a r t   T i m e :   M o n ,   1 1   J a n   2 0 2 2   1 7 : 0 7 : 5 9   + 0 0 0 0   P o d s   S t a t u s e s :   1   R u n n i n g   /   0   S u c c e e d e d   /   0   F a i l e d   P o d   T e m p l a t e :   L a b e l s :   c o n t r o l l e r - u i d = b 1 c 7 e 4 e 3 - 9 2 e 1 - 1 1 e 7 - b 8 5 e - f a 1 6 3 e e 3 c 1 1 f   j o b - n a m e = j o b - w q - 2   C o n t a i n e r s :   c :   I m a g e :   c o n t a i n e r - r e g i s t r y . e x a m p l e / e x a m p l e p r o j e c t / j o b - w q - 2   P o r t :   E n v i r o n m e n t :   < n o n e >   M o u n t s :   < n o n e >   V o l u m e s :   < n o n e >   E v e n t s :   F i r s t S e e n   L a s t S e e n   C o u n t   F r o m   S u b o b j e c t P a t h   T y p e   R e a s o n   M e s s a g e   - - - - - - - - -   - - - - - - - -   - - - - -   - - - -   - - - - - - - - - - - - -   - - - - - - - -   - - - - - -   - - - - - - -   3 3 s   3 3 s   1   { j o b - c o n t r o l l e r   }   N o r m a l   S u c c e s s f u l C r e a t e   C r e a t e d   p o d :   j o b - w q - 2 - l g l f 8   Y o u   c a n   w a i t   f o r   t h e   J o b   t o   s u c c e e d ,   w i t h   a   t i m e


Question: What is Alternatives?

Answer: I f   r u n n i n g   a   q u e u e   s e r v i c e   o r   m o d i f y i n g   y o u r   c o n t a i n e r s   t o   u s e   a   w o r k   q u e u e   i s   i n c o n v e n i e n t ,   y o u   m a y   w a n t   t o   c o n s i d e r   o n e   o f   t h e   o t h e r   j o b   p a t t e r n s .   I f   y o u   h a v e   a   c o n t i n u o u s   s t r e a m   o f   b a c k g r o u n d   p r o c e s s i n g   w o r k   t o   r u n ,   t h e n   c o n s i d e r   r u n n i n g   y o u r   b a c k g r o u n d   w o r k e r s   w i t h   a   R e p l i c a S e t   i n s t e a d ,   a n d   c o n s i d e r   r u n n i n g   a   b a c k g r o u n d   p r o c e s s i n g   l i b r a r y   s u c h   a s   h t t p s : / / g i t h u b . c o m / r e s q u e / r e s q u e .


Question: What is 4 - Indexed Job for Parallel Processing with Static Work Assignment?

Answer: I n   t h i s   e x a m p l e ,   y o u   w i l l   r u n   a   K u b e r n e t e s   J o b   t h a t   u s e s   m u l t i p l e   p a r a l l e l   w o r k e r   p r o c e s s e s .   E a c h   w o r k e r   i s   a   d i f f e r e n t   c o n t a i n e r   r u n n i n g   i n   i t s   o w n   P o d .   T h e   P o d s   h a v e   a n   i n d e x   n u m b e r   t h a t   t h e   c o n t r o l   p l a n e   s e t s   a u t o m a t i c a l l y ,   w h i c h   a l l o w s   e a c h   P o d   t o   i d e n t i f y   w h i c h   p a r t   o f   t h e   o v e r a l l   t a s k   t o   w o r k   o n .   T h e   p o d   i n d e x   i s   a v a i l a b l e   i n   t h e   a n n o t a t i o n   b a t c h . k u b e r n e t e s . i o / j o b - c o m p l e t i o n - i n d e x   a s   a   s t r i n g   r e p r e s e n t i n g   i t s   d e c i m a l   v a l u e .   I n   o r d e r   f o r   t h e   c o n t a i n e r i z e d   t a s k   p r o c e s s   t o   o b t a i n   t h i s   i n d e x ,   y o u   c a n   p u b l i s h   t h e   v a l u e   o f   t h e   a n n o t a t i o n   u s i n g   t h e   d o w n w a r d   A P I   m e c h a n i s m .   F o r   c o n v e n i e n c e ,   t h e   c o n t r o l   p l a n e   a u t o m a t i c a l l y   s e t s   t h e   d o w n w a r d   A P I   t o   e x p o s e   t h e   i n d e x   i n   t h e   J O B _ C O M P L E T I O N _ I N D E X   e n v i r o n m e n t   v a r i a b l e .   H e r e   i s   a n   o v e r v i e w   o f   t h e   s t e p s   i n   t h i s   e x a m p l e :   D e f i n e   a   J o b   m a n i f e s t   u s i n g   i n d e x e d   c o m p l e t i o n .   T h e   d o w n w a r d   A P I   a l l o w s   y o u   t o   p a s s   t h e   p o d   i n d e x   a n n o t a t i o n   a s   a n   e n v i r o n m e n t   v a r i a b l e   o r   f i l e   t o   t h e   c o n t a i n e r . S t a r t   a n   I n d e x e d   J o b   b a s e d   o n   t h a t   m a n i f e s t .


Question: What is Before you begin?

Answer: Y o u   s h o u l d   a l r e a d y   b e   f a m i l i a r   w i t h   t h e   b a s i c ,   n o n - p a r a l l e l ,   u s e   o f   J o b .   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 r   K u b e r n e t e s   s e r v e r   m u s t   b e   a t   o r   l a t e r   t h a n   v e r s i o n   v 1 . 2 1 . 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


Question: What is Choose an approach?

Answer: T o   a c c e s s   t h e   w o r k   i t e m   f r o m   t h e   w o r k e r   p r o g r a m ,   y o u   h a v e   a   f e w   o p t i o n s :   R e a d   t h e   J O B _ C O M P L E T I O N _ I N D E X   e n v i r o n m e n t   v a r i a b l e .   T h e   J o b   c o n t r o l l e r   a u t o m a t i c a l l y   l i n k s   t h i s   v a r i a b l e   t o   t h e   a n n o t a t i o n   c o n t a i n i n g   t h e   c o m p l e t i o n   i n d e x . R e a d   a   f i l e   t h a t   c o n t a i n s   t h e   c o m p l e t i o n   i n d e x . A s s u m i n g   t h a t   y o u   c a n ' t   m o d i f y   t h e   p r o g r a m ,   y o u   c a n   w r a p   i t   w i t h   a   s c r i p t   t h a t   r e a d s   t h e   i n d e x   u s i n g   a n y   o f   t h e   m e t h o d s   a b o v e   a n d   c o n v e r t s   i t   i n t o   s o m e t h i n g   t h a t   t h e   p r o g r a m   c a n   u s e   a s   i n p u t .   F o r   t h i s   e x a m p l e ,   i m a g i n e   t h a t   y o u   c h o s e   o p t i o n   3   a n d   y o u   w a n t   t o   r u n   t h e   r e v   u t i l i t y .   T h i s   p r o g r a m   a c c e p t s   a   f i l e   a s   a n   a r g u m e n t   a n d   p r i n t s   i t s   c o n t e n t   r e v e r s e d .   r e v   d a t a . t x t   Y o u ' l l   u s e   t h e   r e v   t o o l   f r o m   t h e   b u s y b o x   c o n t a i n e r   i m a g e .   A s   t h i s   i s   o n l y   a n   e x a m p l e ,   e a c h   P o d   o n l y   d o e s   a   t i n y   p i e c e   o f   w o r k   ( r e v e r s i n g   a   s h o r t   s t r i n g ) .   I n   a   r e a l   w o r k l o a d   y o u   m i g h t ,   f o r   e x a m p l e ,   c r e a t e   a   J o b   t h a t   r e p r e s e n t s   t h e   t a s k   o f   p r o d u c i n g   6 0   s e c o n d s   o f   v i d e o   b a s e d   o n   s c e n e   d a t a .   E a c h   w o r k   i t e m   i n   t h e   v i d e o   r e n d e r i n g   J o b   w o u l d   b e   t o   r e n d e r   a   p a r t i


Question: What is Define an Indexed Job?

Answer: H e r e   i s   a   s a m p l e   J o b   m a n i f e s t   t h a t   u s e s   I n d e x e d   c o m p l e t i o n   m o d e :   a p i V e r s i o n :   b a t c h / v 1   k i n d :   J o b   m e t a d a t a :   n a m e :   ' i n d e x e d - j o b '   s p e c :   c o m p l e t i o n s :   5   p a r a l l e l i s m :   3   c o m p l e t i o n M o d e :   I n d e x e d   t e m p l a t e :   s p e c :   r e s t a r t P o l i c y :   N e v e r   i n i t C o n t a i n e r s :   -   n a m e :   ' i n p u t '   i m a g e :   ' d o c k e r . i o / l i b r a r y / b a s h '   c o m m a n d :   -   " b a s h "   -   " - c "   -   |   i t e m s = ( f o o   b a r   b a z   q u x   x y z )   e c h o   $ { i t e m s [ $ J O B _ C O M P L E T I O N _ I N D E X ] }   >   / i n p u t / d a t a . t x t   v o l u m e M o u n t s :   -   m o u n t P a t h :   / i n p u t   n a m e :   i n p u t   c o n t a i n e r s :   -   n a m e :   ' w o r k e r '   i m a g e :   ' d o c k e r . i o / l i b r a r y / b u s y b o x '   c o m m a n d :   -   " r e v "   -   " / i n p u t / d a t a . t x t "   v o l u m e M o u n t s :   -   m o u n t P a t h :   / i n p u t   n a m e :   i n p u t   v o l u m e s :   -   n a m e :   i n p u t   e m p t y D i r :   { }   I n   t h e   e x a m p l e   a b o v e ,   y o u   u s e   t h e   b u i l t i n   J O B _ C O M P L E T I O N _ I N D E X   e n v i r o n m e n t   v a r i a b l e   s e t   b y   t h e   J o b   c o n t r o l l e r   f o r   a l l   c o n t a i n e r s .   A n   i n i t   c o n t a i n e r   m a p s   t h e   i n d e x   t o   a   s t a t i c   v a l u e   a n d   w r i t e s   i t   t o   a   f i l e   t h a t   i s   s h a r e d   w i t h   t h e   c o n t a i n e r   r u n n i n g   t h e   w o r k e r   t h r o u g h   a n   e m p t y D i r   v o l u m e .   O p t i o n a l l y ,   y o u   c a n   d e f i n e   y o u r   o w n   e n v i r o n m e n t   v a r i a b l e   t h r o u g h   t h e   d o w n w a r d   A P I   t o   p


Question: What is Running the Job?

Answer: N o w   r u n   t h e   J o b :   #   T h i s   u s e s   t h e   f i r s t   a p p r o a c h   ( r e l y i n g   o n   $ J O B _ C O M P L E T I O N _ I N D E X )   k u b e c t l   a p p l y   - f   h t t p s : / / k u b e r n e t e s . i o / e x a m p l e s / a p p l i c a t i o n / j o b / i n d e x e d - j o b . y a m l   W h e n   y o u   c r e a t e   t h i s   J o b ,   t h e   c o n t r o l   p l a n e   c r e a t e s   a   s e r i e s   o f   P o d s ,   o n e   f o r   e a c h   i n d e x   y o u   s p e c i f i e d .   T h e   v a l u e   o f   . s p e c . p a r a l l e l i s m   d e t e r m i n e s   h o w   m a n y   c a n   r u n   a t   o n c e   w h e r e a s   . s p e c . c o m p l e t i o n s   d e t e r m i n e s   h o w   m a n y   P o d s   t h e   J o b   c r e a t e s   i n   t o t a l .   B e c a u s e   . s p e c . p a r a l l e l i s m   i s   l e s s   t h a n   . s p e c . c o m p l e t i o n s ,   t h e   c o n t r o l   p l a n e   w a i t s   f o r   s o m e   o f   t h e   f i r s t   P o d s   t o   c o m p l e t e   b e f o r e   s t a r t i n g   m o r e   o f   t h e m .   Y o u   c a n   w a i t   f o r   t h e   J o b   t o   s u c c e e d ,   w i t h   a   t i m e o u t :   #   T h e   c h e c k   f o r   c o n d i t i o n   n a m e   i s   c a s e   i n s e n s i t i v e   k u b e c t l   w a i t   - - f o r = c o n d i t i o n = c o m p l e t e   - - t i m e o u t = 3 0 0 s   j o b / i n d e x e d - j o b   N o w ,   d e s c r i b e   t h e   J o b   a n d   c h e c k   t h a t   i t   w a s   s u c c e s s f u l .   k u b e c t l   d e s c r i b e   j o b s / i n d e x e d - j o b   T h e   o u t p u t   i s   s i m i l a r   t o :   N a m e :   i n d e x e d - j o b   N a m e s p a c e :   d e f a u l t   S e l e c t o r :   c o n t r o l l e r - u i d = b f 8 6 5 e 0 4 - 0 b 6 7 - 4 8 3 b - 9 a 9 0 - 7 4 c f c 4 c 3 e 7 5 6   L a b e l s :   c o n t r o l l e r - u i d = b f 8 6 5 e 0 4 - 0 b 6 7 - 4 8 3 b - 9 a 9 0 - 7 4


Question: What is 5 - Job with Pod-to-Pod Communication?

Answer: I n   t h i s   e x a m p l e ,   y o u   w i l l   r u n   a   J o b   i n   I n d e x e d   c o m p l e t i o n   m o d e   c o n f i g u r e d   s u c h   t h a t   t h e   p o d s   c r e a t e d   b y   t h e   J o b   c a n   c o m m u n i c a t e   w i t h   e a c h   o t h e r   u s i n g   p o d   h o s t n a m e s   r a t h e r   t h a n   p o d   I P   a d d r e s s e s .   P o d s   w i t h i n   a   J o b   m i g h t   n e e d   t o   c o m m u n i c a t e   a m o n g   t h e m s e l v e s .   T h e   u s e r   w o r k l o a d   r u n n i n g   i n   e a c h   p o d   c o u l d   q u e r y   t h e   K u b e r n e t e s   A P I   s e r v e r   t o   l e a r n   t h e   I P s   o f   t h e   o t h e r   P o d s ,   b u t   i t ' s   m u c h   s i m p l e r   t o   r e l y   o n   K u b e r n e t e s '   b u i l t - i n   D N S   r e s o l u t i o n .   J o b s   i n   I n d e x e d   c o m p l e t i o n   m o d e   a u t o m a t i c a l l y   s e t   t h e   p o d s '   h o s t n a m e   t o   b e   i n   t h e   f o r m a t   o f   $ { j o b N a m e } - $ { c o m p l e t i o n I n d e x } .   Y o u   c a n   u s e   t h i s   f o r m a t   t o   d e t e r m i n i s t i c a l l y   b u i l d   p o d   h o s t n a m e s   a n d   e n a b l e   p o d   c o m m u n i c a t i o n   w i t h o u t   n e e d i n g   t o   c r e a t e   a   c l i e n t   c o n n e c t i o n   t o   t h e   K u b e r n e t e s   c o n t r o l   p l a n e   t o   o b t a i n   p o d   h o s t n a m e s / I P s   v i a   A P I   r e q u e s t s .   T h i s   c o n f i g u r a t i o n   i s   u s e f u l   f o r   u s e   c a s e s   w h e r e   p o d   n e t w o r k i n g   i s   r e q u i r e d   b u t   y o u   d o n ' t   w a n t   t o   d e p e n d   o n   a   n e t w o r k   c o n n e c t i o n   w i t h   t h e   K u b e r n e t e s   A P I   s e r v e r .


Question: What is Before you begin?

Answer: Y o u   s h o u l d   a l r e a d y   b e   f a m i l i a r   w i t h   t h e   b a s i c   u s e   o f   J o b .   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 r   K u b e r n e t e s   s e r v e r   m u s t   b e   a t   o r   l a t e r   t h a n   v e r s i o n   v 1 . 2 1 . 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


Question: What is Starting a Job with pod-to-pod communication?

Answer: T o   e n a b l e   p o d - t o - p o d   c o m m u n i c a t i o n   u s i n g   p o d   h o s t n a m e s   i n   a   J o b ,   y o u   m u s t   d o   t h e   f o l l o w i n g :   S e t   u p   a   h e a d l e s s   S e r v i c e   w i t h   a   v a l i d   l a b e l   s e l e c t o r   f o r   t h e   p o d s   c r e a t e d   b y   y o u r   J o b .   T h e   h e a d l e s s   s e r v i c e   m u s t   b e   i n   t h e   s a m e   n a m e s p a c e   a s   t h e   J o b .   O n e   e a s y   w a y   t o   d o   t h i s   i s   t o   u s e   t h e   j o b - n a m e :   < y o u r - j o b - n a m e >   s e l e c t o r ,   s i n c e   t h e   j o b - n a m e   l a b e l   w i l l   b e   a u t o m a t i c a l l y   a d d e d   b y   K u b e r n e t e s .   T h i s   c o n f i g u r a t i o n   w i l l   t r i g g e r   t h e   D N S   s y s t e m   t o   c r e a t e   r e c o r d s   o f   t h e   h o s t n a m e s   o f   t h e   p o d s   r u n n i n g   y o u r   J o b . C o n f i g u r e   t h e   h e a d l e s s   s e r v i c e   a s   s u b d o m a i n   s e r v i c e   f o r   t h e   J o b   p o d s   b y   i n c l u d i n g   t h e   f o l l o w i n g   v a l u e   i n   y o u r   J o b   t e m p l a t e   s p e c : s u b d o m a i n :   < h e a d l e s s - s v c - n a m e >   S e t   u p   a   h e a d l e s s   S e r v i c e   w i t h   a   v a l i d   l a b e l   s e l e c t o r   f o r   t h e   p o d s   c r e a t e d   b y   y o u r   J o b .   T h e   h e a d l e s s   s e r v i c e   m u s t   b e   i n   t h e   s a m e   n a m e s p a c e   a s   t h e   J o b .   O n e   e a s y   w a y   t o   d o   t h i s   i s   t o   u s e   t h e   j o b - n a m e :   < y o u r - j o b - n a m e >   s e l e c t o r ,   s i n c e   t h e   j o b - n a m e   l a b e l   w i l l   b e   a u t o m a t i c a l l y   a d d e d   b y   K u b e r n e t e s .   T h i s   c o n f i g u r a t i o n   w i l l   t r i g g e r   t h e   D N S   s y s t e m   t o   c r


Question: What is Example?

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


Question: What is Note:?

Answer: 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 :   h e a d l e s s - s v c   s p e c :   c l u s t e r I P :   N o n e   #   c l u s t e r I P   m u s t   b e   N o n e   t o   c r e a t e   a   h e a d l e s s   s e r v i c e   s e l e c t o r :   j o b - n a m e :   e x a m p l e - j o b   #   m u s t   m a t c h   J o b   n a m e   - - -   a p i V e r s i o n :   b a t c h / v 1   k i n d :   J o b   m e t a d a t a :   n a m e :   e x a m p l e - j o b   s p e c :   c o m p l e t i o n s :   3   p a r a l l e l i s m :   3   c o m p l e t i o n M o d e :   I n d e x e d   t e m p l a t e :   s p e c :   s u b d o m a i n :   h e a d l e s s - s v c   #   h a s   t o   m a t c h   S e r v i c e   n a m e   r e s t a r t P o l i c y :   N e v e r   c o n t a i n e r s :   -   n a m e :   e x a m p l e - w o r k l o a d   i m a g e :   b a s h : l a t e s t   c o m m a n d :   -   b a s h   -   - c   -   |   f o r   i   i n   0   1   2   d o   g o t S t a t u s = " - 1 "   w a n t S t a t u s = " 0 "   w h i l e   [   $ g o t S t a t u s   - n e   $ w a n t S t a t u s   ]   d o   p i n g   - c   1   e x a m p l e - j o b - $ { i } . h e a d l e s s - s v c   >   / d e v / n u l l   2 > & 1   g o t S t a t u s = $ ?   i f   [   $ g o t S t a t u s   - n e   $ w a n t S t a t u s   ] ;   t h e n   e c h o   " F a i l e d   t o   p i n g   p o d   e x a m p l e - j o b - $ { i } . h e a d l e s s - s v c ,   r e t r y i n g   i n   1   s e c o n d . . . "   s l e e p   1   f i   d o n e   e c h o   " S u c c e s s f u l l y   p i n g e d   p o d :   e x a m p l e - j o b - $ { i } . h e a d l e s s - s v c "   d o n e   A f t e r   a p p l y i n g   t h e   e x a m p l e   a b o v e ,   r e a c h   e a c h   o t h e r   o v e r   t h e   n e t w o r k   u s i n g :   < p o d - h o s t n a m e > . < h e a d l e s s - s e r v i c e - n a m e > .   Y o u   s h o u l d   s e e   o u t p u t   s i m i l a r   t o   t h e   f o l l o


Question: What is 6 - Parallel Processing using Expansions?

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


Question: What is Before you begin?

Answer: Y o u   s h o u l d   b e   f a m i l i a r   w i t h   t h e   b a s i c ,   n o n - p a r a l l e l ,   u s e   o f   J o b .   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   F o r   b a s i c   t e m p l a t i n g   y o u   n e e d   t h e   c o m m a n d - l i n e   u t i l i t y   s e d .   T o   f o l l o w   t h e   a d v a n c e d   t e m p l a t i n g   e x a m p l e ,   y o u   n e e d   a   w o r k i n g   i n s t a l l a t i o n   o f   P y t h o n ,   a n d   t h e   J i n j a 2   t e m p l a t e   l i b r a r y   f o r   P y t h o n .   O n c e   y o u   h a v e   P y t h o n   s e t   u p ,   y o u   c a n   i n s t a l l   J i n j a 2   b y   r u n n i n g :   p i p   i n s t a l l   - - u s e r   j i n j a 2


Question: What is Create Jobs based on a template?

Answer: F i r s t ,   d o w n l o a d   t h e   f o l l o w i n g   t e m p l a t e   o f   a   J o b   t o   a   f i l e   c a l l e d   j o b - t m p l . y a m l .   H e r e ' s   w h a t   y o u ' l l   d o w n l o a d :   a p i V e r s i o n :   b a t c h / v 1   k i n d :   J o b   m e t a d a t a :   n a m e :   p r o c e s s - i t e m - $ I T E M   l a b e l s :   j o b g r o u p :   j o b e x a m p l e   s p e c :   t e m p l a t e :   m e t a d a t a :   n a m e :   j o b e x a m p l e   l a b e l s :   j o b g r o u p :   j o b e x a m p l e   s p e c :   c o n t a i n e r s :   -   n a m e :   c   i m a g e :   b u s y b o x : 1 . 2 8   c o m m a n d :   [ " s h " ,   " - c " ,   " e c h o   P r o c e s s i n g   i t e m   $ I T E M   & &   s l e e p   5 " ]   r e s t a r t P o l i c y :   N e v e r   #   U s e   c u r l   t o   d o w n l o a d   j o b - t m p l . y a m l   c u r l   - L   - s   - O   h t t p s : / / k 8 s . i o / e x a m p l e s / a p p l i c a t i o n / j o b / j o b - t m p l . y a m l   T h e   f i l e   y o u   d o w n l o a d e d   i s   n o t   y e t   a   v a l i d   K u b e r n e t e s   m a n i f e s t .   I n s t e a d   t h a t   t e m p l a t e   i s   a   Y A M L   r e p r e s e n t a t i o n   o f   a   J o b   o b j e c t   w i t h   s o m e   p l a c e h o l d e r s   t h a t   n e e d   t o   b e   f i l l e d   i n   b e f o r e   i t   c a n   b e   u s e d .   T h e   $ I T E M   s y n t a x   i s   n o t   m e a n i n g f u l   t o   K u b e r n e t e s .


Question: What is Create manifests from the template?

Answer: T h e   f o l l o w i n g   s h e l l   s n i p p e t   u s e s   s e d   t o   r e p l a c e   t h e   s t r i n g   $ I T E M   w i t h   t h e   l o o p   v a r i a b l e ,   w r i t i n g   i n t o   a   t e m p o r a r y   d i r e c t o r y   n a m e d   j o b s .   R u n   t h i s   n o w :   #   E x p a n d   t h e   t e m p l a t e   i n t o   m u l t i p l e   f i l e s ,   o n e   f o r   e a c h   i t e m   t o   b e   p r o c e s s e d .   m k d i r   . / j o b s   f o r   i   i n   a p p l e   b a n a n a   c h e r r y   d o   c a t   j o b - t m p l . y a m l   |   s e d   " s / \ $ I T E M / $ i / "   >   . / j o b s / j o b - $ i . y a m l   d o n e   C h e c k   i f   i t   w o r k e d :   l s   j o b 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 :   j o b - a p p l e . y a m l   j o b - b a n a n a . y a m l   j o b - c h e r r y . y a m l   Y o u   c o u l d   u s e   a n y   t y p e   o f   t e m p l a t e   l a n g u a g e   ( f o r   e x a m p l e :   J i n j a 2 ;   E R B ) ,   o r   w r i t e   a   p r o g r a m   t o   g e n e r a t e   t h e   J o b   m a n i f e s t s .


Question: What is Create Jobs from the manifests?

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


Question: What is Clean up?

Answer: #   R e m o v e   t h e   J o b s   y o u   c r e a t e d   #   Y o u r   c l u s t e r   a u t o m a t i c a l l y   c l e a n s   u p   t h e i r   P o d s   k u b e c t l   d e l e t e   j o b   - l   j o b g r o u p = j o b e x a m p l e


Question: What is Use advanced template parameters?

Answer: I n   t h e   f i r s t   e x a m p l e ,   e a c h   i n s t a n c e   o f   t h e   t e m p l a t e   h a d   o n e   p a r a m e t e r ,   a n d   t h a t   p a r a m e t e r   w a s   a l s o   u s e d   i n   t h e   J o b ' s   n a m e .   H o w e v e r ,   n a m e s   a r e   r e s t r i c t e d   t o   c o n t a i n   o n l y   c e r t a i n   c h a r a c t e r s .   T h i s   s l i g h t l y   m o r e   c o m p l e x   e x a m p l e   u s e s   t h e   J i n j a   t e m p l a t e   l a n g u a g e   t o   g e n e r a t e   m a n i f e s t s   a n d   t h e n   o b j e c t s   f r o m   t h o s e   m a n i f e s t s ,   w i t h   a   m u l t i p l e   p a r a m e t e r s   f o r   e a c h   J o b .   F o r   t h i s   p a r t   o f   t h e   t a s k ,   y o u   a r e   g o i n g   t o   u s e   a   o n e - l i n e   P y t h o n   s c r i p t   t o   c o n v e r t   t h e   t e m p l a t e   t o   a   s e t   o f   m a n i f e s t s .   F i r s t ,   c o p y   a n d   p a s t e   t h e   f o l l o w i n g   t e m p l a t e   o f   a   J o b   o b j e c t ,   i n t o   a   f i l e   c a l l e d   j o b . y a m l . j i n j a 2 :   { %   s e t   p a r a m s   =   [ {   " n a m e " :   " a p p l e " ,   " u r l " :   " h t t p : / / d b p e d i a . o r g / r e s o u r c e / A p p l e " ,   } ,   {   " n a m e " :   " b a n a n a " ,   " u r l " :   " h t t p : / / d b p e d i a . o r g / r e s o u r c e / B a n a n a " ,   } ,   {   " n a m e " :   " c h e r r y " ,   " u r l " :   " h t t p : / / d b p e d i a . o r g / r e s o u r c e / C h e r r y "   } ]   % }   { %   f o r   p   i n   p a r a m s   % }   { %   s e t   n a m e   =   p [ " n a m e " ]   % }   { %   s e t   u r l   =   p [ " u r l " ]   % }   - - -   a p i V e r s i o n :   b a t c h / v 1   k i n d :   J o b   m e t a d a t a :   n a m e :   j o b e x a m p l e - { {   n a m e   } }   l a b e l s :   j o b g r o u p :   j o b e x a m p l e   s p e c :   t e m p l a t e :   m e t a d a t a :


Question: What is Clean up?

Answer: #   R e m o v e   t h e   J o b s   y o u   c r e a t e d   #   Y o u r   c l u s t e r   a u t o m a t i c a l l y   c l e a n s   u p   t h e i r   P o d s   k u b e c t l   d e l e t e   j o b   - l   j o b g r o u p = j o b e x a m p l e


Question: What is Using Jobs in real workloads?

Answer: I n   a   r e a l   u s e   c a s e ,   e a c h   J o b   p e r f o r m s   s o m e   s u b s t a n t i a l   c o m p u t a t i o n ,   s u c h   a s   r e n d e r i n g   a   f r a m e   o f   a   m o v i e ,   o r   p r o c e s s i n g   a   r a n g e   o f   r o w s   i n   a   d a t a b a s e .   I f   y o u   w e r e   r e n d e r i n g   a   m o v i e   y o u   w o u l d   s e t   $ I T E M   t o   t h e   f r a m e   n u m b e r .   I f   y o u   w e r e   p r o c e s s i n g   r o w s   f r o m   a   d a t a b a s e   t a b l e ,   y o u   w o u l d   s e t   $ I T E M   t o   r e p r e s e n t   t h e   r a n g e   o f   d a t a b a s e   r o w s   t o   p r o c e s s .   I n   t h e   t a s k ,   y o u   r a n   a   c o m m a n d   t o   c o l l e c t   t h e   o u t p u t   f r o m   P o d s   b y   f e t c h i n g   t h e i r   l o g s .   I n   a   r e a l   u s e   c a s e ,   e a c h   P o d   f o r   a   J o b   w r i t e s   i t s   o u t p u t   t o   d u r a b l e   s t o r a g e   b e f o r e   c o m p l e t i n g .   Y o u   c a n   u s e   a   P e r s i s t e n t V o l u m e   f o r   e a c h   J o b ,   o r   a n   e x t e r n a l   s t o r a g e   s e r v i c e .   F o r   e x a m p l e ,   i f   y o u   a r e   r e n d e r i n g   f r a m e s   f o r   a   m o v i e ,   u s e   H T T P   t o   P U T   t h e   r e n d e r e d   f r a m e   d a t a   t o   a   U R L ,   u s i n g   a   d i f f e r e n t   U R L   f o r   e a c h   f r a m e .


Question: What is Labels on Jobs and Pods?

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


Question: What is Alternatives?

Answer: I f   y o u   p l a n   t o   c r e a t e   a   l a r g e   n u m b e r   o f   J o b   o b j e c t s ,   y o u   m a y   f i n d   t h a t :   E v e n   u s i n g   l a b e l s ,   m a n a g i n g   s o   m a n y   J o b s   i s   c u m b e r s o m e . I f   y o u   c r e a t e   m a n y   J o b s   i n   a   b a t c h ,   y o u   m i g h t   p l a c e   h i g h   l o a d   o n   t h e   K u b e r n e t e s   c o n t r o l   p l a n e .   A l t e r n a t i v e l y ,   t h e   K u b e r n e t e s   A P I   s e r v e r   c o u l d   r a t e   l i m i t   y o u ,   t e m p o r a r i l y   r e j e c t i n g   y o u r   r e q u e s t s   w i t h   a   4 2 9   s t a t u s . Y o u   a r e   l i m i t e d   b y   a   r e s o u r c e   q u o t a   o n   J o b s :   t h e   A P I   s e r v e r   p e r m a n e n t l y   r e j e c t s   s o m e   o f   y o u r   r e q u e s t s   w h e n   y o u   c r e a t e   a   g r e a t   d e a l   o f   w o r k   i n   o n e   b a t c h .   T h e r e   a r e   o t h e r   j o b   p a t t e r n s   t h a t   y o u   c a n   u s e   t o   p r o c e s s   l a r g e   a m o u n t s   o f   w o r k   w i t h o u t   c r e a t i n g   v e r y   m a n y   J o b   o b j e c t s .   Y o u   c o u l d   a l s o   c o n s i d e r   w r i t i n g   y o u r   o w n   c o n t r o l l e r   t o   m a n a g e   J o b   o b j e c t s   a u t o m a t i c a l l y .


Question: What is 7 - Handling retriable and non-retriable pod failures with Pod failure policy?

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


Question: What is Before you begin?

Answer: Y o u   s h o u l d   a l r e a d y   b e   f a m i l i a r   w i t h   t h e   b a s i c   u s e   o f   J o b .   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 r   K u b e r n e t e s   s e r v e r   m u s t   b e   a t   o r   l a t e r   t h a n   v e r s i o n   v 1 . 2 5 . 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


Question: What is Usage scenarios?

Answer: C o n s i d e r   t h e   f o l l o w i n g   u s a g e   s c e n a r i o s   f o r   J o b s   t h a t   d e f i n e   a   P o d   f a i l u r e   p o l i c y   :   A v o i d i n g   u n n e c e s s a r y   P o d   r e t r i e s I g n o r i n g   P o d   d i s r u p t i o n s A v o i d i n g   u n n e c e s s a r y   P o d   r e t r i e s   b a s e d   o n   c u s t o m   P o d   C o n d i t i o n s A v o i d i n g   u n n e c e s s a r y   P o d   r e t r i e s   p e r   i n d e x


Question: What is Using Pod failure policy to avoid unnecessary Pod retries?

Answer: W i t h   t h e   f o l l o w i n g   e x a m p l e ,   y o u   c a n   l e a r n   h o w   t o   u s e   P o d   f a i l u r e   p o l i c y   t o   a v o i d   u n n e c e s s a r y   P o d   r e s t a r t s   w h e n   a   P o d   f a i l u r e   i n d i c a t e s   a   n o n - r e t r i a b l e   s o f t w a r e   b u g .   E x a m i n e   t h e   f o l l o w i n g   m a n i f e s t : / c o n t r o l l e r s / j o b - p o d - f a i l u r e - p o l i c y - f a i l j o b . y a m l   a p i V e r s i o n :   b a t c h / v 1   k i n d :   J o b   m e t a d a t a :   n a m e :   j o b - p o d - f a i l u r e - p o l i c y - f a i l j o b   s p e c :   c o m p l e t i o n s :   8   p a r a l l e l i s m :   2   t e m p l a t e :   s p e c :   r e s t a r t P o l i c y :   N e v e r   c o n t a i n e r s :   -   n a m e :   m a i n   i m a g e :   d o c k e r . i o / l i b r a r y / b a s h : 5   c o m m a n d :   [ " b a s h " ]   a r g s :   -   - c   -   e c h o   " H e l l o   w o r l d !   I ' m   g o i n g   t o   e x i t   w i t h   4 2   t o   s i m u l a t e   a   s o f t w a r e   b u g . "   & &   s l e e p   3 0   & &   e x i t   4 2   b a c k o f f L i m i t :   6   p o d F a i l u r e P o l i c y :   r u l e s :   -   a c t i o n :   F a i l J o b   o n E x i t C o d e s :   c o n t a i n e r N a m e :   m a i n   o p e r a t o r :   I n   v a l u e s :   [ 4 2 ]   A p p l y   t h e   m a n i f e s t : k u b e c t l   c r e a t e   - f   h t t p s : / / k 8 s . i o / e x a m p l e s / c o n t r o l l e r s / j o b - p o d - f a i l u r e - p o l i c y - f a i l j o b . y a m l   A f t e r   a r o u n d   3 0   s e c o n d s   t h e   e n t i r e   J o b   s h o u l d   b e   t e r m i n a t e d .   I n s p e c t   t h e   s t a t u s   o f   t h e   J o b   b y   r u n n i n g : k u b e c t l   g e t   j o b s   - l   j o b - n a m e = j o b - p o d - f a i l u r e - p o l i c y - f a i l j o b   - o   y a m l   I n   t h e   J o b   s t a t u s ,   t h e


Question: What is Clean up?

Answer: D e l e t e   t h e   J o b   y o u   c r e a t e d :   k u b e c t l   d e l e t e   j o b s / j o b - p o d - f a i l u r e - p o l i c y - f a i l j o b   T h e   c l u s t e r   a u t o m a t i c a l l y   c l e a n s   u p   t h e   P o d s .


Question: What is Using Pod failure policy to ignore Pod disruptions?

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


Question: What is Caution:?

Answer: E x a m i n e   t h e   f o l l o w i n g   m a n i f e s t : / c o n t r o l l e r s / j o b - p o d - f a i l u r e - p o l i c y - i g n o r e . y a m l   a p i V e r s i o n :   b a t c h / v 1   k i n d :   J o b   m e t a d a t a :   n a m e :   j o b - p o d - f a i l u r e - p o l i c y - i g n o r e   s p e c :   c o m p l e t i o n s :   4   p a r a l l e l i s m :   2   t e m p l a t e :   s p e c :   r e s t a r t P o l i c y :   N e v e r   c o n t a i n e r s :   -   n a m e :   m a i n   i m a g e :   d o c k e r . i o / l i b r a r y / b a s h : 5   c o m m a n d :   [ " b a s h " ]   a r g s :   -   - c   -   e c h o   " H e l l o   w o r l d !   I ' m   g o i n g   t o   e x i t   w i t h   0   ( s u c c e s s ) . "   & &   s l e e p   9 0   & &   e x i t   0   b a c k o f f L i m i t :   0   p o d F a i l u r e P o l i c y :   r u l e s :   -   a c t i o n :   I g n o r e   o n P o d C o n d i t i o n s :   -   t y p e :   D i s r u p t i o n T a r g e t   A p p l y   t h e   m a n i f e s t : k u b e c t l   c r e a t e   - f   h t t p s : / / k 8 s . i o / e x a m p l e s / c o n t r o l l e r s / j o b - p o d - f a i l u r e - p o l i c y - i g n o r e . y a m l   R u n   t h i s   c o m m a n d   t o   c h e c k   t h e   n o d e N a m e   t h e   P o d   i s   s c h e d u l e d   t o : n o d e N a m e = $ ( k u b e c t l   g e t   p o d s   - l   j o b - n a m e = j o b - p o d - f a i l u r e - p o l i c y - i g n o r e   - o   j s o n p a t h = ' { . i t e m s [ 0 ] . s p e c . n o d e N a m e } ' )   D r a i n   t h e   n o d e   t o   e v i c t   t h e   P o d   b e f o r e   i t   c o m p l e t e s   ( w i t h i n   9 0 s ) : k u b e c t l   d r a i n   n o d e s / $ n o d e N a m e   - - i g n o r e - d a e m o n s e t s   - - g r a c e - p e r i o d = 0   I n s p e c t   t h e   . s t a t u s . f a i l e d   t o   c h e c k   t h e   c o u n t e r   f o r   t h e   J o b   i s   n o t   i n c r e m e n t e d : k u b e c t l   g e t


Question: What is Cleaning up?

Answer: D e l e t e   t h e   J o b   y o u   c r e a t e d :   k u b e c t l   d e l e t e   j o b s / j o b - p o d - f a i l u r e - p o l i c y - i g n o r e   T h e   c l u s t e r   a u t o m a t i c a l l y   c l e a n s   u p   t h e   P o d s .


Question: What is Using Pod failure policy to avoid unnecessary Pod retries based on custom Pod Conditions?

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


Question: What is Note:?

Answer: E x a m i n e   t h e   f o l l o w i n g   m a n i f e s t : / c o n t r o l l e r s / j o b - p o d - f a i l u r e - p o l i c y - c o n f i g - i s s u e . y a m l   a p i V e r s i o n :   b a t c h / v 1   k i n d :   J o b   m e t a d a t a :   n a m e :   j o b - p o d - f a i l u r e - p o l i c y - c o n f i g - i s s u e   s p e c :   c o m p l e t i o n s :   8   p a r a l l e l i s m :   2   t e m p l a t e :   s p e c :   r e s t a r t P o l i c y :   N e v e r   c o n t a i n e r s :   -   n a m e :   m a i n   i m a g e :   " n o n - e x i s t i n g - r e p o / n o n - e x i s t i n g - i m a g e : e x a m p l e "   b a c k o f f L i m i t :   6   p o d F a i l u r e P o l i c y :   r u l e s :   -   a c t i o n :   F a i l J o b   o n P o d C o n d i t i o n s :   -   t y p e :   C o n f i g I s s u e   A p p l y   t h e   m a n i f e s t : k u b e c t l   c r e a t e   - f   h t t p s : / / k 8 s . i o / e x a m p l e s / c o n t r o l l e r s / j o b - p o d - f a i l u r e - p o l i c y - c o n f i g - i s s u e . y a m l   N o t e   t h a t ,   t h e   i m a g e   i s   m i s c o n f i g u r e d ,   a s   i t   d o e s   n o t   e x i s t . I n s p e c t   t h e   s t a t u s   o f   t h e   j o b ' s   P o d s   b y   r u n n i n g : k u b e c t l   g e t   p o d s   - l   j o b - n a m e = j o b - p o d - f a i l u r e - p o l i c y - c o n f i g - i s s u e   - o   y a m l   Y o u   w i l l   s e e   o u t p u t   s i m i l a r   t o   t h i s : c o n t a i n e r S t a t u s e s :   -   i m a g e :   n o n - e x i s t i n g - r e p o / n o n - e x i s t i n g - i m a g e : e x a m p l e   . . .   s t a t e :   w a i t i n g :   m e s s a g e :   B a c k - o f f   p u l l i n g   i m a g e   " n o n - e x i s t i n g - r e p o / n o n - e x i s t i n g - i m a g e : e x a m p l e "   r e a s o n :   I m a g e P u l l B a c k O f f   . . .   p h a s e :   P e n d i n g   N o t e   t h a t   t h e   p o d   r e m a i n s   i n   t h e   P e n d


Question: What is Cleaning up?

Answer: D e l e t e   t h e   J o b   y o u   c r e a t e d :   k u b e c t l   d e l e t e   j o b s / j o b - p o d - f a i l u r e - p o l i c y - c o n f i g - i s s u e   T h e   c l u s t e r   a u t o m a t i c a l l y   c l e a n s   u p   t h e   P o d s .


Question: What is Using Pod Failure Policy to avoid unnecessary Pod retries per index?

Answer: T o   a v o i d   u n n e c e s s a r y   P o d   r e s t a r t s   p e r   i n d e x ,   y o u   c a n   u s e   t h e   P o d   f a i l u r e   p o l i c y   a n d   b a c k o f f   l i m i t   p e r   i n d e x   f e a t u r e s .   T h i s   s e c t i o n   o f   t h e   p a g e   s h o w s   h o w   t o   u s e   t h e s e   f e a t u r e s   t o g e t h e r .   E x a m i n e   t h e   f o l l o w i n g   m a n i f e s t : / c o n t r o l l e r s / j o b - b a c k o f f - l i m i t - p e r - i n d e x - f a i l i n d e x . y a m l   a p i V e r s i o n :   b a t c h / v 1   k i n d :   J o b   m e t a d a t a :   n a m e :   j o b - b a c k o f f - l i m i t - p e r - i n d e x - f a i l i n d e x   s p e c :   c o m p l e t i o n s :   4   p a r a l l e l i s m :   2   c o m p l e t i o n M o d e :   I n d e x e d   b a c k o f f L i m i t P e r I n d e x :   1   t e m p l a t e :   s p e c :   r e s t a r t P o l i c y :   N e v e r   c o n t a i n e r s :   -   n a m e :   m a i n   i m a g e :   d o c k e r . i o / l i b r a r y / p y t h o n : 3   c o m m a n d :   #   T h e   s c r i p t :   #   -   f a i l s   t h e   P o d   w i t h   i n d e x   0   w i t h   e x i t   c o d e   1 ,   w h i c h   r e s u l t s   i n   o n e   r e t r y ;   #   -   f a i l s   t h e   P o d   w i t h   i n d e x   1   w i t h   e x i t   c o d e   4 2   w h i c h   r e s u l t s   #   i n   f a i l i n g   t h e   i n d e x   w i t h o u t   r e t r y .   #   -   s u c c e e d s   P o d s   w i t h   a n y   o t h e r   i n d e x .   -   p y t h o n 3   -   - c   -   |   i m p o r t   o s ,   s y s   i n d e x   =   i n t ( o s . e n v i r o n . g e t ( " J O B _ C O M P L E T I O N _ I N D E X " ) )   i f   i n d e x   = =   0 :   s y s . e x i t ( 1 )   e l i f   i n d e x   = =   1 :   s y s . e x i t ( 4 2 )   e l s e :   s y s . e x i t ( 0 )   b a c k o f f L i m i t :   6   p o d F a i l u r e P o l i c y :   r u l e s :   -   a c t i o n :   F a i l I n d e x


Question: What is Cleaning up?

Answer: D e l e t e   t h e   J o b   y o u   c r e a t e d :   k u b e c t l   d e l e t e   j o b s / j o b - b a c k o f f - l i m i t - p e r - i n d e x - f a i l i n d e x   T h e   c l u s t e r   a u t o m a t i c a l l y   c l e a n s   u p   t h e   P o d s .


Question: What is Alternatives?

Answer: Y o u   c o u l d   r e l y   s o l e l y   o n   t h e   P o d   b a c k o f f   f a i l u r e   p o l i c y ,   b y   s p e c i f y i n g   t h e   J o b ' s   . s p e c . b a c k o f f L i m i t   f i e l d .   H o w e v e r ,   i n   m a n y   s i t u a t i o n s   i t   i s   p r o b l e m a t i c   t o   f i n d   a   b a l a n c e   b e t w e e n   s e t t i n g   a   l o w   v a l u e   f o r   . s p e c . b a c k o f f L i m i t   t o   a v o i d   u n n e c e s s a r y   P o d   r e t r i e s ,   y e t   h i g h   e n o u g h   t o   m a k e   s u r e   t h e   J o b   w o u l d   n o t   b e   t e r m i n a t e d   b y   P o d   d i s r u p t i o n s .   ©   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 Configure Pods and Containers?

Answer: This is the multi-page printable view of this section. Click here to print.Return to the regular view of this page.Configure Pods and ContainersPerform common configuration tasks for Pods and containers.1: Assign Memory Resources to Containers and Pods2: Assign CPU Resources to Containers and Pods3: Assign Devices to Pods and Containers3.1: Set Up DRA in a Cluster3.2: Allocate Devices to Workloads with DRA4: Assign Pod-level CPU and memory resources5: Configure GMSA for Windows Pods and containers6: Resize CPU and Memory Resources assigned to Containers7: Configure RunAsUserName for Windows pods and containers8: Create a Windows HostProcess Pod9: Configure Quality of Service for Pods10: Assign Extended Resources to a Container11: Configure a Pod to Use a Volume for Storage12: Configure a Pod to Use a PersistentVolume for Storage13: Configure a Pod to Use a Projected Volume for Storage14: Configure a Security Context for a Pod or Container15: Configure Service Accounts for Pods16: Pull an Image from a Private Registry17: Configure Liveness, Readiness and Startup Probes18: Assign Pods to Nodes19: Assign Pods to Nodes using Node Affinity20: Configure Pod Initialization21: Attach Handlers to Container Lifecycle Events22: Configure a Pod to Use a ConfigMap23: Share Process Namespace between Containers in a Pod24: Use a User Namespace With a Pod25: Use an Image Volume With a Pod26: Create static Pods27: Translate a Docker Compose File to Kubernetes Resources28: Enforce Pod Security Standards by Configuring the Built-in Admission Controller29: Enforce Pod Security Standards with Namespace Labels30: Migrate from PodSecurityPolicy to the Built-In PodSecurity Admission Controller1 - Assign Memory Resources to Containers and PodsThis page shows how to assign a memory request and a memory limit to a Container. A Container is guaranteed to have as much memory as it requests, but is not allowed to use more memory than its limit.Before you beginYou 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 KubernetesTo check the version, enter kubectl version.Each node in your cluster must have at least 300 MiB of memory.A few of the steps on this page require you to run the metrics-server service in your cluster. If you have the metrics-server running, you can skip those steps.If you are running Minikube, run the following command to enable the metrics-server:minikube addons enable metrics-server To see whether the metrics-server is running, or another provider of the resource metrics API (metrics.k8s.io), run the following command:kubectl get apiservices If the resource metrics API is available, the output includes


Question: How does Configure Pods and Containers work?

Answer: This is the multi-page printable view of this section. Click here to print.Return to the regular view of this page.Configure Pods and ContainersPerform common configuration tasks for Pods and containers.1: Assign Memory Resources to Containers and Pods2: Assign CPU Resources to Containers and Pods3: Assign Devices to Pods and Containers3.1: Set Up DRA in a Cluster3.2: Allocate Devices to Workloads with DRA4: Assign Pod-level CPU and memory resources5: Configure GMSA for Windows Pods and containers6: Resize CPU and Memory Resources assigned to Containers7: Configure RunAsUserName for Windows pods and containers8: Create a Windows HostProcess Pod9: Configure Quality of Service for Pods10: Assign Extended Resources to a Container11: Configure a Pod to Use a Volume for Storage12: Configure a Pod to Use a PersistentVolume for Storage13: Configure a Pod to Use a Projected Volume for Storage14: Configure a Security Context for a Pod or Container15: Configure Service Accounts for Pods16: Pull an Image from a Private Registry17: Configure Liveness, Readiness and Startup Probes18: Assign Pods to Nodes19: Assign Pods to Nodes using Node Affinity20: Configure Pod Initialization21: Attach Handlers to Container Lifecycle Events22: Configure a Pod to Use a ConfigMap23: Share Process Namespace between Containers in a Pod24: Use a User Namespace With a Pod25: Use an Image Volume With a Pod26: Create static Pods27: Translate a Docker Compose File to Kubernetes Resources28: Enforce Pod Security Standards by Configuring the Built-in Admission Controller29: Enforce Pod Security Standards with Namespace Labels30: Migrate from PodSecurityPolicy to the Built-In PodSecurity Admission Controller1 - Assign Memory Resources to Containers and PodsThis page shows how to assign a memory request and a memory limit to a Container. A Container is guaranteed to have as much memory as it requests, but is not allowed to use more memory than its limit.Before you beginYou 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 KubernetesTo check the version, enter kubectl version.Each node in your cluster must have at least 300 MiB of memory.A few of the steps on this page require you to run the metrics-server service in your cluster. If you have the metrics-server running, you can skip those steps.If you are running Minikube, run the following command to enable the metrics-server:minikube addons enable metrics-server To see whether the metrics-server is running, or another provider of the resource metrics API (metrics.k8s.io), run the following command:kubectl get apiservices If the resource metrics API is available, the output includes


Question: When would you use Configure Pods and Containers?

Answer: This is the multi-page printable view of this section. Click here to print.Return to the regular view of this page.Configure Pods and ContainersPerform common configuration tasks for Pods and containers.1: Assign Memory Resources to Containers and Pods2: Assign CPU Resources to Containers and Pods3: Assign Devices to Pods and Containers3.1: Set Up DRA in a Cluster3.2: Allocate Devices to Workloads with DRA4: Assign Pod-level CPU and memory resources5: Configure GMSA for Windows Pods and containers6: Resize CPU and Memory Resources assigned to Containers7: Configure RunAsUserName for Windows pods and containers8: Create a Windows HostProcess Pod9: Configure Quality of Service for Pods10: Assign Extended Resources to a Container11: Configure a Pod to Use a Volume for Storage12: Configure a Pod to Use a PersistentVolume for Storage13: Configure a Pod to Use a Projected Volume for Storage14: Configure a Security Context for a Pod or Container15: Configure Service Accounts for Pods16: Pull an Image from a Private Registry17: Configure Liveness, Readiness and Startup Probes18: Assign Pods to Nodes19: Assign Pods to Nodes using Node Affinity20: Configure Pod Initialization21: Attach Handlers to Container Lifecycle Events22: Configure a Pod to Use a ConfigMap23: Share Process Namespace between Containers in a Pod24: Use a User Namespace With a Pod25: Use an Image Volume With a Pod26: Create static Pods27: Translate a Docker Compose File to Kubernetes Resources28: Enforce Pod Security Standards by Configuring the Built-in Admission Controller29: Enforce Pod Security Standards with Namespace Labels30: Migrate from PodSecurityPolicy to the Built-In PodSecurity Admission Controller1 - Assign Memory Resources to Containers and PodsThis page shows how to assign a memory request and a memory limit to a Container. A Container is guaranteed to have as much memory as it requests, but is not allowed to use more memory than its limit.Before you beginYou 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 KubernetesTo check the version, enter kubectl version.Each node in your cluster must have at least 300 MiB of memory.A few of the steps on this page require you to run the metrics-server service in your cluster. If you have the metrics-server running, you can skip those steps.If you are running Minikube, run the following command to enable the metrics-server:minikube addons enable metrics-server To see whether the metrics-server is running, or another provider of the resource metrics API (metrics.k8s.io), run the following command:kubectl get apiservices If the resource metrics API is available, the output includes


Question: What are the benefits of Configure Pods and Containers?

Answer: This is the multi-page printable view of this section. Click here to print.Return to the regular view of this page.Configure Pods and ContainersPerform common configuration tasks for Pods and containers.1: Assign Memory Resources to Containers and Pods2: Assign CPU Resources to Containers and Pods3: Assign Devices to Pods and Containers3.1: Set Up DRA in a Cluster3.2: Allocate Devices to Workloads with DRA4: Assign Pod-level CPU and memory resources5: Configure GMSA for Windows Pods and containers6: Resize CPU and Memory Resources assigned to Containers7: Configure RunAsUserName for Windows pods and containers8: Create a Windows HostProcess Pod9: Configure Quality of Service for Pods10: Assign Extended Resources to a Container11: Configure a Pod to Use a Volume for Storage12: Configure a Pod to Use a PersistentVolume for Storage13: Configure a Pod to Use a Projected Volume for Storage14: Configure a Security Context for a Pod or Container15: Configure Service Accounts for Pods16: Pull an Image from a Private Registry17: Configure Liveness, Readiness and Startup Probes18: Assign Pods to Nodes19: Assign Pods to Nodes using Node Affinity20: Configure Pod Initialization21: Attach Handlers to Container Lifecycle Events22: Configure a Pod to Use a ConfigMap23: Share Process Namespace between Containers in a Pod24: Use a User Namespace With a Pod25: Use an Image Volume With a Pod26: Create static Pods27: Translate a Docker Compose File to Kubernetes Resources28: Enforce Pod Security Standards by Configuring the Built-in Admission Controller29: Enforce Pod Security Standards with Namespace Labels30: Migrate from PodSecurityPolicy to the Built-In PodSecurity Admission Controller1 - Assign Memory Resources to Containers and PodsThis page shows how to assign a memory request and a memory limit to a Container. A Container is guaranteed to have as much memory as it requests, but is not allowed to use more memory than its limit.Before you beginYou 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 KubernetesTo check the version, enter kubectl version.Each node in your cluster must have at least 300 MiB of memory.A few of the steps on this page require you to run the metrics-server service in your cluster. If you have the metrics-server running, you can skip those steps.If you are running Minikube, run the following command to enable the metrics-server:minikube addons enable metrics-server To see whether the metrics-server is running, or another provider of the resource metrics API (metrics.k8s.io), run the following command:kubectl get apiservices If the resource metrics API is available, the output includes


Question: What is Configure Pods and Containers?

Answer: 1 :   A s s i g n   M e m o r y   R e s o u r c e s   t o   C o n t a i n e r s   a n d   P o d s 2 :   A s s i g n   C P U   R e s o u r c e s   t o   C o n t a i n e r s   a n d   P o d s 3 :   A s s i g n   D e v i c e s   t o   P o d s   a n d   C o n t a i n e r s 3 . 1 :   S e t   U p   D R A   i n   a   C l u s t e r 3 . 2 :   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 4 :   A s s i g n   P o d - l e v e l   C P U   a n d   m e m o r y   r e s o u r c e s 5 :   C o n f i g u r e   G M S A   f o r   W i n d o w s   P o d s   a n d   c o n t a i n e r s 6 :   R e s i z e   C P U   a n d   M e m o r y   R e s o u r c e s   a s s i g n e d   t o   C o n t a i n e r s 7 :   C o n f i g u r e   R u n A s U s e r N a m e   f o r   W i n d o w s   p o d s   a n d   c o n t a i n e r s 8 :   C r e a t e   a   W i n d o w s   H o s t P r o c e s s   P o d 9 :   C o n f i g u r e   Q u a l i t y   o f   S e r v i c e   f o r   P o d s 1 0 :   A s s i g n   E x t e n d e d   R e s o u r c e s   t o   a   C o n t a i n e r 1 1 :   C o n f i g u r e   a   P o d   t o   U s e   a   V o l u m e   f o r   S t o r a g e 1 2 :   C o n f i g u r e   a   P o d   t o   U s e   a   P e r s i s t e n t V o l u m e   f o r   S t o r a g e 1 3 :   C o n f i g u r e   a   P o d   t o   U s e   a   P r o j e c t e d   V o l u m e   f o r   S t o r a g e 1 4 :   C o n f i g u r e   a   S e c u r i t y   C o n t e x t   f o r   a   P o d   o r   C o n t a i n e r 1 5 :   C o n f i g u r e   S e r v i c e   A c c o u n t s   f o r   P o d s 1 6 :   P u l l   a n   I m a g e   f r o m   a   P r i v a t e   R e g i s t r y 1 7 :   C o n f i g u r e   L i v e n e s s ,   R e a d i n e s s   a n d   S t a r t u p   P r o b e s 1 8 :   A s s i g n   P o d s   t o   N o d e s 1 9 :   A s s i g n   P o d s   t o   N o d e s   u s i n g   N o d e   A f f i n i t y 2 0 :   C o n f i g u r e   P o d   I n i t i a l i z a t i o n 2 1 :   A t t a c h   H a n d l e r s


Question: What is 1 - Assign Memory Resources to Containers and Pods?

Answer: T h i s   p a g e   s h o w s   h o w   t o   a s s i g n   a   m e m o r y   r e q u e s t   a n d   a   m e m o r y   l i m i t   t o   a   C o n t a i n e r .   A   C o n t a i n e r   i s   g u a r a n t e e d   t o   h a v e   a s   m u c h   m e m o r y   a s   i t   r e q u e s t s ,   b u t   i s   n o t   a l l o w e d   t o   u s e   m o r e   m e m o r y   t h a n   i t s   l i m i t .


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 .   E a c h   n o d e   i n   y o u r   c l u s t e r   m u s t   h a v e   a t   l e a s t   3 0 0   M i B   o f   m e m o r y


Question: What is Create a namespace?

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


Question: What is Specify a memory request and a memory limit?

Answer: T o   s p e c i f y   a   m e m o r y   r e q u e s t   f o r   a   C o n t a i n e r ,   i n c l u d e   t h e   r e s o u r c e s : r e q u e s t s   f i e l d   i n   t h e   C o n t a i n e r ' s   r e s o u r c e   m a n i f e s t .   T o   s p e c i f y   a   m e m o r y   l i m i t ,   i n c l u d e   r e s o u r c e s : l i m i t s .   I n   t h i s   e x e r c i s e ,   y o u   c r e a t e   a   P o d   t h a t   h a s   o n e   C o n t a i n e r .   T h e   C o n t a i n e r   h a s   a   m e m o r y   r e q u e s t   o f   1 0 0   M i B   a n d   a   m e m o r y   l i m i t   o f   2 0 0   M i B .   H e r e ' s   t h e   c o n f i g u r a t i o n   f i l e   f o r   t h e   P o d :   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 :   m e m o r y - d e m o   n a m e s p a c e :   m e m - e x a m p l e   s p e c :   c o n t a i n e r s :   -   n a m e :   m e m o r y - d e m o - c t r   i m a g e :   p o l i n u x / s t r e s s   r e s o u r c e s :   r e q u e s t s :   m e m o r y :   " 1 0 0 M i "   l i m i t s :   m e m o r y :   " 2 0 0 M i "   c o m m a n d :   [ " s t r e s s " ]   a r g s :   [ " - - v m " ,   " 1 " ,   " - - v m - b y t e s " ,   " 1 5 0 M " ,   " - - v m - h a n g " ,   " 1 " ]   T h e   a r g s   s e c t i o n   i n   t h e   c o n f i g u r a t i o n   f i l e   p r o v i d e s   a r g u m e n t s   f o r   t h e   C o n t a i n e r   w h e n   i t   s t a r t s .   T h e   " - - v m - b y t e s " ,   " 1 5 0 M "   a r g u m e n t s   t e l l   t h e   C o n t a i n e r   t o   a t t e m p t   t o   a l l o c a t e   1 5 0   M i B   o f   m e m o r y .   C r e a t e   t h e   P o d :   k u b e c t l   a p p l y   - f   h t t p s : / / k 8 s . i o / e x a m p l e s / p o d s / r e s o u r c e / m e m o r y - r e q u e s t - l i m i t . y a m l   - - n a m e s p a c e = m e m - e x a m p l e   V e r i f y   t h a t   t h e   P o d   C o n t a i n e r   i s   r u n n i n g :   k u b e c t l   g e t


Question: What is Exceed a Container's memory limit?

Answer: A   C o n t a i n e r   c a n   e x c e e d   i t s   m e m o r y   r e q u e s t   i f   t h e   N o d e   h a s   m e m o r y   a v a i l a b l e .   B u t   a   C o n t a i n e r   i s   n o t   a l l o w e d   t o   u s e   m o r e   t h a n   i t s   m e m o r y   l i m i t .   I f   a   C o n t a i n e r   a l l o c a t e s   m o r e   m e m o r y   t h a n   i t s   l i m i t ,   t h e   C o n t a i n e r   b e c o m e s   a   c a n d i d a t e   f o r   t e r m i n a t i o n .   I f   t h e   C o n t a i n e r   c o n t i n u e s   t o   c o n s u m e   m e m o r y   b e y o n d   i t s   l i m i t ,   t h e   C o n t a i n e r   i s   t e r m i n a t e d .   I f   a   t e r m i n a t e d   C o n t a i n e r   c a n   b e   r e s t a r t e d ,   t h e   k u b e l e t   r e s t a r t s   i t ,   a s   w i t h   a n y   o t h e r   t y p e   o f   r u n t i m e   f a i l u r e .   I n   t h i s   e x e r c i s e ,   y o u   c r e a t e   a   P o d   t h a t   a t t e m p t s   t o   a l l o c a t e   m o r e   m e m o r y   t h a n   i t s   l i m i t .   H e r e   i s   t h e   c o n f i g u r a t i o n   f i l e   f o r   a   P o d   t h a t   h a s   o n e   C o n t a i n e r   w i t h   a   m e m o r y   r e q u e s t   o f   5 0   M i B   a n d   a   m e m o r y   l i m i t   o f   1 0 0   M i B :   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 :   m e m o r y - d e m o - 2   n a m e s p a c e :   m e m - e x a m p l e   s p e c :   c o n t a i n e r s :   -   n a m e :   m e m o r y - d e m o - 2 - c t r   i m a g e :   p o l i n u x / s t r e s s   r e s o u r c e s :   r e q u e s t s :   m e m o r y :   " 5 0 M i "   l i m i t s :   m e m o r y :   " 1 0 0 M i "   c o m m a n d :   [ " s t r e s s " ]   a r g s :   [ " - - v m " ,   " 1 " ,   " - - v m - b y t e s " ,   " 2 5 0 M " ,   " - - v m - h a n g " ,   " 1 " ]   I n   t h e   a r g s   s e c t i o n   o f   t h e   c o n f i g u r a t i o n   f i l e ,   y o u


Question: What is Specify a memory request that is too big for your Nodes?

Answer: M e m o r y   r e q u e s t s   a n d   l i m i t s   a r e   a s s o c i a t e d   w i t h   C o n t a i n e r s ,   b u t   i t   i s   u s e f u l   t o   t h i n k   o f   a   P o d   a s   h a v i n g   a   m e m o r y   r e q u e s t   a n d   l i m i t .   T h e   m e m o r y   r e q u e s t   f o r   t h e   P o d   i s   t h e   s u m   o f   t h e   m e m o r y   r e q u e s t s   f o r   a l l   t h e   C o n t a i n e r s   i n   t h e   P o d .   L i k e w i s e ,   t h e   m e m o r y   l i m i t   f o r   t h e   P o d   i s   t h e   s u m   o f   t h e   l i m i t s   o f   a l l   t h e   C o n t a i n e r s   i n   t h e   P o d .   P o d   s c h e d u l i n g   i s   b a s e d   o n   r e q u e s t s .   A   P o d   i s   s c h e d u l e d   t o   r u n   o n   a   N o d e   o n l y   i f   t h e   N o d e   h a s   e n o u g h   a v a i l a b l e   m e m o r y   t o   s a t i s f y   t h e   P o d ' s   m e m o r y   r e q u e s t .   I n   t h i s   e x e r c i s e ,   y o u   c r e a t e   a   P o d   t h a t   h a s   a   m e m o r y   r e q u e s t   s o   b i g   t h a t   i t   e x c e e d s   t h e   c a p a c i t y   o f   a n y   N o d e   i n   y o u r   c l u s t e r .   H e r e   i s   t h e   c o n f i g u r a t i o n   f i l e   f o r   a   P o d   t h a t   h a s   o n e   C o n t a i n e r   w i t h   a   r e q u e s t   f o r   1 0 0 0   G i B   o f   m e m o r y ,   w h i c h   l i k e l y   e x c e e d s   t h e   c a p a c i t y   o f   a n y   N o d e   i n   y o u r   c l u s t 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 :   m e m o r y - d e m o - 3   n a m e s p a c e :   m e m - e x a m p l e   s p e c :   c o n t a i n e r s :   -   n a m e :   m e m o r y - d e m o - 3 - c t r   i m a g e :   p o l i n u x / s t r e s s   r e s o u r c e s :   r e q u e s t s :   m e m o r y :   " 1 0 0 0 G i "   l i m i t s :   m e m o r y :   " 1 0 0 0 G i "   c o m m a n d :   [ " s t r e s


Question: What is Memory units?

Answer: T h e   m e m o r y   r e s o u r c e   i s   m e a s u r e d   i n   b y t e s .   Y o u   c a n   e x p r e s s   m e m o r y   a s   a   p l a i n   i n t e g e r   o r   a   f i x e d - p o i n t   i n t e g e r   w i t h   o n e   o f   t h e s e   s u f f i x e s :   E ,   P ,   T ,   G ,   M ,   K ,   E i ,   P i ,   T i ,   G i ,   M i ,   K i .   F o r   e x a m p l e ,   t h e   f o l l o w i n g   r e p r e s e n t   a p p r o x i m a t e l y   t h e   s a m e   v a l u e :   1 2 8 9 7 4 8 4 8 ,   1 2 9 e 6 ,   1 2 9 M ,   1 2 3 M i   D e l e t e   y o u r   P o d :   k u b e c t l   d e l e t e   p o d   m e m o r y - d e m o - 3   - - n a m e s p a c e = m e m - e x a m p l e


Question: What is If you do not specify a memory limit?

Answer: I f   y o u   d o   n o t   s p e c i f y   a   m e m o r y   l i m i t   f o r   a   C o n t a i n e r ,   o n e   o f   t h e   f o l l o w i n g   s i t u a t i o n s   a p p l i e s :   T h e   C o n t a i n e r   h a s   n o   u p p e r   b o u n d   o n   t h e   a m o u n t   o f   m e m o r y   i t   u s e s .   T h e   C o n t a i n e r   c o u l d   u s e   a l l   o f   t h e   m e m o r y   a v a i l a b l e   o n   t h e   N o d e   w h e r e   i t   i s   r u n n i n g   w h i c h   i n   t u r n   c o u l d   i n v o k e   t h e   O O M   K i l l e r .   F u r t h e r ,   i n   c a s e   o f   a n   O O M   K i l l ,   a   c o n t a i n e r   w i t h   n o   r e s o u r c e   l i m i t s   w i l l   h a v e   a   g r e a t e r   c h a n c e   o f   b e i n g   k i l l e d . T h e   C o n t a i n e r   i s   r u n n i n g   i n   a   n a m e s p a c e   t h a t   h a s   a   d e f a u l t   m e m o r y   l i m i t ,   a n d   t h e   C o n t a i n e r   i s   a u t o m a t i c a l l y   a s s i g n e d   t h e   d e f a u l t   l i m i t .   C l u s t e r   a d m i n i s t r a t o r s   c a n   u s e   a   L i m i t R a n g e   t o   s p e c i f y   a   d e f a u l t   v a l u e   f o r   t h e   m e m o r y   l i m i t .   T h e   C o n t a i n e r   h a s   n o   u p p e r   b o u n d   o n   t h e   a m o u n t   o f   m e m o r y   i t   u s e s .   T h e   C o n t a i n e r   c o u l d   u s e   a l l   o f   t h e   m e m o r y   a v a i l a b l e   o n   t h e   N o d e   w h e r e   i t   i s   r u n n i n g   w h i c h   i n   t u r n   c o u l d   i n v o k e   t h e   O O M   K i l l e r .   F u r t h e r ,   i n   c a s e   o f   a n   O O M   K i l l ,   a   c o n t a i n e r   w i t h   n o   r e s o u r c e   l i m i t s   w i l l   h a v e   a   g r e a t e r   c h a n c e   o f   b e i n g   k i l l e d .   T h e   C o n t a i n e r   i s   r u n n i n g   i n   a   n a m e s p a c e   t h a t   h a s   a   d e f a u l t   m e m o r y


Question: What is Motivation for memory requests and limits?

Answer: B y   c o n f i g u r i n g   m e m o r y   r e q u e s t s   a n d   l i m i t s   f o r   t h e   C o n t a i n e r s   t h a t   r u n   i n   y o u r   c l u s t e r ,   y o u   c a n   m a k e   e f f i c i e n t   u s e   o f   t h e   m e m o r y   r e s o u r c e s   a v a i l a b l e   o n   y o u r   c l u s t e r ' s   N o d e s .   B y   k e e p i n g   a   P o d ' s   m e m o r y   r e q u e s t   l o w ,   y o u   g i v e   t h e   P o d   a   g o o d   c h a n c e   o f   b e i n g   s c h e d u l e d .   B y   h a v i n g   a   m e m o r y   l i m i t   t h a t   i s   g r e a t e r   t h a n   t h e   m e m o r y   r e q u e s t ,   y o u   a c c o m p l i s h   t w o   t h i n g s :   T h e   P o d   c a n   h a v e   b u r s t s   o f   a c t i v i t y   w h e r e   i t   m a k e s   u s e   o f   m e m o r y   t h a t   h a p p e n s   t o   b e   a v a i l a b l e . T h e   a m o u n t   o f   m e m o r y   a   P o d   c a n   u s e   d u r i n g   a   b u r s t   i s   l i m i t e d   t o   s o m e   r e a s o n a b l e   a m o u n t .


Question: What is Clean up?

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


Question: What is For app developers?

Answer: A s s i g n   C P U   R e s o u r c e s   t o   C o n t a i n e r s   a n d   P o d s A s s i g n   P o d - l e v e l   C P U   a n d   m e m o r y   r e s o u r c e s C o n f i g u r e   Q u a l i t y   o f   S e r v i c e   f o r   P o d s R e s i z e   C P U   a n d   M e m o r y   R e s o u r c e s   a s s i g n e d   t o   C o n t a i n e r s   A s s i g n   C P U   R e s o u r c e s   t o   C o n t a i n e r s   a n d   P o d s   A s s i g n   P o d - l e v e l   C P U   a n d   m e m o r y   r e s o u r c e s   C o n f i g u r e   Q u a l i t y   o f   S e r v i c e   f o r   P o d s   R e s i z e   C P U   a n d   M e m o r y   R e s o u r c e s   a s s i g n e d   t o   C o n t a i n e r s


Question: What is For cluster administrators?

Answer: C o n f i g u r e   D e f a u l t   M e m o r y   R e q u e s t s   a n d   L i m i t s   f o r   a   N a m e s p a c e C o n f i g u r e   D e f a u l t   C P U   R e q u e s t s   a n d   L i m i t s   f o r   a   N a m e s p a c e C o n f i g u r e   M i n i m u m   a n d   M a x i m u m   M e m o r y   C o n s t r a i n t s   f o r   a   N a m e s p a c e C o n f i g u r e   M i n i m u m   a n d   M a x i m u m   C P U   C o n s t r a i n t s   f o r   a   N a m e s p a c e C o n f i g u r e   M e m o r y   a n d   C P U   Q u o t a s   f o r   a   N a m e s p a c e C o n f i g u r e   a   P o d   Q u o t a   f o r   a   N a m e s p a c e C o n f i g u r e   Q u o t a s   f o r   A P I   O b j e c t s R e s i z e   C P U   a n d   M e m o r y   R e s o u r c e s   a s s i g n e d   t o   C o n t a i n e r s   C o n f i g u r e   D e f a u l t   M e m o r y   R e q u e s t s   a n d   L i m i t s   f o r   a   N a m e s p a c e   C o n f i g u r e   D e f a u l t   C P U   R e q u e s t s   a n d   L i m i t s   f o r   a   N a m e s p a c e   C o n f i g u r e   M i n i m u m   a n d   M a x i m u m   M e m o r y   C o n s t r a i n t s   f o r   a   N a m e s p a c e   C o n f i g u r e   M i n i m u m   a n d   M a x i m u m   C P U   C o n s t r a i n t s   f o r   a   N a m e s p a c e   C o n f i g u r e   M e m o r y   a n d   C P U   Q u o t a s   f o r   a   N a m e s p a c e   C o n f i g u r e   a   P o d   Q u o t a   f o r   a   N a m e s p a c e   C o n f i g u r e   Q u o t a s   f o r   A P I   O b j e c t s   R e s i z e   C P U   a n d   M e m o r y   R e s o u r c e s   a s s i g n e d   t o   C o n t a i n e r s


Question: What is 2 - Assign CPU Resources to Containers and Pods?

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


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 .   Y o u r   c l u s t e r   m u s t   h a v e   a t   l e a s t   1   C P U   a v a i l a b l e   f o r   u s e   t o   r u n


Question: What is Create a namespace?

Answer: C r e a t e   a   N a m e s p a c e   s o   t h a t   t h e   r e s o u r c e s   y o u   c r e a t e   i n   t h i s   e x e r c i s e   a r e   i s o l a t e d   f r o m   t h e   r e s t   o f   y o u r   c l u s t e r .   k u b e c t l   c r e a t e   n a m e s p a c e   c p u - e x a m p l e