Question: What are the benefits of Labels and Selectors?

Answer: Labels and SelectorsLabels are key/value pairs that are attached to objects such as Pods. Labels are intended to be used to specify identifying attributes of objects that are meaningful and relevant to users, but do not directly imply semantics to the core system. Labels can be used to organize and to select subsets of objects. Labels can be attached to objects at creation time and subsequently added and modified at any time. Each object can have a set of key/value labels defined. Each Key must be unique for a given object."metadata": { "labels": { "key1" : "value1", "key2" : "value2" } } Labels allow for efficient queries and watches and are ideal for use in UIs and CLIs. Non-identifying information should be recorded using annotations.MotivationLabels enable users to map their own organizational structures onto system objects in a loosely coupled fashion, without requiring clients to store these mappings.Service deployments and batch processing pipelines are often multi-dimensional entities (e.g., multiple partitions or deployments, multiple release tracks, multiple tiers, multiple micro-services per tier). Management often requires cross-cutting operations, which breaks encapsulation of strictly hierarchical representations, especially rigid hierarchies determined by the infrastructure rather than by users.Example labels:"release" : "stable", "release" : "canary""environment" : "dev", "environment" : "qa", "environment" : "production""tier" : "frontend", "tier" : "backend", "tier" : "cache""partition" : "customerA", "partition" : "customerB""track" : "daily", "track" : "weekly"These are examples of commonly used labels; you are free to develop your own conventions. Keep in mind that label Key must be unique for a given object.Syntax and character setLabels are key/value pairs. Valid label keys have two segments: an optional prefix and name, separated by a slash (/). The name segment is required and must be 63 characters or less, beginning and ending with an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), dots (.), and alphanumerics between. The prefix is optional. If specified, the prefix must be a DNS subdomain: a series of DNS labels separated by dots (.), not longer than 253 characters in total, followed by a slash (/).If the prefix is omitted, the label Key is presumed to be private to the user. Automated system components (e.g. kube-scheduler, kube-controller-manager, kube-apiserver, kubectl, or other third-party automation) which add labels to end-user objects must specify a prefix.The kubernetes.io/ and k8s.io/ prefixes are reserved for Kubernetes core components.Valid label value:must be 63 characters or less (can be empty),unless empty, must begin and end with an alphanumeric character ([a-z0-9A-Z]),could contain dashes (-), underscores (_), dots (.), and alphanumerics between.For example, here's a manifest for a Pod that has two labels environment: production and app: nginx:apiVersion: v1 kind: Pod metadata: na


Question: What is Labels and Selectors?

Answer: L a b e l s   a r e   k e y / v a l u e   p a i r s   t h a t   a r e   a t t a c h e d   t o   o b j e c t s   s u c h   a s   P o d s .   L a b e l s   a r e   i n t e n d e d   t o   b e   u s e d   t o   s p e c i f y   i d e n t i f y i n g   a t t r i b u t e s   o f   o b j e c t s   t h a t   a r e   m e a n i n g f u l   a n d   r e l e v a n t   t o   u s e r s ,   b u t   d o   n o t   d i r e c t l y   i m p l y   s e m a n t i c s   t o   t h e   c o r e   s y s t e m .   L a b e l s   c a n   b e   u s e d   t o   o r g a n i z e   a n d   t o   s e l e c t   s u b s e t s   o f   o b j e c t s .   L a b e l s   c a n   b e   a t t a c h e d   t o   o b j e c t s   a t   c r e a t i o n   t i m e   a n d   s u b s e q u e n t l y   a d d e d   a n d   m o d i f i e d   a t   a n y   t i m e .   E a c h   o b j e c t   c a n   h a v e   a   s e t   o f   k e y / v a l u e   l a b e l s   d e f i n e d .   E a c h   K e y   m u s t   b e   u n i q u e   f o r   a   g i v e n   o b j e c t .   " m e t a d a t a " :   {   " l a b e l s " :   {   " k e y 1 "   :   " v a l u e 1 " ,   " k e y 2 "   :   " v a l u e 2 "   }   }   L a b e l s   a l l o w   f o r   e f f i c i e n t   q u e r i e s   a n d   w a t c h e s   a n d   a r e   i d e a l   f o r   u s e   i n   U I s   a n d   C L I s .   N o n - i d e n t i f y i n g   i n f o r m a t i o n   s h o u l d   b e   r e c o r d e d   u s i n g   a n n o t a t i o n s .


Question: What is Motivation?

Answer: L a b e l s   e n a b l e   u s e r s   t o   m a p   t h e i r   o w n   o r g a n i z a t i o n a l   s t r u c t u r e s   o n t o   s y s t e m   o b j e c t s   i n   a   l o o s e l y   c o u p l e d   f a s h i o n ,   w i t h o u t   r e q u i r i n g   c l i e n t s   t o   s t o r e   t h e s e   m a p p i n g s .   S e r v i c e   d e p l o y m e n t s   a n d   b a t c h   p r o c e s s i n g   p i p e l i n e s   a r e   o f t e n   m u l t i - d i m e n s i o n a l   e n t i t i e s   ( e . g . ,   m u l t i p l e   p a r t i t i o n s   o r   d e p l o y m e n t s ,   m u l t i p l e   r e l e a s e   t r a c k s ,   m u l t i p l e   t i e r s ,   m u l t i p l e   m i c r o - s e r v i c e s   p e r   t i e r ) .   M a n a g e m e n t   o f t e n   r e q u i r e s   c r o s s - c u t t i n g   o p e r a t i o n s ,   w h i c h   b r e a k s   e n c a p s u l a t i o n   o f   s t r i c t l y   h i e r a r c h i c a l   r e p r e s e n t a t i o n s ,   e s p e c i a l l y   r i g i d   h i e r a r c h i e s   d e t e r m i n e d   b y   t h e   i n f r a s t r u c t u r e   r a t h e r   t h a n   b y   u s e r s .   E x a m p l e   l a b e l s :   " r e l e a s e "   :   " s t a b l e " ,   " r e l e a s e "   :   " c a n a r y " " e n v i r o n m e n t "   :   " d e v " ,   " e n v i r o n m e n t "   :   " q a " ,   " e n v i r o n m e n t "   :   " p r o d u c t i o n " " t i e r "   :   " f r o n t e n d " ,   " t i e r "   :   " b a c k e n d " ,   " t i e r "   :   " c a c h e " " p a r t i t i o n "   :   " c u s t o m e r A " ,   " p a r t i t i o n "   :   " c u s t o m e r B " " t r a c k "   :   " d a i l y " ,   " t r a c k "   :   " w e e k l y "   T h e s e   a r e   e x a m p l e s   o f   c o m m o n l y   u s e d   l a b e l s ;   y o u   a r e   f r e e   t o   d e v e l o p   y o u r   o w n   c o n v e n t i o n s .   K e e p   i n   m i n d   t h a t   l a b e l   K e y   m u s t   b e   u n i q u e   f o r   a   g i v e n   o


Question: What is Syntax and character set?

Answer: L a b e l s   a r e   k e y / v a l u e   p a i r s .   V a l i d   l a b e l   k e y s   h a v e   t w o   s e g m e n t s :   a n   o p t i o n a l   p r e f i x   a n d   n a m e ,   s e p a r a t e d   b y   a   s l a s h   ( / ) .   T h e   n a m e   s e g m e n t   i s   r e q u i r e d   a n d   m u s t   b e   6 3   c h a r a c t e r s   o r   l e s s ,   b e g i n n i n g   a n d   e n d i n g   w i t h   a n   a l p h a n u m e r i c   c h a r a c t e r   ( [ a - z 0 - 9 A - Z ] )   w i t h   d a s h e s   ( - ) ,   u n d e r s c o r e s   ( _ ) ,   d o t s   ( . ) ,   a n d   a l p h a n u m e r i c s   b e t w e e n .   T h e   p r e f i x   i s   o p t i o n a l .   I f   s p e c i f i e d ,   t h e   p r e f i x   m u s t   b e   a   D N S   s u b d o m a i n :   a   s e r i e s   o f   D N S   l a b e l s   s e p a r a t e d   b y   d o t s   ( . ) ,   n o t   l o n g e r   t h a n   2 5 3   c h a r a c t e r s   i n   t o t a l ,   f o l l o w e d   b y   a   s l a s h   ( / ) .   I f   t h e   p r e f i x   i s   o m i t t e d ,   t h e   l a b e l   K e y   i s   p r e s u m e d   t o   b e   p r i v a t e   t o   t h e   u s e r .   A u t o m a t e d   s y s t e m   c o m p o n e n t s   ( e . g .   k u b e - s c h e d u l e r ,   k u b e - c o n t r o l l e r - m a n a g e r ,   k u b e - a p i s e r v e r ,   k u b e c t l ,   o r   o t h e r   t h i r d - p a r t y   a u t o m a t i o n )   w h i c h   a d d   l a b e l s   t o   e n d - u s e r   o b j e c t s   m u s t   s p e c i f y   a   p r e f i x .   T h e   k u b e r n e t e s . i o /   a n d   k 8 s . i o /   p r e f i x e s   a r e   r e s e r v e d   f o r   K u b e r n e t e s   c o r e   c o m p o n e n t s .   V a l i d   l a b e l   v a l u e :   m u s t   b e   6 3   c h a r a c t e r s   o r   l e s s   ( c a n   b e   e m p t y ) , u n l e s s   e m p t y ,   m u s t   b e g i n   a n d   e n d   w i t h   a n   a l p h a n u m e r i c   c h a r a c t e r   ( [ a - z 0 - 9 A


Question: What is Label selectors?

Answer: U n l i k e   n a m e s   a n d   U I D s ,   l a b e l s   d o   n o t   p r o v i d e   u n i q u e n e s s .   I n   g e n e r a l ,   w e   e x p e c t   m a n y   o b j e c t s   t o   c a r r y   t h e   s a m e   l a b e l ( s ) .   V i a   a   l a b e l   s e l e c t o r ,   t h e   c l i e n t / u s e r   c a n   i d e n t i f y   a   s e t   o f   o b j e c t s .   T h e   l a b e l   s e l e c t o r   i s   t h e   c o r e   g r o u p i n g   p r i m i t i v e   i n   K u b e r n e t e s .   T h e   A P I   c u r r e n t l y   s u p p o r t s   t w o   t y p e s   o f   s e l e c t o r s :   e q u a l i t y - b a s e d   a n d   s e t - b a s e d .   A   l a b e l   s e l e c t o r   c a n   b e   m a d e   o f   m u l t i p l e   r e q u i r e m e n t s   w h i c h   a r e   c o m m a - s e p a r a t e d .   I n   t h e   c a s e   o f   m u l t i p l e   r e q u i r e m e n t s ,   a l l   m u s t   b e   s a t i s f i e d   s o   t h e   c o m m a   s e p a r a t o r   a c t s   a s   a   l o g i c a l   A N D   ( & & )   o p e r a t o r .   T h e   s e m a n t i c s   o f   e m p t y   o r   n o n - s p e c i f i e d   s e l e c t o r s   a r e   d e p e n d e n t   o n   t h e   c o n t e x t ,   a n d   A P I   t y p e s   t h a t   u s e   s e l e c t o r s   s h o u l d   d o c u m e n t   t h e   v a l i d i t y   a n d   m e a n i n g   o f   t h e m .


Question: What is Equality-based requirement?

Answer: E q u a l i t y -   o r   i n e q u a l i t y - b a s e d   r e q u i r e m e n t s   a l l o w   f i l t e r i n g   b y   l a b e l   k e y s   a n d   v a l u e s .   M a t c h i n g   o b j e c t s   m u s t   s a t i s f y   a l l   o f   t h e   s p e c i f i e d   l a b e l   c o n s t r a i n t s ,   t h o u g h   t h e y   m a y   h a v e   a d d i t i o n a l   l a b e l s   a s   w e l l .   T h r e e   k i n d s   o f   o p e r a t o r s   a r e   a d m i t t e d   = , = = , ! = .   T h e   f i r s t   t w o   r e p r e s e n t   e q u a l i t y   ( a n d   a r e   s y n o n y m s ) ,   w h i l e   t h e   l a t t e r   r e p r e s e n t s   i n e q u a l i t y .   F o r   e x a m p l e :   e n v i r o n m e n t   =   p r o d u c t i o n   t i e r   ! =   f r o n t e n d   T h e   f o r m e r   s e l e c t s   a l l   r e s o u r c e s   w i t h   k e y   e q u a l   t o   e n v i r o n m e n t   a n d   v a l u e   e q u a l   t o   p r o d u c t i o n .   T h e   l a t t e r   s e l e c t s   a l l   r e s o u r c e s   w i t h   k e y   e q u a l   t o   t i e r   a n d   v a l u e   d i s t i n c t   f r o m   f r o n t e n d ,   a n d   a l l   r e s o u r c e s   w i t h   n o   l a b e l s   w i t h   t h e   t i e r   k e y .   O n e   c o u l d   f i l t e r   f o r   r e s o u r c e s   i n   p r o d u c t i o n   e x c l u d i n g   f r o n t e n d   u s i n g   t h e   c o m m a   o p e r a t o r :   e n v i r o n m e n t = p r o d u c t i o n , t i e r ! = f r o n t e n d   O n e   u s a g e   s c e n a r i o   f o r   e q u a l i t y - b a s e d   l a b e l   r e q u i r e m e n t   i s   f o r   P o d s   t o   s p e c i f y   n o d e   s e l e c t i o n   c r i t e r i a .   F o r   e x a m p l e ,   t h e   s a m p l e   P o d   b e l o w   s e l e c t s   n o d e s   w h e r e   t h e   a c c e l e r a t o r   l a b e l   e x i s t s   a n d   i s   s e t   t o   n v i d i a - t e s l a - p 1 0 0 .   a p i V e r s i o n :   v 1   k i n


Question: What is Set-based requirement?

Answer: S e t - b a s e d   l a b e l   r e q u i r e m e n t s   a l l o w   f i l t e r i n g   k e y s   a c c o r d i n g   t o   a   s e t   o f   v a l u e s .   T h r e e   k i n d s   o f   o p e r a t o r s   a r e   s u p p o r t e d :   i n , n o t i n   a n d   e x i s t s   ( o n l y   t h e   k e y   i d e n t i f i e r ) .   F o r   e x a m p l e :   e n v i r o n m e n t   i n   ( p r o d u c t i o n ,   q a )   t i e r   n o t i n   ( f r o n t e n d ,   b a c k e n d )   p a r t i t i o n   ! p a r t i t i o n   T h e   f i r s t   e x a m p l e   s e l e c t s   a l l   r e s o u r c e s   w i t h   k e y   e q u a l   t o   e n v i r o n m e n t   a n d   v a l u e   e q u a l   t o   p r o d u c t i o n   o r   q a . T h e   s e c o n d   e x a m p l e   s e l e c t s   a l l   r e s o u r c e s   w i t h   k e y   e q u a l   t o   t i e r   a n d   v a l u e s   o t h e r   t h a n   f r o n t e n d   a n d   b a c k e n d ,   a n d   a l l   r e s o u r c e s   w i t h   n o   l a b e l s   w i t h   t h e   t i e r   k e y . T h e   t h i r d   e x a m p l e   s e l e c t s   a l l   r e s o u r c e s   i n c l u d i n g   a   l a b e l   w i t h   k e y   p a r t i t i o n ;   n o   v a l u e s   a r e   c h e c k e d . T h e   f o u r t h   e x a m p l e   s e l e c t s   a l l   r e s o u r c e s   w i t h o u t   a   l a b e l   w i t h   k e y   p a r t i t i o n ;   n o   v a l u e s   a r e   c h e c k e d .   S i m i l a r l y   t h e   c o m m a   s e p a r a t o r   a c t s   a s   a n   A N D   o p e r a t o r .   S o   f i l t e r i n g   r e s o u r c e s   w i t h   a   p a r t i t i o n   k e y   ( n o   m a t t e r   t h e   v a l u e )   a n d   w i t h   e n v i r o n m e n t   d i f f e r e n t   t h a n   q a   c a n   b e   a c h i e v e d   u s i n g   p a r t i t i o n , e n v i r o n m e n t   n o t i n   ( q a ) .   T h e   s e t - b a s e d   l a b e l   s e l e c t o r   i s   a   g e n e r a l   f o r m   o f   e q u a l


Question: What is LIST and WATCH filtering?

Answer: F o r   l i s t   a n d   w a t c h   o p e r a t i o n s ,   y o u   c a n   s p e c i f y   l a b e l   s e l e c t o r s   t o   f i l t e r   t h e   s e t s   o f   o b j e c t s   r e t u r n e d ;   y o u   s p e c i f y   t h e   f i l t e r   u s i n g   a   q u e r y   p a r a m e t e r .   ( T o   l e a r n   i n   d e t a i l   a b o u t   w a t c h e s   i n   K u b e r n e t e s ,   r e a d   e f f i c i e n t   d e t e c t i o n   o f   c h a n g e s ) .   B o t h   r e q u i r e m e n t s   a r e   p e r m i t t e d   ( p r e s e n t e d   h e r e   a s   t h e y   w o u l d   a p p e a r   i n   a   U R L   q u e r y   s t r i n g ) :   e q u a l i t y - b a s e d   r e q u i r e m e n t s :   ? l a b e l S e l e c t o r = e n v i r o n m e n t % 3 D p r o d u c t i o n , t i e r % 3 D f r o n t e n d s e t - b a s e d   r e q u i r e m e n t s :   ? l a b e l S e l e c t o r = e n v i r o n m e n t + i n + % 2 8 p r o d u c t i o n % 2 C q a % 2 9 % 2 C t i e r + i n + % 2 8 f r o n t e n d % 2 9   B o t h   l a b e l   s e l e c t o r   s t y l e s   c a n   b e   u s e d   t o   l i s t   o r   w a t c h   r e s o u r c e s   v i a   a   R E S T   c l i e n t .   F o r   e x a m p l e ,   t a r g e t i n g   a p i s e r v e r   w i t h   k u b e c t l   a n d   u s i n g   e q u a l i t y - b a s e d   o n e   m a y   w r i t e :   k u b e c t l   g e t   p o d s   - l   e n v i r o n m e n t = p r o d u c t i o n , t i e r = f r o n t e n d   o r   u s i n g   s e t - b a s e d   r e q u i r e m e n t s :   k u b e c t l   g e t   p o d s   - l   ' e n v i r o n m e n t   i n   ( p r o d u c t i o n ) , t i e r   i n   ( f r o n t e n d ) '   A s   a l r e a d y   m e n t i o n e d   s e t - b a s e d   r e q u i r e m e n t s   a r e   m o r e   e x p r e s s i v e .   F o r   i n s t a n c e ,   t h e y   c a n   i m p l e m e n t   t h e   O R   o p e r a t o r   o n   v a l u e s :   k u b e c t l   g e t   p o d s   - l   ' e n v i r o n m


Question: What is Set references in API objects?

Answer: S o m e   K u b e r n e t e s   o b j e c t s ,   s u c h   a s   s e r v i c e s   a n d   r e p l i c a t i o n c o n t r o l l e r s ,   a l s o   u s e   l a b e l   s e l e c t o r s   t o   s p e c i f y   s e t s   o f   o t h e r   r e s o u r c e s ,   s u c h   a s   p o d s .


Question: What is Service and ReplicationController?

Answer: T h e   s e t   o f   p o d s   t h a t   a   s e r v i c e   t a r g e t s   i s   d e f i n e d   w i t h   a   l a b e l   s e l e c t o r .   S i m i l a r l y ,   t h e   p o p u l a t i o n   o f   p o d s   t h a t   a   r e p l i c a t i o n c o n t r o l l e r   s h o u l d   m a n a g e   i s   a l s o   d e f i n e d   w i t h   a   l a b e l   s e l e c t o r .   L a b e l   s e l e c t o r s   f o r   b o t h   o b j e c t s   a r e   d e f i n e d   i n   j s o n   o r   y a m l   f i l e s   u s i n g   m a p s ,   a n d   o n l y   e q u a l i t y - b a s e d   r e q u i r e m e n t   s e l e c t o r s   a r e   s u p p o r t e d :   " s e l e c t o r " :   {   " c o m p o n e n t "   :   " r e d i s " ,   }   o r   s e l e c t o r :   c o m p o n e n t :   r e d i s   T h i s   s e l e c t o r   ( r e s p e c t i v e l y   i n   j s o n   o r   y a m l   f o r m a t )   i s   e q u i v a l e n t   t o   c o m p o n e n t = r e d i s   o r   c o m p o n e n t   i n   ( r e d i s ) .


Question: What is Resources that support set-based requirements?

Answer: N e w e r   r e s o u r c e s ,   s u c h   a s   J o b ,   D e p l o y m e n t ,   R e p l i c a S e t ,   a n d   D a e m o n S e t ,   s u p p o r t   s e t - b a s e d   r e q u i r e m e n t s   a s   w e l l .   s e l e c t o r :   m a t c h L a b e l s :   c o m p o n e n t :   r e d i s   m a t c h E x p r e s s i o n s :   -   {   k e y :   t i e r ,   o p e r a t o r :   I n ,   v a l u e s :   [ c a c h e ]   }   -   {   k e y :   e n v i r o n m e n t ,   o p e r a t o r :   N o t I n ,   v a l u e s :   [ d e v ]   }   m a t c h L a b e l s   i s   a   m a p   o f   { k e y , v a l u e }   p a i r s .   A   s i n g l e   { k e y , v a l u e }   i n   t h e   m a t c h L a b e l s   m a p   i s   e q u i v a l e n t   t o   a n   e l e m e n t   o f   m a t c h E x p r e s s i o n s ,   w h o s e   k e y   f i e l d   i s   " k e y " ,   t h e   o p e r a t o r   i s   " I n " ,   a n d   t h e   v a l u e s   a r r a y   c o n t a i n s   o n l y   " v a l u e " .   m a t c h E x p r e s s i o n s   i s   a   l i s t   o f   p o d   s e l e c t o r   r e q u i r e m e n t s .   V a l i d   o p e r a t o r s   i n c l u d e   I n ,   N o t I n ,   E x i s t s ,   a n d   D o e s N o t E x i s t .   T h e   v a l u e s   s e t   m u s t   b e   n o n - e m p t y   i n   t h e   c a s e   o f   I n   a n d   N o t I n .   A l l   o f   t h e   r e q u i r e m e n t s ,   f r o m   b o t h   m a t c h L a b e l s   a n d   m a t c h E x p r e s s i o n s   a r e   A N D e d   t o g e t h e r   - -   t h e y   m u s t   a l l   b e   s a t i s f i e d   i n   o r d e r   t o   m a t c h .


Question: What is Selecting sets of nodes?

Answer: O n e   u s e   c a s e   f o r   s e l e c t i n g   o v e r   l a b e l s   i s   t o   c o n s t r a i n   t h e   s e t   o f   n o d e s   o n t o   w h i c h   a   p o d   c a n   s c h e d u l e .   S e e   t h e   d o c u m e n t a t i o n   o n   n o d e   s e l e c t i o n   f o r   m o r e   i n f o r m a t i o n .


Question: What is Using labels effectively?

Answer: Y o u   c a n   a p p l y   a   s i n g l e   l a b e l   t o   a n y   r e s o u r c e s ,   b u t   t h i s   i s   n o t   a l w a y s   t h e   b e s t   p r a c t i c e .   T h e r e   a r e   m a n y   s c e n a r i o s   w h e r e   m u l t i p l e   l a b e l s   s h o u l d   b e   u s e d   t o   d i s t i n g u i s h   r e s o u r c e   s e t s   f r o m   o n e   a n o t h e r .   F o r   i n s t a n c e ,   d i f f e r e n t   a p p l i c a t i o n s   w o u l d   u s e   d i f f e r e n t   v a l u e s   f o r   t h e   a p p   l a b e l ,   b u t   a   m u l t i - t i e r   a p p l i c a t i o n ,   s u c h   a s   t h e   g u e s t b o o k   e x a m p l e ,   w o u l d   a d d i t i o n a l l y   n e e d   t o   d i s t i n g u i s h   e a c h   t i e r .   T h e   f r o n t e n d   c o u l d   c a r r y   t h e   f o l l o w i n g   l a b e l s :   l a b e l s :   a p p :   g u e s t b o o k   t i e r :   f r o n t e n d   w h i l e   t h e   R e d i s   m a s t e r   a n d   r e p l i c a   w o u l d   h a v e   d i f f e r e n t   t i e r   l a b e l s ,   a n d   p e r h a p s   e v e n   a n   a d d i t i o n a l   r o l e   l a b e l :   l a b e l s :   a p p :   g u e s t b o o k   t i e r :   b a c k e n d   r o l e :   m a s t e r   a n d   l a b e l s :   a p p :   g u e s t b o o k   t i e r :   b a c k e n d   r o l e :   r e p l i c a   T h e   l a b e l s   a l l o w   f o r   s l i c i n g   a n d   d i c i n g   t h e   r e s o u r c e s   a l o n g   a n y   d i m e n s i o n   s p e c i f i e d   b y   a   l a b e l :   k u b e c t l   a p p l y   - f   e x a m p l e s / g u e s t b o o k / a l l - i n - o n e / g u e s t b o o k - a l l - i n - o n e . y a m l   k u b e c t l   g e t   p o d s   - L a p p   - L t i e r   - L r o l e   N A M E   R E A D Y   S T A T U S   R E S T A R T S   A G E   A P P   T I E R   R O L E   g u e s t b o o k - f e - 4 n l p b   1 / 1   R u n n i n g   0   1 m   g u e s t b o o k   f r o n t e n d


Question: What is Updating labels?

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


Question: What is What's next?

Answer: L e a r n   h o w   t o   a d d   a   l a b e l   t o   a   n o d e F i n d   W e l l - k n o w n   l a b e l s ,   A n n o t a t i o n s   a n d   T a i n t s S e e   R e c o m m e n d e d   l a b e l s E n f o r c e   P o d   S e c u r i t y   S t a n d a r d s   w i t h   N a m e s p a c e   L a b e l s R e a d   a   b l o g   o n   W r i t i n g   a   C o n t r o l l e r   f o r   P o d   L a b e l s


Question: What is LabelSelector?

Answer: LabelSelectorA label selector is a label query over a set of resources.import "k8s.io/apimachinery/pkg/apis/meta/v1"A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.matchExpressions ([]LabelSelectorRequirement)Atomic: will be replaced during a mergematchExpressions is a list of label selector requirements. The requirements are ANDed.A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values.matchExpressions.key (string), requiredkey is the label key that the selector applies to.matchExpressions.operator (string), requiredoperator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist.matchExpressions.values ([]string)Atomic: will be replaced during a mergevalues is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.matchLabels (map[string]string)matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed.This page is automatically generated.If you plan to report an issue with this page, mention that the page is auto-generated in your issue description. The fix may need to happen elsewhere in the Kubernetes project.


Question: How does LabelSelector work?

Answer: LabelSelectorA label selector is a label query over a set of resources.import "k8s.io/apimachinery/pkg/apis/meta/v1"A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.matchExpressions ([]LabelSelectorRequirement)Atomic: will be replaced during a mergematchExpressions is a list of label selector requirements. The requirements are ANDed.A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values.matchExpressions.key (string), requiredkey is the label key that the selector applies to.matchExpressions.operator (string), requiredoperator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist.matchExpressions.values ([]string)Atomic: will be replaced during a mergevalues is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.matchLabels (map[string]string)matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed.This page is automatically generated.If you plan to report an issue with this page, mention that the page is auto-generated in your issue description. The fix may need to happen elsewhere in the Kubernetes project.


Question: When would you use LabelSelector?

Answer: LabelSelectorA label selector is a label query over a set of resources.import "k8s.io/apimachinery/pkg/apis/meta/v1"A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.matchExpressions ([]LabelSelectorRequirement)Atomic: will be replaced during a mergematchExpressions is a list of label selector requirements. The requirements are ANDed.A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values.matchExpressions.key (string), requiredkey is the label key that the selector applies to.matchExpressions.operator (string), requiredoperator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist.matchExpressions.values ([]string)Atomic: will be replaced during a mergevalues is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.matchLabels (map[string]string)matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed.This page is automatically generated.If you plan to report an issue with this page, mention that the page is auto-generated in your issue description. The fix may need to happen elsewhere in the Kubernetes project.


Question: What are the benefits of LabelSelector?

Answer: LabelSelectorA label selector is a label query over a set of resources.import "k8s.io/apimachinery/pkg/apis/meta/v1"A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.matchExpressions ([]LabelSelectorRequirement)Atomic: will be replaced during a mergematchExpressions is a list of label selector requirements. The requirements are ANDed.A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values.matchExpressions.key (string), requiredkey is the label key that the selector applies to.matchExpressions.operator (string), requiredoperator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist.matchExpressions.values ([]string)Atomic: will be replaced during a mergevalues is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.matchLabels (map[string]string)matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed.This page is automatically generated.If you plan to report an issue with this page, mention that the page is auto-generated in your issue description. The fix may need to happen elsewhere in the Kubernetes project.


Question: What is LabelSelector?

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


Question: What is Viewing Site Analytics?

Answer: Viewing Site AnalyticsThis page contains information about the kubernetes.io analytics dashboard.View the dashboard.This dashboard is built using Google Looker Studio and shows information collected on kubernetes.io using Google Analytics 4 since August 2022.Using the dashboardBy default, the dashboard shows all collected analytics for the past 30 days. Use the date selector to see data from a different date range. Other filtering options allow you to view data based on user location, the device used to access the site, the translation of the docs used, and more.If you notice an issue with this dashboard, or would like to request any improvements, please open an issue.


Question: How does Viewing Site Analytics work?

Answer: Viewing Site AnalyticsThis page contains information about the kubernetes.io analytics dashboard.View the dashboard.This dashboard is built using Google Looker Studio and shows information collected on kubernetes.io using Google Analytics 4 since August 2022.Using the dashboardBy default, the dashboard shows all collected analytics for the past 30 days. Use the date selector to see data from a different date range. Other filtering options allow you to view data based on user location, the device used to access the site, the translation of the docs used, and more.If you notice an issue with this dashboard, or would like to request any improvements, please open an issue.


Question: When would you use Viewing Site Analytics?

Answer: Viewing Site AnalyticsThis page contains information about the kubernetes.io analytics dashboard.View the dashboard.This dashboard is built using Google Looker Studio and shows information collected on kubernetes.io using Google Analytics 4 since August 2022.Using the dashboardBy default, the dashboard shows all collected analytics for the past 30 days. Use the date selector to see data from a different date range. Other filtering options allow you to view data based on user location, the device used to access the site, the translation of the docs used, and more.If you notice an issue with this dashboard, or would like to request any improvements, please open an issue.


Question: What are the benefits of Viewing Site Analytics?

Answer: Viewing Site AnalyticsThis page contains information about the kubernetes.io analytics dashboard.View the dashboard.This dashboard is built using Google Looker Studio and shows information collected on kubernetes.io using Google Analytics 4 since August 2022.Using the dashboardBy default, the dashboard shows all collected analytics for the past 30 days. Use the date selector to see data from a different date range. Other filtering options allow you to view data based on user location, the device used to access the site, the translation of the docs used, and more.If you notice an issue with this dashboard, or would like to request any improvements, please open an issue.


Question: What is Viewing Site Analytics?

Answer: T h i s   p a g e   c o n t a i n s   i n f o r m a t i o n   a b o u t   t h e   k u b e r n e t e s . i o   a n a l y t i c s   d a s h b o a r d .   V i e w   t h e   d a s h b o a r d .   T h i s   d a s h b o a r d   i s   b u i l t   u s i n g   G o o g l e   L o o k e r   S t u d i o   a n d   s h o w s   i n f o r m a t i o n   c o l l e c t e d   o n   k u b e r n e t e s . i o   u s i n g   G o o g l e   A n a l y t i c s   4   s i n c e   A u g u s t   2 0 2 2 .


Question: What is Using the dashboard?

Answer: B y   d e f a u l t ,   t h e   d a s h b o a r d   s h o w s   a l l   c o l l e c t e d   a n a l y t i c s   f o r   t h e   p a s t   3 0   d a y s .   U s e   t h e   d a t e   s e l e c t o r   t o   s e e   d a t a   f r o m   a   d i f f e r e n t   d a t e   r a n g e .   O t h e r   f i l t e r i n g   o p t i o n s   a l l o w   y o u   t o   v i e w   d a t a   b a s e d   o n   u s e r   l o c a t i o n ,   t h e   d e v i c e   u s e d   t o   a c c e s s   t h e   s i t e ,   t h e   t r a n s l a t i o n   o f   t h e   d o c s   u s e d ,   a n d   m o r e .   I f   y o u   n o t i c e   a n   i s s u e   w i t h   t h i s   d a s h b o a r d ,   o r   w o u l d   l i k e   t o   r e q u e s t   a n y   i m p r o v e m e n t s ,   p l e a s e   o p e n   a n   i s s u e .


Question: What is Configure Quotas for API Objects?

Answer: Configure Quotas for API ObjectsThis page shows how to configure quotas for API objects, including PersistentVolumeClaims and Services. A quota restricts the number of objects, of a particular type, that can be created in a namespace. You specify quotas in a ResourceQuota object.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.Create a namespaceCreate a namespace so that the resources you create in this exercise are isolated from the rest of your cluster.kubectl create namespace quota-object-example Create a ResourceQuotaHere is the configuration file for a ResourceQuota object:admin/resource/quota-objects.yaml apiVersion: v1 kind: ResourceQuota metadata: name: object-quota-demo spec: hard: persistentvolumeclaims: "1" services.loadbalancers: "2" services.nodeports: "0" Create the ResourceQuota:kubectl apply -f https://k8s.io/examples/admin/resource/quota-objects.yaml --namespace=quota-object-example View detailed information about the ResourceQuota:kubectl get resourcequota object-quota-demo --namespace=quota-object-example --output=yaml The output shows that in the quota-object-example namespace, there can be at most one PersistentVolumeClaim, at most two Services of type LoadBalancer, and no Services of type NodePort.status: hard: persistentvolumeclaims: "1" services.loadbalancers: "2" services.nodeports: "0" used: persistentvolumeclaims: "0" services.loadbalancers: "0" services.nodeports: "0" Create a PersistentVolumeClaimHere is the configuration file for a PersistentVolumeClaim object:admin/resource/quota-objects-pvc.yaml apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pvc-quota-demo spec: storageClassName: manual accessModes: - ReadWriteOnce resources: requests: storage: 3Gi Create the PersistentVolumeClaim:kubectl apply -f https://k8s.io/examples/admin/resource/quota-objects-pvc.yaml --namespace=quota-object-example Verify that the PersistentVolumeClaim was created:kubectl get persistentvolumeclaims --namespace=quota-object-example The output shows that the PersistentVolumeClaim exists and has status Pending:NAME STATUS pvc-quota-demo Pending Attempt to create a second PersistentVolumeClaimHere is the configuration file for a second PersistentVolumeClaim:admin/resource/quota-objects-pvc-2.yaml apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pvc-quota-demo-2 spec: storageClassName: manual accessModes: - ReadWriteOnce resources: requests: storage: 4Gi Attempt to create the second PersistentVolumeClaim:kubectl apply -f https://k8s.io/examples/admin/resource/quota-objects-pvc-2.yaml --namespace=q


Question: How does Configure Quotas for API Objects work?

Answer: Configure Quotas for API ObjectsThis page shows how to configure quotas for API objects, including PersistentVolumeClaims and Services. A quota restricts the number of objects, of a particular type, that can be created in a namespace. You specify quotas in a ResourceQuota object.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.Create a namespaceCreate a namespace so that the resources you create in this exercise are isolated from the rest of your cluster.kubectl create namespace quota-object-example Create a ResourceQuotaHere is the configuration file for a ResourceQuota object:admin/resource/quota-objects.yaml apiVersion: v1 kind: ResourceQuota metadata: name: object-quota-demo spec: hard: persistentvolumeclaims: "1" services.loadbalancers: "2" services.nodeports: "0" Create the ResourceQuota:kubectl apply -f https://k8s.io/examples/admin/resource/quota-objects.yaml --namespace=quota-object-example View detailed information about the ResourceQuota:kubectl get resourcequota object-quota-demo --namespace=quota-object-example --output=yaml The output shows that in the quota-object-example namespace, there can be at most one PersistentVolumeClaim, at most two Services of type LoadBalancer, and no Services of type NodePort.status: hard: persistentvolumeclaims: "1" services.loadbalancers: "2" services.nodeports: "0" used: persistentvolumeclaims: "0" services.loadbalancers: "0" services.nodeports: "0" Create a PersistentVolumeClaimHere is the configuration file for a PersistentVolumeClaim object:admin/resource/quota-objects-pvc.yaml apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pvc-quota-demo spec: storageClassName: manual accessModes: - ReadWriteOnce resources: requests: storage: 3Gi Create the PersistentVolumeClaim:kubectl apply -f https://k8s.io/examples/admin/resource/quota-objects-pvc.yaml --namespace=quota-object-example Verify that the PersistentVolumeClaim was created:kubectl get persistentvolumeclaims --namespace=quota-object-example The output shows that the PersistentVolumeClaim exists and has status Pending:NAME STATUS pvc-quota-demo Pending Attempt to create a second PersistentVolumeClaimHere is the configuration file for a second PersistentVolumeClaim:admin/resource/quota-objects-pvc-2.yaml apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pvc-quota-demo-2 spec: storageClassName: manual accessModes: - ReadWriteOnce resources: requests: storage: 4Gi Attempt to create the second PersistentVolumeClaim:kubectl apply -f https://k8s.io/examples/admin/resource/quota-objects-pvc-2.yaml --namespace=q


Question: When would you use Configure Quotas for API Objects?

Answer: Configure Quotas for API ObjectsThis page shows how to configure quotas for API objects, including PersistentVolumeClaims and Services. A quota restricts the number of objects, of a particular type, that can be created in a namespace. You specify quotas in a ResourceQuota object.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.Create a namespaceCreate a namespace so that the resources you create in this exercise are isolated from the rest of your cluster.kubectl create namespace quota-object-example Create a ResourceQuotaHere is the configuration file for a ResourceQuota object:admin/resource/quota-objects.yaml apiVersion: v1 kind: ResourceQuota metadata: name: object-quota-demo spec: hard: persistentvolumeclaims: "1" services.loadbalancers: "2" services.nodeports: "0" Create the ResourceQuota:kubectl apply -f https://k8s.io/examples/admin/resource/quota-objects.yaml --namespace=quota-object-example View detailed information about the ResourceQuota:kubectl get resourcequota object-quota-demo --namespace=quota-object-example --output=yaml The output shows that in the quota-object-example namespace, there can be at most one PersistentVolumeClaim, at most two Services of type LoadBalancer, and no Services of type NodePort.status: hard: persistentvolumeclaims: "1" services.loadbalancers: "2" services.nodeports: "0" used: persistentvolumeclaims: "0" services.loadbalancers: "0" services.nodeports: "0" Create a PersistentVolumeClaimHere is the configuration file for a PersistentVolumeClaim object:admin/resource/quota-objects-pvc.yaml apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pvc-quota-demo spec: storageClassName: manual accessModes: - ReadWriteOnce resources: requests: storage: 3Gi Create the PersistentVolumeClaim:kubectl apply -f https://k8s.io/examples/admin/resource/quota-objects-pvc.yaml --namespace=quota-object-example Verify that the PersistentVolumeClaim was created:kubectl get persistentvolumeclaims --namespace=quota-object-example The output shows that the PersistentVolumeClaim exists and has status Pending:NAME STATUS pvc-quota-demo Pending Attempt to create a second PersistentVolumeClaimHere is the configuration file for a second PersistentVolumeClaim:admin/resource/quota-objects-pvc-2.yaml apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pvc-quota-demo-2 spec: storageClassName: manual accessModes: - ReadWriteOnce resources: requests: storage: 4Gi Attempt to create the second PersistentVolumeClaim:kubectl apply -f https://k8s.io/examples/admin/resource/quota-objects-pvc-2.yaml --namespace=q


Question: What are the benefits of Configure Quotas for API Objects?

Answer: Configure Quotas for API ObjectsThis page shows how to configure quotas for API objects, including PersistentVolumeClaims and Services. A quota restricts the number of objects, of a particular type, that can be created in a namespace. You specify quotas in a ResourceQuota object.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.Create a namespaceCreate a namespace so that the resources you create in this exercise are isolated from the rest of your cluster.kubectl create namespace quota-object-example Create a ResourceQuotaHere is the configuration file for a ResourceQuota object:admin/resource/quota-objects.yaml apiVersion: v1 kind: ResourceQuota metadata: name: object-quota-demo spec: hard: persistentvolumeclaims: "1" services.loadbalancers: "2" services.nodeports: "0" Create the ResourceQuota:kubectl apply -f https://k8s.io/examples/admin/resource/quota-objects.yaml --namespace=quota-object-example View detailed information about the ResourceQuota:kubectl get resourcequota object-quota-demo --namespace=quota-object-example --output=yaml The output shows that in the quota-object-example namespace, there can be at most one PersistentVolumeClaim, at most two Services of type LoadBalancer, and no Services of type NodePort.status: hard: persistentvolumeclaims: "1" services.loadbalancers: "2" services.nodeports: "0" used: persistentvolumeclaims: "0" services.loadbalancers: "0" services.nodeports: "0" Create a PersistentVolumeClaimHere is the configuration file for a PersistentVolumeClaim object:admin/resource/quota-objects-pvc.yaml apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pvc-quota-demo spec: storageClassName: manual accessModes: - ReadWriteOnce resources: requests: storage: 3Gi Create the PersistentVolumeClaim:kubectl apply -f https://k8s.io/examples/admin/resource/quota-objects-pvc.yaml --namespace=quota-object-example Verify that the PersistentVolumeClaim was created:kubectl get persistentvolumeclaims --namespace=quota-object-example The output shows that the PersistentVolumeClaim exists and has status Pending:NAME STATUS pvc-quota-demo Pending Attempt to create a second PersistentVolumeClaimHere is the configuration file for a second PersistentVolumeClaim:admin/resource/quota-objects-pvc-2.yaml apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pvc-quota-demo-2 spec: storageClassName: manual accessModes: - ReadWriteOnce resources: requests: storage: 4Gi Attempt to create the second PersistentVolumeClaim:kubectl apply -f https://k8s.io/examples/admin/resource/quota-objects-pvc-2.yaml --namespace=q


Question: What is Configure Quotas for API Objects?

Answer: T h i s   p a g e   s h o w s   h o w   t o   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 ,   i n c l u d i n g   P e r s i s t e n t V o l u m e C l a i m s   a n d   S e r v i c e s .   A   q u o t a   r e s t r i c t s   t h e   n u m b e r   o f   o b j e c t s ,   o f   a   p a r t i c u l a r   t y p e ,   t h a t   c a n   b e   c r e a t e d   i n   a   n a m e s p a c e .   Y o u   s p e c i f y   q u o t a s   i n   a   R e s o u r c e Q u o t a   o b j e c 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 .


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   q u o t a - o b j e c t - e x a m p l e


Question: What is Create a ResourceQuota?

Answer: 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   R e s o u r c e Q u o t a   o b j e c t :   a p i V e r s i o n :   v 1   k i n d :   R e s o u r c e Q u o t a   m e t a d a t a :   n a m e :   o b j e c t - q u o t a - d e m o   s p e c :   h a r d :   p e r s i s t e n t v o l u m e c l a i m s :   " 1 "   s e r v i c e s . l o a d b a l a n c e r s :   " 2 "   s e r v i c e s . n o d e p o r t s :   " 0 "   C r e a t e   t h e   R e s o u r c e Q u o t a :   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 d m i n / r e s o u r c e / q u o t a - o b j e c t s . y a m l   - - n a m e s p a c e = q u o t a - o b j e c t - e x a m p l e   V i e w   d e t a i l e d   i n f o r m a t i o n   a b o u t   t h e   R e s o u r c e Q u o t a :   k u b e c t l   g e t   r e s o u r c e q u o t a   o b j e c t - q u o t a - d e m o   - - n a m e s p a c e = q u o t a - o b j e c t - e x a m p l e   - - o u t p u t = y a m l   T h e   o u t p u t   s h o w s   t h a t   i n   t h e   q u o t a - o b j e c t - e x a m p l e   n a m e s p a c e ,   t h e r e   c a n   b e   a t   m o s t   o n e   P e r s i s t e n t V o l u m e C l a i m ,   a t   m o s t   t w o   S e r v i c e s   o f   t y p e   L o a d B a l a n c e r ,   a n d   n o   S e r v i c e s   o f   t y p e   N o d e P o r t .   s t a t u s :   h a r d :   p e r s i s t e n t v o l u m e c l a i m s :   " 1 "   s e r v i c e s . l o a d b a l a n c e r s :   " 2 "   s e r v i c e s . n o d e p o r t s :   " 0 "   u s e d :   p e r s i s t e n t v o l u m e c l a i m s :   " 0 "   s e r v i c e s . l o a d b a l a n c e r s :   " 0 "   s e r v i c e s . n o d e p o r t s :   " 0 "


Question: What is Create a PersistentVolumeClaim?

Answer: 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 e r s i s t e n t V o l u m e C l a i m   o b j e c t :   a p i V e r s i o n :   v 1   k i n d :   P e r s i s t e n t V o l u m e C l a i m   m e t a d a t a :   n a m e :   p v c - q u o t a - d e m o   s p e c :   s t o r a g e C l a s s N a m e :   m a n u a l   a c c e s s M o d e s :   -   R e a d W r i t e O n c e   r e s o u r c e s :   r e q u e s t s :   s t o r a g e :   3 G i   C r e a t e   t h e   P e r s i s t e n t V o l u m e C l a i m :   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 d m i n / r e s o u r c e / q u o t a - o b j e c t s - p v c . y a m l   - - n a m e s p a c e = q u o t a - o b j e c t - e x a m p l e   V e r i f y   t h a t   t h e   P e r s i s t e n t V o l u m e C l a i m   w a s   c r e a t e d :   k u b e c t l   g e t   p e r s i s t e n t v o l u m e c l a i m s   - - n a m e s p a c e = q u o t a - o b j e c t - e x a m p l e   T h e   o u t p u t   s h o w s   t h a t   t h e   P e r s i s t e n t V o l u m e C l a i m   e x i s t s   a n d   h a s   s t a t u s   P e n d i n g :   N A M E   S T A T U S   p v c - q u o t a - d e m o   P e n d i n g


Question: What is Attempt to create a second PersistentVolumeClaim?

Answer: 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   s e c o n d   P e r s i s t e n t V o l u m e C l a i m :   a p i V e r s i o n :   v 1   k i n d :   P e r s i s t e n t V o l u m e C l a i m   m e t a d a t a :   n a m e :   p v c - q u o t a - d e m o - 2   s p e c :   s t o r a g e C l a s s N a m e :   m a n u a l   a c c e s s M o d e s :   -   R e a d W r i t e O n c e   r e s o u r c e s :   r e q u e s t s :   s t o r a g e :   4 G i   A t t e m p t   t o   c r e a t e   t h e   s e c o n d   P e r s i s t e n t V o l u m e C l a i m :   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 d m i n / r e s o u r c e / q u o t a - o b j e c t s - p v c - 2 . y a m l   - - n a m e s p a c e = q u o t a - o b j e c t - e x a m p l e   T h e   o u t p u t   s h o w s   t h a t   t h e   s e c o n d   P e r s i s t e n t V o l u m e C l a i m   w a s   n o t   c r e a t e d ,   b e c a u s e   i t   w o u l d   h a v e   e x c e e d e d   t h e   q u o t a   f o r   t h e   n a m e s p a c e .   p e r s i s t e n t v o l u m e c l a i m s   " p v c - q u o t a - d e m o - 2 "   i s   f o r b i d d e n :   e x c e e d e d   q u o t a :   o b j e c t - q u o t a - d e m o ,   r e q u e s t e d :   p e r s i s t e n t v o l u m e c l a i m s = 1 ,   u s e d :   p e r s i s t e n t v o l u m e c l a i m s = 1 ,   l i m i t e d :   p e r s i s t e n t v o l u m e c l a i m s = 1


Question: What is Notes?

Answer: T h e s e   a r e   t h e   s t r i n g s   u s e d   t o   i d e n t i f y   A P I   r e s o u r c e s   t h a t   c a n   b e   c o n s t r a i n e d   b y   q u o t a s :


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 :   k u b e c t l   d e l e t e   n a m e s p a c e   q u o t a - o b j e c t - e x a m p l e


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   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


Question: What is For app developers?

Answer: 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 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   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   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


Question: What is Debug Services?

Answer: Debug ServicesAn issue that comes up rather frequently for new installations of Kubernetes is that a Service is not working properly. You've run your Pods through a Deployment (or other workload controller) and created a Service, but you get no response when you try to access it. This document will hopefully help you to figure out what's going wrong.Running commands in a PodFor many steps here you will want to see what a Pod running in the cluster sees. The simplest way to do this is to run an interactive busybox Pod:kubectl run -it --rm --restart=Never busybox --image=gcr.io/google-containers/busybox sh Note:If you don't see a command prompt, try pressing enter.If you already have a running Pod that you prefer to use, you can run a command in it using:kubectl exec <POD-NAME> -c <CONTAINER-NAME> -- <COMMAND> SetupFor the purposes of this walk-through, let's run some Pods. Since you're probably debugging your own Service you can substitute your own details, or you can follow along and get a second data point.kubectl create deployment hostnames --image=registry.k8s.io/serve_hostname deployment.apps/hostnames created kubectl commands will print the type and name of the resource created or mutated, which can then be used in subsequent commands.Let's scale the deployment to 3 replicas.kubectl scale deployment hostnames --replicas=3 deployment.apps/hostnames scaled Note that this is the same as if you had started the Deployment with the following YAML:apiVersion: apps/v1 kind: Deployment metadata: labels: app: hostnames name: hostnames spec: selector: matchLabels: app: hostnames replicas: 3 template: metadata: labels: app: hostnames spec: containers: - name: hostnames image: registry.k8s.io/serve_hostname The label "app" is automatically set by kubectl create deployment to the name of the Deployment.You can confirm your Pods are running:kubectl get pods -l app=hostnames NAME READY STATUS RESTARTS AGE hostnames-632524106-bbpiw 1/1 Running 0 2m hostnames-632524106-ly40y 1/1 Running 0 2m hostnames-632524106-tlaok 1/1 Running 0 2m You can also confirm that your Pods are serving. You can get the list of Pod IP addresses and test them directly.kubectl get pods -l app=hostnames \ -o go-template='{{range .items}}{{.status.podIP}}{{"\n"}}{{end}}' 10.244.0.5 10.244.0.6 10.244.0.7 The example container used for this walk-through serves its own hostname via HTTP on port 9376, but if you are debugging your own app, you'll want to use whatever port number your Pods are listening on.From within a pod:for ep in 10.244.0.5:9376 10.244.0.6:9376 10.244.0.7:9376; do wget -qO- $ep done This should produce something like:hostnames-632524106-bbpiw hostnames-632524106-ly40y hostnames-632524106-tlaok If you are not getting the responses you expect at this point, your Pods might not be healthy or might not be listening on the port you think they are. You might find kubectl logs to be useful for seeing what is happening, or perhaps you need to kubectl exec directly into your Pod


Question: How does Debug Services work?

Answer: Debug ServicesAn issue that comes up rather frequently for new installations of Kubernetes is that a Service is not working properly. You've run your Pods through a Deployment (or other workload controller) and created a Service, but you get no response when you try to access it. This document will hopefully help you to figure out what's going wrong.Running commands in a PodFor many steps here you will want to see what a Pod running in the cluster sees. The simplest way to do this is to run an interactive busybox Pod:kubectl run -it --rm --restart=Never busybox --image=gcr.io/google-containers/busybox sh Note:If you don't see a command prompt, try pressing enter.If you already have a running Pod that you prefer to use, you can run a command in it using:kubectl exec <POD-NAME> -c <CONTAINER-NAME> -- <COMMAND> SetupFor the purposes of this walk-through, let's run some Pods. Since you're probably debugging your own Service you can substitute your own details, or you can follow along and get a second data point.kubectl create deployment hostnames --image=registry.k8s.io/serve_hostname deployment.apps/hostnames created kubectl commands will print the type and name of the resource created or mutated, which can then be used in subsequent commands.Let's scale the deployment to 3 replicas.kubectl scale deployment hostnames --replicas=3 deployment.apps/hostnames scaled Note that this is the same as if you had started the Deployment with the following YAML:apiVersion: apps/v1 kind: Deployment metadata: labels: app: hostnames name: hostnames spec: selector: matchLabels: app: hostnames replicas: 3 template: metadata: labels: app: hostnames spec: containers: - name: hostnames image: registry.k8s.io/serve_hostname The label "app" is automatically set by kubectl create deployment to the name of the Deployment.You can confirm your Pods are running:kubectl get pods -l app=hostnames NAME READY STATUS RESTARTS AGE hostnames-632524106-bbpiw 1/1 Running 0 2m hostnames-632524106-ly40y 1/1 Running 0 2m hostnames-632524106-tlaok 1/1 Running 0 2m You can also confirm that your Pods are serving. You can get the list of Pod IP addresses and test them directly.kubectl get pods -l app=hostnames \ -o go-template='{{range .items}}{{.status.podIP}}{{"\n"}}{{end}}' 10.244.0.5 10.244.0.6 10.244.0.7 The example container used for this walk-through serves its own hostname via HTTP on port 9376, but if you are debugging your own app, you'll want to use whatever port number your Pods are listening on.From within a pod:for ep in 10.244.0.5:9376 10.244.0.6:9376 10.244.0.7:9376; do wget -qO- $ep done This should produce something like:hostnames-632524106-bbpiw hostnames-632524106-ly40y hostnames-632524106-tlaok If you are not getting the responses you expect at this point, your Pods might not be healthy or might not be listening on the port you think they are. You might find kubectl logs to be useful for seeing what is happening, or perhaps you need to kubectl exec directly into your Pod


Question: When would you use Debug Services?

Answer: Debug ServicesAn issue that comes up rather frequently for new installations of Kubernetes is that a Service is not working properly. You've run your Pods through a Deployment (or other workload controller) and created a Service, but you get no response when you try to access it. This document will hopefully help you to figure out what's going wrong.Running commands in a PodFor many steps here you will want to see what a Pod running in the cluster sees. The simplest way to do this is to run an interactive busybox Pod:kubectl run -it --rm --restart=Never busybox --image=gcr.io/google-containers/busybox sh Note:If you don't see a command prompt, try pressing enter.If you already have a running Pod that you prefer to use, you can run a command in it using:kubectl exec <POD-NAME> -c <CONTAINER-NAME> -- <COMMAND> SetupFor the purposes of this walk-through, let's run some Pods. Since you're probably debugging your own Service you can substitute your own details, or you can follow along and get a second data point.kubectl create deployment hostnames --image=registry.k8s.io/serve_hostname deployment.apps/hostnames created kubectl commands will print the type and name of the resource created or mutated, which can then be used in subsequent commands.Let's scale the deployment to 3 replicas.kubectl scale deployment hostnames --replicas=3 deployment.apps/hostnames scaled Note that this is the same as if you had started the Deployment with the following YAML:apiVersion: apps/v1 kind: Deployment metadata: labels: app: hostnames name: hostnames spec: selector: matchLabels: app: hostnames replicas: 3 template: metadata: labels: app: hostnames spec: containers: - name: hostnames image: registry.k8s.io/serve_hostname The label "app" is automatically set by kubectl create deployment to the name of the Deployment.You can confirm your Pods are running:kubectl get pods -l app=hostnames NAME READY STATUS RESTARTS AGE hostnames-632524106-bbpiw 1/1 Running 0 2m hostnames-632524106-ly40y 1/1 Running 0 2m hostnames-632524106-tlaok 1/1 Running 0 2m You can also confirm that your Pods are serving. You can get the list of Pod IP addresses and test them directly.kubectl get pods -l app=hostnames \ -o go-template='{{range .items}}{{.status.podIP}}{{"\n"}}{{end}}' 10.244.0.5 10.244.0.6 10.244.0.7 The example container used for this walk-through serves its own hostname via HTTP on port 9376, but if you are debugging your own app, you'll want to use whatever port number your Pods are listening on.From within a pod:for ep in 10.244.0.5:9376 10.244.0.6:9376 10.244.0.7:9376; do wget -qO- $ep done This should produce something like:hostnames-632524106-bbpiw hostnames-632524106-ly40y hostnames-632524106-tlaok If you are not getting the responses you expect at this point, your Pods might not be healthy or might not be listening on the port you think they are. You might find kubectl logs to be useful for seeing what is happening, or perhaps you need to kubectl exec directly into your Pod


Question: What are the benefits of Debug Services?

Answer: Debug ServicesAn issue that comes up rather frequently for new installations of Kubernetes is that a Service is not working properly. You've run your Pods through a Deployment (or other workload controller) and created a Service, but you get no response when you try to access it. This document will hopefully help you to figure out what's going wrong.Running commands in a PodFor many steps here you will want to see what a Pod running in the cluster sees. The simplest way to do this is to run an interactive busybox Pod:kubectl run -it --rm --restart=Never busybox --image=gcr.io/google-containers/busybox sh Note:If you don't see a command prompt, try pressing enter.If you already have a running Pod that you prefer to use, you can run a command in it using:kubectl exec <POD-NAME> -c <CONTAINER-NAME> -- <COMMAND> SetupFor the purposes of this walk-through, let's run some Pods. Since you're probably debugging your own Service you can substitute your own details, or you can follow along and get a second data point.kubectl create deployment hostnames --image=registry.k8s.io/serve_hostname deployment.apps/hostnames created kubectl commands will print the type and name of the resource created or mutated, which can then be used in subsequent commands.Let's scale the deployment to 3 replicas.kubectl scale deployment hostnames --replicas=3 deployment.apps/hostnames scaled Note that this is the same as if you had started the Deployment with the following YAML:apiVersion: apps/v1 kind: Deployment metadata: labels: app: hostnames name: hostnames spec: selector: matchLabels: app: hostnames replicas: 3 template: metadata: labels: app: hostnames spec: containers: - name: hostnames image: registry.k8s.io/serve_hostname The label "app" is automatically set by kubectl create deployment to the name of the Deployment.You can confirm your Pods are running:kubectl get pods -l app=hostnames NAME READY STATUS RESTARTS AGE hostnames-632524106-bbpiw 1/1 Running 0 2m hostnames-632524106-ly40y 1/1 Running 0 2m hostnames-632524106-tlaok 1/1 Running 0 2m You can also confirm that your Pods are serving. You can get the list of Pod IP addresses and test them directly.kubectl get pods -l app=hostnames \ -o go-template='{{range .items}}{{.status.podIP}}{{"\n"}}{{end}}' 10.244.0.5 10.244.0.6 10.244.0.7 The example container used for this walk-through serves its own hostname via HTTP on port 9376, but if you are debugging your own app, you'll want to use whatever port number your Pods are listening on.From within a pod:for ep in 10.244.0.5:9376 10.244.0.6:9376 10.244.0.7:9376; do wget -qO- $ep done This should produce something like:hostnames-632524106-bbpiw hostnames-632524106-ly40y hostnames-632524106-tlaok If you are not getting the responses you expect at this point, your Pods might not be healthy or might not be listening on the port you think they are. You might find kubectl logs to be useful for seeing what is happening, or perhaps you need to kubectl exec directly into your Pod


Question: What is Debug Services?

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


Question: What is Running commands in a Pod?

Answer: F o r   m a n y   s t e p s   h e r e   y o u   w i l l   w a n t   t o   s e e   w h a t   a   P o d   r u n n i n g   i n   t h e   c l u s t e r   s e e s .   T h e   s i m p l e s t   w a y   t o   d o   t h i s   i s   t o   r u n   a n   i n t e r a c t i v e   b u s y b o x   P o d :   k u b e c t l   r u n   - i t   - - r m   - - r e s t a r t = N e v e r   b u s y b o x   - - i m a g e = g c r . i o / g o o g l e - c o n t a i n e r s / b u s y b o x   s h


Question: What is Note:?

Answer: I f   y o u   a l r e a d y   h a v e   a   r u n n i n g   P o d   t h a t   y o u   p r e f e r   t o   u s e ,   y o u   c a n   r u n   a   c o m m a n d   i n   i t   u s i n g :   k u b e c t l   e x e c   < P O D - N A M E >   - c   < C O N T A I N E R - N A M E >   - -   < C O M M A N D >


Question: What is Setup?

Answer: F o r   t h e   p u r p o s e s   o f   t h i s   w a l k - t h r o u g h ,   l e t ' s   r u n   s o m e   P o d s .   S i n c e   y o u ' r e   p r o b a b l y   d e b u g g i n g   y o u r   o w n   S e r v i c e   y o u   c a n   s u b s t i t u t e   y o u r   o w n   d e t a i l s ,   o r   y o u   c a n   f o l l o w   a l o n g   a n d   g e t   a   s e c o n d   d a t a   p o i n t .   k u b e c t l   c r e a t e   d e p l o y m e n t   h o s t n a m e s   - - i m a g e = r e g i s t r y . k 8 s . i o / s e r v e _ h o s t n a m e   d e p l o y m e n t . a p p s / h o s t n a m e s   c r e a t e d   k u b e c t l   c o m m a n d s   w i l l   p r i n t   t h e   t y p e   a n d   n a m e   o f   t h e   r e s o u r c e   c r e a t e d   o r   m u t a t e d ,   w h i c h   c a n   t h e n   b e   u s e d   i n   s u b s e q u e n t   c o m m a n d s .   L e t ' s   s c a l e   t h e   d e p l o y m e n t   t o   3   r e p l i c a s .   k u b e c t l   s c a l e   d e p l o y m e n t   h o s t n a m e s   - - r e p l i c a s = 3   d e p l o y m e n t . a p p s / h o s t n a m e s   s c a l e d   N o t e   t h a t   t h i s   i s   t h e   s a m e   a s   i f   y o u   h a d   s t a r t e d   t h e   D e p l o y m e n t   w i t h   t h e   f o l l o w i n g   Y A M L :   a p i V e r s i o n :   a p p s / v 1   k i n d :   D e p l o y m e n t   m e t a d a t a :   l a b e l s :   a p p :   h o s t n a m e s   n a m e :   h o s t n a m e s   s p e c :   s e l e c t o r :   m a t c h L a b e l s :   a p p :   h o s t n a m e s   r e p l i c a s :   3   t e m p l a t e :   m e t a d a t a :   l a b e l s :   a p p :   h o s t n a m e s   s p e c :   c o n t a i n e r s :   -   n a m e :   h o s t n a m e s   i m a g e :   r e g i s t r y . k 8 s . i o / s e r v e _ h o s t n a m e   T h e   l a b e l   " a p p "   i s   a u t o m a t i c a l l y   s e t   b y   k u b e c t l   c r e a t e   d e p l o y m e n t   t o   t h e   n a m e   o f   t h e   D e p l o y m


Question: What is Does the Service exist??

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


Question: What is Any Network Policy Ingress rules affecting the target Pods??

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


Question: What is Does the Service work by DNS name??

Answer: O n e   o f   t h e   m o s t   c o m m o n   w a y s   t h a t   c l i e n t s   c o n s u m e   a   S e r v i c e   i s   t h r o u g h   a   D N S   n a m e .   F r o m   a   P o d   i n   t h e   s a m e   N a m e s p a c e :   n s l o o k u p   h o s t n a m e s   A d d r e s s   1 :   1 0 . 0 . 0 . 1 0   k u b e - d n s . k u b e - s y s t e m . s v c . c l u s t e r . l o c a l   N a m e :   h o s t n a m e s   A d d r e s s   1 :   1 0 . 0 . 1 . 1 7 5   h o s t n a m e s . d e f a u l t . s v c . c l u s t e r . l o c a l   I f   t h i s   f a i l s ,   p e r h a p s   y o u r   P o d   a n d   S e r v i c e   a r e   i n   d i f f e r e n t   N a m e s p a c e s ,   t r y   a   n a m e s p a c e - q u a l i f i e d   n a m e   ( a g a i n ,   f r o m   w i t h i n   a   P o d ) :   n s l o o k u p   h o s t n a m e s . d e f a u l t   A d d r e s s   1 :   1 0 . 0 . 0 . 1 0   k u b e - d n s . k u b e - s y s t e m . s v c . c l u s t e r . l o c a l   N a m e :   h o s t n a m e s . d e f a u l t   A d d r e s s   1 :   1 0 . 0 . 1 . 1 7 5   h o s t n a m e s . d e f a u l t . s v c . c l u s t e r . l o c a l   I f   t h i s   w o r k s ,   y o u ' l l   n e e d   t o   a d j u s t   y o u r   a p p   t o   u s e   a   c r o s s - n a m e s p a c e   n a m e ,   o r   r u n   y o u r   a p p   a n d   S e r v i c e   i n   t h e   s a m e   N a m e s p a c e .   I f   t h i s   s t i l l   f a i l s ,   t r y   a   f u l l y - q u a l i f i e d   n a m e :   n s l o o k u p   h o s t n a m e s . d e f a u l t . s v c . c l u s t e r . l o c a l   A d d r e s s   1 :   1 0 . 0 . 0 . 1 0   k u b e - d n s . k u b e - s y s t e m . s v c . c l u s t e r . l o c a l   N a m e :   h o s t n a m e s . d e f a u l t . s v c . c l u s t e r . l o c a l   A d d r e s s   1 :   1 0 . 0 . 1 . 1 7 5   h o s t n a m e s . d e f a u l t . s v c . c l u s t e r . l o c a l   N o t e   t h e   s u f f i x   h e r e :   " d e f a u l t . s v c . c l u s t e r . l o c a l


Question: What is Note:?

Answer: n s l o o k u p   h o s t n a m e s . d e f a u l t . s v c . c l u s t e r . l o c a l   1 0 . 0 . 0 . 1 0   S e r v e r :   1 0 . 0 . 0 . 1 0   A d d r e s s :   1 0 . 0 . 0 . 1 0 # 5 3   N a m e :   h o s t n a m e s . d e f a u l t . s v c . c l u s t e r . l o c a l   A d d r e s s :   1 0 . 0 . 1 . 1 7 5   I f   y o u   a r e   a b l e   t o   d o   a   f u l l y - q u a l i f i e d   n a m e   l o o k u p   b u t   n o t   a   r e l a t i v e   o n e ,   y o u   n e e d   t o   c h e c k   t h a t   y o u r   / e t c / r e s o l v . c o n f   f i l e   i n   y o u r   P o d   i s   c o r r e c t .   F r o m   w i t h i n   a   P o d :   c a t   / e t c / r e s o l v . c o n f   Y o u   s h o u l d   s e e   s o m e t h i n g   l i k e :   n a m e s e r v e r   1 0 . 0 . 0 . 1 0   s e a r c h   d e f a u l t . s v c . c l u s t e r . l o c a l   s v c . c l u s t e r . l o c a l   c l u s t e r . l o c a l   e x a m p l e . c o m   o p t i o n s   n d o t s : 5   T h e   n a m e s e r v e r   l i n e   m u s t   i n d i c a t e   y o u r   c l u s t e r ' s   D N S   S e r v i c e .   T h i s   i s   p a s s e d   i n t o   k u b e l e t   w i t h   t h e   - - c l u s t e r - d n s   f l a g .   T h e   s e a r c h   l i n e   m u s t   i n c l u d e   a n   a p p r o p r i a t e   s u f f i x   f o r   y o u   t o   f i n d   t h e   S e r v i c e   n a m e .   I n   t h i s   c a s e   i t   i s   l o o k i n g   f o r   S e r v i c e s   i n   t h e   l o c a l   N a m e s p a c e   ( " d e f a u l t . s v c . c l u s t e r . l o c a l " ) ,   S e r v i c e s   i n   a l l   N a m e s p a c e s   ( " s v c . c l u s t e r . l o c a l " ) ,   a n d   l a s t l y   f o r   n a m e s   i n   t h e   c l u s t e r   ( " c l u s t e r . l o c a l " ) .   D e p e n d i n g   o n   y o u r   o w n   i n s t a l l   y o u   m i g h t   h a v e   a d d i t i o n a l   r e c o r d s   a f t e r   t h a t   ( u p   t o   6   t o t a l ) .   T h e   c l u s t e r   s


Question: What is Does any Service work by DNS name??

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


Question: What is Does the Service work by IP??

Answer: A s s u m i n g   y o u   h a v e   c o n f i r m e d   t h a t   D N S   w o r k s ,   t h e   n e x t   t h i n g   t o   t e s t   i s   w h e t h e r   y o u r   S e r v i c e   w o r k s   b y   i t s   I P   a d d r e s s .   F r o m   a   P o d   i n   y o u r   c l u s t e r ,   a c c e s s   t h e   S e r v i c e ' s   I P   ( f r o m   k u b e c t l   g e t   a b o v e ) .   f o r   i   i n   $ ( s e q   1   3 ) ;   d o   w g e t   - q O -   1 0 . 0 . 1 . 1 7 5 : 8 0   d o n e   T h i s   s h o u l d   p r o d u c e   s o m e t h i n g   l i k e :   h o s t n a m e s - 6 3 2 5 2 4 1 0 6 - b b p i w   h o s t n a m e s - 6 3 2 5 2 4 1 0 6 - l y 4 0 y   h o s t n a m e s - 6 3 2 5 2 4 1 0 6 - t l a o k   I f   y o u r   S e r v i c e   i s   w o r k i n g ,   y o u   s h o u l d   g e t   c o r r e c t   r e s p o n s e s .   I f   n o t ,   t h e r e   a r e   a   n u m b e r   o f   t h i n g s   t h a t   c o u l d   b e   g o i n g   w r o n g .   R e a d   o n .


Question: What is Is the Service defined correctly??

Answer: I t   m i g h t   s o u n d   s i l l y ,   b u t   y o u   s h o u l d   r e a l l y   d o u b l e   a n d   t r i p l e   c h e c k   t h a t   y o u r   S e r v i c e   i s   c o r r e c t   a n d   m a t c h e s   y o u r   P o d ' s   p o r t .   R e a d   b a c k   y o u r   S e r v i c e   a n d   v e r i f y   i t :   k u b e c t l   g e t   s e r v i c e   h o s t n a m e s   - o   j s o n   {   " k i n d " :   " S e r v i c e " ,   " a p i V e r s i o n " :   " v 1 " ,   " m e t a d a t a " :   {   " n a m e " :   " h o s t n a m e s " ,   " n a m e s p a c e " :   " d e f a u l t " ,   " u i d " :   " 4 2 8 c 8 b 6 c - 2 4 b c - 1 1 e 5 - 9 3 6 d - 4 2 0 1 0 a f 0 a 9 b c " ,   " r e s o u r c e V e r s i o n " :   " 3 4 7 1 8 9 " ,   " c r e a t i o n T i m e s t a m p " :   " 2 0 1 5 - 0 7 - 0 7 T 1 5 : 2 4 : 2 9 Z " ,   " l a b e l s " :   {   " a p p " :   " h o s t n a m e s "   }   } ,   " s p e c " :   {   " p o r t s " :   [   {   " n a m e " :   " d e f a u l t " ,   " p r o t o c o l " :   " T C P " ,   " p o r t " :   8 0 ,   " t a r g e t P o r t " :   9 3 7 6 ,   " n o d e P o r t " :   0   }   ] ,   " s e l e c t o r " :   {   " a p p " :   " h o s t n a m e s "   } ,   " c l u s t e r I P " :   " 1 0 . 0 . 1 . 1 7 5 " ,   " t y p e " :   " C l u s t e r I P " ,   " s e s s i o n A f f i n i t y " :   " N o n e "   } ,   " s t a t u s " :   {   " l o a d B a l a n c e r " :   { }   }   }   I s   t h e   S e r v i c e   p o r t   y o u   a r e   t r y i n g   t o   a c c e s s   l i s t e d   i n   s p e c . p o r t s [ ] ? I s   t h e   t a r g e t P o r t   c o r r e c t   f o r   y o u r   P o d s   ( s o m e   P o d s   u s e   a   d i f f e r e n t   p o r t   t h a n   t h e   S e r v i c e ) ? I f   y o u   m e a n t   t o   u s e   a   n u m e r i c   p o r t ,   i s   i t   a   n u m b e r   ( 9 3 7 6 )   o r   a   s t r i n g   " 9 3 7 6 " ? I f   y o u   m e a n t   t o   u s e   a   n a m e d   p o r t ,   d o   y o u r   P o d s


Question: What is Does the Service have any EndpointSlices??

Answer: I f   y o u   g o t   t h i s   f a r ,   y o u   h a v e   c o n f i r m e d   t h a t   y o u r   S e r v i c e   i s   c o r r e c t l y   d e f i n e d   a n d   i s   r e s o l v e d   b y   D N S .   N o w   l e t ' s   c h e c k   t h a t   t h e   P o d s   y o u   r a n   a r e   a c t u a l l y   b e i n g   s e l e c t e d   b y   t h e   S e r v i c e .   E a r l i e r   y o u   s a w   t h a t   t h e   P o d s   w e r e   r u n n i n g .   Y o u   c a n   r e - c h e c k   t h a t :   k u b e c t l   g e t   p o d s   - l   a p p = h o s t n a m e s   N A M E   R E A D Y   S T A T U S   R E S T A R T S   A G E   h o s t n a m e s - 6 3 2 5 2 4 1 0 6 - b b p i w   1 / 1   R u n n i n g   0   1 h   h o s t n a m e s - 6 3 2 5 2 4 1 0 6 - l y 4 0 y   1 / 1   R u n n i n g   0   1 h   h o s t n a m e s - 6 3 2 5 2 4 1 0 6 - t l a o k   1 / 1   R u n n i n g   0   1 h   T h e   - l   a p p = h o s t n a m e s   a r g u m e n t   i s   a   l a b e l   s e l e c t o r   c o n f i g u r e d   o n   t h e   S e r v i c e .   T h e   " A G E "   c o l u m n   s a y s   t h a t   t h e s e   P o d s   a r e   a b o u t   a n   h o u r   o l d ,   w h i c h   i m p l i e s   t h a t   t h e y   a r e   r u n n i n g   f i n e   a n d   n o t   c r a s h i n g .   T h e   " R E S T A R T S "   c o l u m n   s a y s   t h a t   t h e s e   p o d s   a r e   n o t   c r a s h i n g   f r e q u e n t l y   o r   b e i n g   r e s t a r t e d .   F r e q u e n t   r e s t a r t s   c o u l d   l e a d   t o   i n t e r m i t t e n t   c o n n e c t i v i t y   i s s u e s .   I f   t h e   r e s t a r t   c o u n t   i s   h i g h ,   r e a d   m o r e   a b o u t   h o w   t o   d e b u g   p o d s .   I n s i d e   t h e   K u b e r n e t e s   s y s t e m   i s   a   c o n t r o l   l o o p   w h i c h   e v a l u a t e s   t h e   s e l e c t o r   o f   e v e r y   S e r v i c e   a n d   s a v e s   t h e   r e s u l t s   i n t o   o n e   o r   m o r e   E n d


Question: What is Are the Pods working??

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


Question: What is Note:?

Answer: F r o m   w i t h i n   a   P o d :   f o r   e p   i n   1 0 . 2 4 4 . 0 . 5 : 9 3 7 6   1 0 . 2 4 4 . 0 . 6 : 9 3 7 6   1 0 . 2 4 4 . 0 . 7 : 9 3 7 6 ;   d o   w g e t   - q O -   $ e p   d o n e   T h i s   s h o u l d   p r o d u c e   s o m e t h i n g   l i k e :   h o s t n a m e s - 6 3 2 5 2 4 1 0 6 - b b p i w   h o s t n a m e s - 6 3 2 5 2 4 1 0 6 - l y 4 0 y   h o s t n a m e s - 6 3 2 5 2 4 1 0 6 - t l a o k   Y o u   e x p e c t   e a c h   P o d   i n   t h e   e n d p o i n t s   l i s t   t o   r e t u r n   i t s   o w n   h o s t n a m e .   I f   t h i s   i s   n o t   w h a t   h a p p e n s   ( o r   w h a t e v e r   t h e   c o r r e c t   b e h a v i o r   i s   f o r   y o u r   o w n   P o d s ) ,   y o u   s h o u l d   i n v e s t i g a t e   w h a t ' s   h a p p e n i n g   t h e r e .


Question: What is Is the kube-proxy working??

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


Question: What is Is kube-proxy running??

Answer: C o n f i r m   t h a t   k u b e - p r o x y   i s   r u n n i n g   o n   y o u r   N o d e s .   R u n n i n g   d i r e c t l y   o n   a   N o d e ,   y o u   s h o u l d   g e t   s o m e t h i n g   l i k e   t h e   b e l o w :   p s   a u x w   |   g r e p   k u b e - p r o x y   r o o t   4 1 9 4   0 . 4   0 . 1   1 0 1 8 6 4   1 7 6 9 6   ?   S l   J u l 0 4   2 5 : 4 3   / u s r / l o c a l / b i n / k u b e - p r o x y   - - m a s t e r = h t t p s : / / k u b e r n e t e s - m a s t e r   - - k u b e c o n f i g = / v a r / l i b / k u b e - p r o x y / k u b e c o n f i g   - - v = 2   N e x t ,   c o n f i r m   t h a t   i t   i s   n o t   f a i l i n g   s o m e t h i n g   o b v i o u s ,   l i k e   c o n t a c t i n g   t h e   m a s t e r .   T o   d o   t h i s ,   y o u ' l l   h a v e   t o   l o o k   a t   t h e   l o g s .   A c c e s s i n g   t h e   l o g s   d e p e n d s   o n   y o u r   N o d e   O S .   O n   s o m e   O S e s   i t   i s   a   f i l e ,   s u c h   a s   / v a r / l o g / k u b e - p r o x y . l o g ,   w h i l e   o t h e r   O S e s   u s e   j o u r n a l c t l   t o   a c c e s s   l o g s .   Y o u   s h o u l d   s e e   s o m e t h i n g   l i k e :   I 1 0 2 7   2 2 : 1 4 : 5 3 . 9 9 5 1 3 4   5 0 6 3   s e r v e r . g o : 2 0 0 ]   R u n n i n g   i n   r e s o u r c e - o n l y   c o n t a i n e r   " / k u b e - p r o x y "   I 1 0 2 7   2 2 : 1 4 : 5 3 . 9 9 8 1 6 3   5 0 6 3   s e r v e r . g o : 2 4 7 ]   U s i n g   i p t a b l e s   P r o x i e r .   I 1 0 2 7   2 2 : 1 4 : 5 4 . 0 3 8 1 4 0   5 0 6 3   p r o x i e r . g o : 3 5 2 ]   S e t t i n g   e n d p o i n t s   f o r   " k u b e - s y s t e m / k u b e - d n s : d n s - t c p "   t o   [ 1 0 . 2 4 4 . 1 . 3 : 5 3 ]   I 1 0 2 7   2 2 : 1 4 : 5 4 . 0 3 8 1 6 4   5 0 6 3   p r o x i e r . g o : 3 5 2 ]   S e t t i n g   e n d p o i n t s   f o r   " k u b e - s y s t e m / k u b e - d n s : d n s "   t o   [ 1 0 . 2 4 4 . 1 . 3 : 5 3 ]   I


Question: What is Iptables mode?

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


Question: What is IPVS mode?

Answer: I n   " i p v s "   m o d e ,   y o u   s h o u l d   s e e   s o m e t h i n g   l i k e   t h e   f o l l o w i n g   o n   a   N o d e :   i p v s a d m   - l n   P r o t   L o c a l A d d r e s s : P o r t   S c h e d u l e r   F l a g s   - >   R e m o t e A d d r e s s : P o r t   F o r w a r d   W e i g h t   A c t i v e C o n n   I n A c t C o n n   . . .   T C P   1 0 . 0 . 1 . 1 7 5 : 8 0   r r   - >   1 0 . 2 4 4 . 0 . 5 : 9 3 7 6   M a s q   1   0   0   - >   1 0 . 2 4 4 . 0 . 6 : 9 3 7 6   M a s q   1   0   0   - >   1 0 . 2 4 4 . 0 . 7 : 9 3 7 6   M a s q   1   0   0   . . .   F o r   e a c h   p o r t   o f   e a c h   S e r v i c e ,   p l u s   a n y   N o d e P o r t s ,   e x t e r n a l   I P s ,   a n d   l o a d - b a l a n c e r   I P s ,   k u b e - p r o x y   w i l l   c r e a t e   a   v i r t u a l   s e r v e r .   F o r   e a c h   P o d   e n d p o i n t ,   i t   w i l l   c r e a t e   c o r r e s p o n d i n g   r e a l   s e r v e r s .   I n   t h i s   e x a m p l e ,   s e r v i c e   h o s t n a m e s ( 1 0 . 0 . 1 . 1 7 5 : 8 0 )   h a s   3   e n d p o i n t s ( 1 0 . 2 4 4 . 0 . 5 : 9 3 7 6 ,   1 0 . 2 4 4 . 0 . 6 : 9 3 7 6 ,   1 0 . 2 4 4 . 0 . 7 : 9 3 7 6 ) .


Question: What is Is kube-proxy proxying??

Answer: A s s u m i n g   y o u   d o   s e e   o n e   t h e   a b o v e   c a s e s ,   t r y   a g a i n   t o   a c c e s s   y o u r   S e r v i c e   b y   I P   f r o m   o n e   o f   y o u r   N o d e s :   c u r l   1 0 . 0 . 1 . 1 7 5 : 8 0   h o s t n a m e s - 6 3 2 5 2 4 1 0 6 - b b p i w   I f   t h i s   s t i l l   f a i l s ,   l o o k   a t   t h e   k u b e - p r o x y   l o g s   f o r   s p e c i f i c   l i n e s   l i k e :   S e t t i n g   e n d p o i n t s   f o r   d e f a u l t / h o s t n a m e s : d e f a u l t   t o   [ 1 0 . 2 4 4 . 0 . 5 : 9 3 7 6   1 0 . 2 4 4 . 0 . 6 : 9 3 7 6   1 0 . 2 4 4 . 0 . 7 : 9 3 7 6 ]   I f   y o u   d o n ' t   s e e   t h o s e ,   t r y   r e s t a r t i n g   k u b e - p r o x y   w i t h   t h e   - v   f l a g   s e t   t o   4 ,   a n d   t h e n   l o o k   a t   t h e   l o g s   a g a i n .


Question: What is Edge case: A Pod fails to reach itself via the Service IP?

Answer: T h i s   m i g h t   s o u n d   u n l i k e l y ,   b u t   i t   d o e s   h a p p e n   a n d   i t   i s   s u p p o s e d   t o   w o r k .   T h i s   c a n   h a p p e n   w h e n   t h e   n e t w o r k   i s   n o t   p r o p e r l y   c o n f i g u r e d   f o r   " h a i r p i n "   t r a f f i c ,   u s u a l l y   w h e n   k u b e - p r o x y   i s   r u n n i n g   i n   i p t a b l e s   m o d e   a n d   P o d s   a r e   c o n n e c t e d   w i t h   b r i d g e   n e t w o r k .   T h e   K u b e l e t   e x p o s e s   a   h a i r p i n - m o d e   f l a g   t h a t   a l l o w s   e n d p o i n t s   o f   a   S e r v i c e   t o   l o a d b a l a n c e   b a c k   t o   t h e m s e l v e s   i f   t h e y   t r y   t o   a c c e s s   t h e i r   o w n   S e r v i c e   V I P .   T h e   h a i r p i n - m o d e   f l a g   m u s t   e i t h e r   b e   s e t   t o   h a i r p i n - v e t h   o r   p r o m i s c u o u s - b r i d g e .   T h e   c o m m o n   s t e p s   t o   t r o u b l e   s h o o t   t h i s   a r e   a s   f o l l o w s :   C o n f i r m   h a i r p i n - m o d e   i s   s e t   t o   h a i r p i n - v e t h   o r   p r o m i s c u o u s - b r i d g e .   Y o u   s h o u l d   s e e   s o m e t h i n g   l i k e   t h e   b e l o w .   h a i r p i n - m o d e   i s   s e t   t o   p r o m i s c u o u s - b r i d g e   i n   t h e   f o l l o w i n g   e x a m p l e .   p s   a u x w   |   g r e p   k u b e l e t   r o o t   3 3 9 2   1 . 1   0 . 8   1 8 6 8 0 4   6 5 2 0 8   ?   S l   0 0 : 5 1   1 1 : 1 1   / u s r / l o c a l / b i n / k u b e l e t   - - e n a b l e - d e b u g g i n g - h a n d l e r s = t r u e   - - c o n f i g = / e t c / k u b e r n e t e s / m a n i f e s t s   - - a l l o w - p r i v i l e g e d = T r u e   - - v = 4   - - c l u s t e r - d n s = 1 0 . 0 . 0 . 1 0   - - c l u s t e r - d o m a i n = c l u s t e r . l o c a l   - - c o n f i g u r e - c b r 0 = t r u e   - - c g r o u p - r o o t