Question: What is ReplicaSet?

Answer: ReplicaSetA ReplicaSet's purpose is to maintain a stable set of replica Pods running at any given time. Usually, you define a Deployment and let that Deployment manage ReplicaSets automatically.A ReplicaSet's purpose is to maintain a stable set of replica Pods running at any given time. As such, it is often used to guarantee the availability of a specified number of identical Pods.How a ReplicaSet worksA ReplicaSet is defined with fields, including a selector that specifies how to identify Pods it can acquire, a number of replicas indicating how many Pods it should be maintaining, and a pod template specifying the data of new Pods it should create to meet the number of replicas criteria. A ReplicaSet then fulfills its purpose by creating and deleting Pods as needed to reach the desired number. When a ReplicaSet needs to create new Pods, it uses its Pod template.A ReplicaSet is linked to its Pods via the Pods' metadata.ownerReferences field, which specifies what resource the current object is owned by. All Pods acquired by a ReplicaSet have their owning ReplicaSet's identifying information within their ownerReferences field. It's through this link that the ReplicaSet knows of the state of the Pods it is maintaining and plans accordingly.A ReplicaSet identifies new Pods to acquire by using its selector. If there is a Pod that has no OwnerReference or the OwnerReference is not a Controller and it matches a ReplicaSet's selector, it will be immediately acquired by said ReplicaSet.When to use a ReplicaSetA ReplicaSet ensures that a specified number of pod replicas are running at any given time. However, a Deployment is a higher-level concept that manages ReplicaSets and provides declarative updates to Pods along with a lot of other useful features. Therefore, we recommend using Deployments instead of directly using ReplicaSets, unless you require custom update orchestration or don't require updates at all.This actually means that you may never need to manipulate ReplicaSet objects: use a Deployment instead, and define your application in the spec section.Examplecontrollers/frontend.yaml apiVersion: apps/v1 kind: ReplicaSet metadata: name: frontend labels: app: guestbook tier: frontend spec: # modify replicas according to your case replicas: 3 selector: matchLabels: tier: frontend template: metadata: labels: tier: frontend spec: containers: - name: php-redis image: us-docker.pkg.dev/google-samples/containers/gke/gb-frontend:v5 Saving this manifest into frontend.yaml and submitting it to a Kubernetes cluster will create the defined ReplicaSet and the Pods that it manages.kubectl apply -f https://kubernetes.io/examples/controllers/frontend.yaml You can then get the current ReplicaSets deployed:kubectl get rs And see the frontend one you created:NAME DESIRED CURRENT READY AGE frontend 3 3 3 6s You can also check on the state of the ReplicaSet:kubectl describe rs/frontend And you will see output similar to:Name: frontend Namespace: default Selector: tier=f


Question: How does ReplicaSet work?

Answer: ReplicaSetA ReplicaSet's purpose is to maintain a stable set of replica Pods running at any given time. Usually, you define a Deployment and let that Deployment manage ReplicaSets automatically.A ReplicaSet's purpose is to maintain a stable set of replica Pods running at any given time. As such, it is often used to guarantee the availability of a specified number of identical Pods.How a ReplicaSet worksA ReplicaSet is defined with fields, including a selector that specifies how to identify Pods it can acquire, a number of replicas indicating how many Pods it should be maintaining, and a pod template specifying the data of new Pods it should create to meet the number of replicas criteria. A ReplicaSet then fulfills its purpose by creating and deleting Pods as needed to reach the desired number. When a ReplicaSet needs to create new Pods, it uses its Pod template.A ReplicaSet is linked to its Pods via the Pods' metadata.ownerReferences field, which specifies what resource the current object is owned by. All Pods acquired by a ReplicaSet have their owning ReplicaSet's identifying information within their ownerReferences field. It's through this link that the ReplicaSet knows of the state of the Pods it is maintaining and plans accordingly.A ReplicaSet identifies new Pods to acquire by using its selector. If there is a Pod that has no OwnerReference or the OwnerReference is not a Controller and it matches a ReplicaSet's selector, it will be immediately acquired by said ReplicaSet.When to use a ReplicaSetA ReplicaSet ensures that a specified number of pod replicas are running at any given time. However, a Deployment is a higher-level concept that manages ReplicaSets and provides declarative updates to Pods along with a lot of other useful features. Therefore, we recommend using Deployments instead of directly using ReplicaSets, unless you require custom update orchestration or don't require updates at all.This actually means that you may never need to manipulate ReplicaSet objects: use a Deployment instead, and define your application in the spec section.Examplecontrollers/frontend.yaml apiVersion: apps/v1 kind: ReplicaSet metadata: name: frontend labels: app: guestbook tier: frontend spec: # modify replicas according to your case replicas: 3 selector: matchLabels: tier: frontend template: metadata: labels: tier: frontend spec: containers: - name: php-redis image: us-docker.pkg.dev/google-samples/containers/gke/gb-frontend:v5 Saving this manifest into frontend.yaml and submitting it to a Kubernetes cluster will create the defined ReplicaSet and the Pods that it manages.kubectl apply -f https://kubernetes.io/examples/controllers/frontend.yaml You can then get the current ReplicaSets deployed:kubectl get rs And see the frontend one you created:NAME DESIRED CURRENT READY AGE frontend 3 3 3 6s You can also check on the state of the ReplicaSet:kubectl describe rs/frontend And you will see output similar to:Name: frontend Namespace: default Selector: tier=f


Question: When would you use ReplicaSet?

Answer: ReplicaSetA ReplicaSet's purpose is to maintain a stable set of replica Pods running at any given time. Usually, you define a Deployment and let that Deployment manage ReplicaSets automatically.A ReplicaSet's purpose is to maintain a stable set of replica Pods running at any given time. As such, it is often used to guarantee the availability of a specified number of identical Pods.How a ReplicaSet worksA ReplicaSet is defined with fields, including a selector that specifies how to identify Pods it can acquire, a number of replicas indicating how many Pods it should be maintaining, and a pod template specifying the data of new Pods it should create to meet the number of replicas criteria. A ReplicaSet then fulfills its purpose by creating and deleting Pods as needed to reach the desired number. When a ReplicaSet needs to create new Pods, it uses its Pod template.A ReplicaSet is linked to its Pods via the Pods' metadata.ownerReferences field, which specifies what resource the current object is owned by. All Pods acquired by a ReplicaSet have their owning ReplicaSet's identifying information within their ownerReferences field. It's through this link that the ReplicaSet knows of the state of the Pods it is maintaining and plans accordingly.A ReplicaSet identifies new Pods to acquire by using its selector. If there is a Pod that has no OwnerReference or the OwnerReference is not a Controller and it matches a ReplicaSet's selector, it will be immediately acquired by said ReplicaSet.When to use a ReplicaSetA ReplicaSet ensures that a specified number of pod replicas are running at any given time. However, a Deployment is a higher-level concept that manages ReplicaSets and provides declarative updates to Pods along with a lot of other useful features. Therefore, we recommend using Deployments instead of directly using ReplicaSets, unless you require custom update orchestration or don't require updates at all.This actually means that you may never need to manipulate ReplicaSet objects: use a Deployment instead, and define your application in the spec section.Examplecontrollers/frontend.yaml apiVersion: apps/v1 kind: ReplicaSet metadata: name: frontend labels: app: guestbook tier: frontend spec: # modify replicas according to your case replicas: 3 selector: matchLabels: tier: frontend template: metadata: labels: tier: frontend spec: containers: - name: php-redis image: us-docker.pkg.dev/google-samples/containers/gke/gb-frontend:v5 Saving this manifest into frontend.yaml and submitting it to a Kubernetes cluster will create the defined ReplicaSet and the Pods that it manages.kubectl apply -f https://kubernetes.io/examples/controllers/frontend.yaml You can then get the current ReplicaSets deployed:kubectl get rs And see the frontend one you created:NAME DESIRED CURRENT READY AGE frontend 3 3 3 6s You can also check on the state of the ReplicaSet:kubectl describe rs/frontend And you will see output similar to:Name: frontend Namespace: default Selector: tier=f


Question: What are the benefits of ReplicaSet?

Answer: ReplicaSetA ReplicaSet's purpose is to maintain a stable set of replica Pods running at any given time. Usually, you define a Deployment and let that Deployment manage ReplicaSets automatically.A ReplicaSet's purpose is to maintain a stable set of replica Pods running at any given time. As such, it is often used to guarantee the availability of a specified number of identical Pods.How a ReplicaSet worksA ReplicaSet is defined with fields, including a selector that specifies how to identify Pods it can acquire, a number of replicas indicating how many Pods it should be maintaining, and a pod template specifying the data of new Pods it should create to meet the number of replicas criteria. A ReplicaSet then fulfills its purpose by creating and deleting Pods as needed to reach the desired number. When a ReplicaSet needs to create new Pods, it uses its Pod template.A ReplicaSet is linked to its Pods via the Pods' metadata.ownerReferences field, which specifies what resource the current object is owned by. All Pods acquired by a ReplicaSet have their owning ReplicaSet's identifying information within their ownerReferences field. It's through this link that the ReplicaSet knows of the state of the Pods it is maintaining and plans accordingly.A ReplicaSet identifies new Pods to acquire by using its selector. If there is a Pod that has no OwnerReference or the OwnerReference is not a Controller and it matches a ReplicaSet's selector, it will be immediately acquired by said ReplicaSet.When to use a ReplicaSetA ReplicaSet ensures that a specified number of pod replicas are running at any given time. However, a Deployment is a higher-level concept that manages ReplicaSets and provides declarative updates to Pods along with a lot of other useful features. Therefore, we recommend using Deployments instead of directly using ReplicaSets, unless you require custom update orchestration or don't require updates at all.This actually means that you may never need to manipulate ReplicaSet objects: use a Deployment instead, and define your application in the spec section.Examplecontrollers/frontend.yaml apiVersion: apps/v1 kind: ReplicaSet metadata: name: frontend labels: app: guestbook tier: frontend spec: # modify replicas according to your case replicas: 3 selector: matchLabels: tier: frontend template: metadata: labels: tier: frontend spec: containers: - name: php-redis image: us-docker.pkg.dev/google-samples/containers/gke/gb-frontend:v5 Saving this manifest into frontend.yaml and submitting it to a Kubernetes cluster will create the defined ReplicaSet and the Pods that it manages.kubectl apply -f https://kubernetes.io/examples/controllers/frontend.yaml You can then get the current ReplicaSets deployed:kubectl get rs And see the frontend one you created:NAME DESIRED CURRENT READY AGE frontend 3 3 3 6s You can also check on the state of the ReplicaSet:kubectl describe rs/frontend And you will see output similar to:Name: frontend Namespace: default Selector: tier=f


Question: What is ReplicaSet?

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


Question: What is How a ReplicaSet works?

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


Question: What is When to use a ReplicaSet?

Answer: A   R e p l i c a S e t   e n s u r e s   t h a t   a   s p e c i f i e d   n u m b e r   o f   p o d   r e p l i c a s   a r e   r u n n i n g   a t   a n y   g i v e n   t i m e .   H o w e v e r ,   a   D e p l o y m e n t   i s   a   h i g h e r - l e v e l   c o n c e p t   t h a t   m a n a g e s   R e p l i c a S e t s   a n d   p r o v i d e s   d e c l a r a t i v e   u p d a t e s   t o   P o d s   a l o n g   w i t h   a   l o t   o f   o t h e r   u s e f u l   f e a t u r e s .   T h e r e f o r e ,   w e   r e c o m m e n d   u s i n g   D e p l o y m e n t s   i n s t e a d   o f   d i r e c t l y   u s i n g   R e p l i c a S e t s ,   u n l e s s   y o u   r e q u i r e   c u s t o m   u p d a t e   o r c h e s t r a t i o n   o r   d o n ' t   r e q u i r e   u p d a t e s   a t   a l l .   T h i s   a c t u a l l y   m e a n s   t h a t   y o u   m a y   n e v e r   n e e d   t o   m a n i p u l a t e   R e p l i c a S e t   o b j e c t s :   u s e   a   D e p l o y m e n t   i n s t e a d ,   a n d   d e f i n e   y o u r   a p p l i c a t i o n   i n   t h e   s p e c   s e c t i o n .


Question: What is Example?

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


Question: What is Non-Template Pod acquisitions?

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


Question: What is Writing a ReplicaSet manifest?

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


Question: What is Pod Template?

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


Question: What is Pod Selector?

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


Question: What is Replicas?

Answer: Y o u   c a n   s p e c i f y   h o w   m a n y   P o d s   s h o u l d   r u n   c o n c u r r e n t l y   b y   s e t t i n g   . s p e c . r e p l i c a s .   T h e   R e p l i c a S e t   w i l l   c r e a t e / d e l e t e   i t s   P o d s   t o   m a t c h   t h i s   n u m b e r .   I f   y o u   d o   n o t   s p e c i f y   . s p e c . r e p l i c a s ,   t h e n   i t   d e f a u l t s   t o   1 .


Question: What is Deleting a ReplicaSet and its Pods?

Answer: T o   d e l e t e   a   R e p l i c a S e t   a n d   a l l   o f   i t s   P o d s ,   u s e   k u b e c t l   d e l e t e .   T h e   G a r b a g e   c o l l e c t o r   a u t o m a t i c a l l y   d e l e t e s   a l l   o f   t h e   d e p e n d e n t   P o d s   b y   d e f a u l t .   W h e n   u s i n g   t h e   R E S T   A P I   o r   t h e   c l i e n t - g o   l i b r a r y ,   y o u   m u s t   s e t   p r o p a g a t i o n P o l i c y   t o   B a c k g r o u n d   o r   F o r e g r o u n d   i n   t h e   - d   o p t i o n .   F o r   e x a m p l e :   k u b e c t l   p r o x y   - - p o r t = 8 0 8 0   c u r l   - X   D E L E T E   ' l o c a l h o s t : 8 0 8 0 / a p i s / a p p s / v 1 / n a m e s p a c e s / d e f a u l t / r e p l i c a s e t s / f r o n t e n d '   \   - d   ' { " k i n d " : " D e l e t e O p t i o n s " , " a p i V e r s i o n " : " v 1 " , " p r o p a g a t i o n P o l i c y " : " F o r e g r o u n d " } '   \   - H   " C o n t e n t - T y p e :   a p p l i c a t i o n / j s o n "


Question: What is Deleting just a ReplicaSet?

Answer: Y o u   c a n   d e l e t e   a   R e p l i c a S e t   w i t h o u t   a f f e c t i n g   a n y   o f   i t s   P o d s   u s i n g   k u b e c t l   d e l e t e   w i t h   t h e   - - c a s c a d e = o r p h a n   o p t i o n .   W h e n   u s i n g   t h e   R E S T   A P I   o r   t h e   c l i e n t - g o   l i b r a r y ,   y o u   m u s t   s e t   p r o p a g a t i o n P o l i c y   t o   O r p h a n .   F o r   e x a m p l e :   k u b e c t l   p r o x y   - - p o r t = 8 0 8 0   c u r l   - X   D E L E T E   ' l o c a l h o s t : 8 0 8 0 / a p i s / a p p s / v 1 / n a m e s p a c e s / d e f a u l t / r e p l i c a s e t s / f r o n t e n d '   \   - d   ' { " k i n d " : " D e l e t e O p t i o n s " , " a p i V e r s i o n " : " v 1 " , " p r o p a g a t i o n P o l i c y " : " O r p h a n " } '   \   - H   " C o n t e n t - T y p e :   a p p l i c a t i o n / j s o n "   O n c e   t h e   o r i g i n a l   i s   d e l e t e d ,   y o u   c a n   c r e a t e   a   n e w   R e p l i c a S e t   t o   r e p l a c e   i t .   A s   l o n g   a s   t h e   o l d   a n d   n e w   . s p e c . s e l e c t o r   a r e   t h e   s a m e ,   t h e n   t h e   n e w   o n e   w i l l   a d o p t   t h e   o l d   P o d s .   H o w e v e r ,   i t   w i l l   n o t   m a k e   a n y   e f f o r t   t o   m a k e   e x i s t i n g   P o d s   m a t c h   a   n e w ,   d i f f e r e n t   p o d   t e m p l a t e .   T o   u p d a t e   P o d s   t o   a   n e w   s p e c   i n   a   c o n t r o l l e d   w a y ,   u s e   a   D e p l o y m e n t ,   a s   R e p l i c a S e t s   d o   n o t   s u p p o r t   a   r o l l i n g   u p d a t e   d i r e c t l y .


Question: What is Terminating Pods?

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


Question: What is Isolating Pods from a ReplicaSet?

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


Question: What is Scaling a ReplicaSet?

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


Question: What is Pod deletion cost?

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


Question: What is Note:?

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


Question: What is Example Use Case?

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


Question: What is ReplicaSet as a Horizontal Pod Autoscaler Target?

Answer: A   R e p l i c a S e t   c a n   a l s o   b e   a   t a r g e t   f o r   H o r i z o n t a l   P o d   A u t o s c a l e r s   ( H P A ) .   T h a t   i s ,   a   R e p l i c a S e t   c a n   b e   a u t o - s c a l e d   b y   a n   H P A .   H e r e   i s   a n   e x a m p l e   H P A   t a r g e t i n g   t h e   R e p l i c a S e t   w e   c r e a t e d   i n   t h e   p r e v i o u s   e x a m p l e .   a p i V e r s i o n :   a u t o s c a l i n g / v 1   k i n d :   H o r i z o n t a l P o d A u t o s c a l e r   m e t a d a t a :   n a m e :   f r o n t e n d - s c a l e r   s p e c :   s c a l e T a r g e t R e f :   k i n d :   R e p l i c a S e t   n a m e :   f r o n t e n d   m i n R e p l i c a s :   3   m a x R e p l i c a s :   1 0   t a r g e t C P U U t i l i z a t i o n P e r c e n t a g e :   5 0   S a v i n g   t h i s   m a n i f e s t   i n t o   h p a - r s . y a m l   a n d   s u b m i t t i n g   i t   t o   a   K u b e r n e t e s   c l u s t e r   s h o u l d   c r e a t e   t h e   d e f i n e d   H P A   t h a t   a u t o s c a l e s   t h e   t a r g e t   R e p l i c a S e t   d e p e n d i n g   o n   t h e   C P U   u s a g e   o f   t h e   r e p l i c a t e d   P o d s .   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 / c o n t r o l l e r s / h p a - r s . y a m l   A l t e r n a t i v e l y ,   y o u   c a n   u s e   t h e   k u b e c t l   a u t o s c a l e   c o m m a n d   t o   a c c o m p l i s h   t h e   s a m e   ( a n d   i t ' s   e a s i e r ! )   k u b e c t l   a u t o s c a l e   r s   f r o n t e n d   - - m a x = 1 0   - - m i n = 3   - - c p u - p e r c e n t = 5 0


Question: What is Deployment (recommended)?

Answer: D e p l o y m e n t   i s   a n   o b j e c t   w h i c h   c a n   o w n   R e p l i c a S e t s   a n d   u p d a t e   t h e m   a n d   t h e i r   P o d s   v i a   d e c l a r a t i v e ,   s e r v e r - s i d e   r o l l i n g   u p d a t e s .   W h i l e   R e p l i c a S e t s   c a n   b e   u s e d   i n d e p e n d e n t l y ,   t o d a y   t h e y ' r e   m a i n l y   u s e d   b y   D e p l o y m e n t s   a s   a   m e c h a n i s m   t o   o r c h e s t r a t e   P o d   c r e a t i o n ,   d e l e t i o n   a n d   u p d a t e s .   W h e n   y o u   u s e   D e p l o y m e n t s   y o u   d o n ' t   h a v e   t o   w o r r y   a b o u t   m a n a g i n g   t h e   R e p l i c a S e t s   t h a t   t h e y   c r e a t e .   D e p l o y m e n t s   o w n   a n d   m a n a g e   t h e i r   R e p l i c a S e t s .   A s   s u c h ,   i t   i s   r e c o m m e n d e d   t o   u s e   D e p l o y m e n t s   w h e n   y o u   w a n t   R e p l i c a S e t s .


Question: What is Bare Pods?

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


Question: What is Job?

Answer: U s e   a   J o b   i n s t e a d   o f   a   R e p l i c a S e t   f o r   P o d s   t h a t   a r e   e x p e c t e d   t o   t e r m i n a t e   o n   t h e i r   o w n   ( t h a t   i s ,   b a t c h   j o b s ) .


Question: What is DaemonSet?

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


Question: What is ReplicationController?

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


Question: What is What's next?

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


Question: What is Configure a Pod to Use a ConfigMap?

Answer: Configure a Pod to Use a ConfigMapMany applications rely on configuration which is used during either application initialization or runtime. Most times, there is a requirement to adjust values assigned to configuration parameters. ConfigMaps are a Kubernetes mechanism that let you inject configuration data into application pods.The ConfigMap concept allow you to decouple configuration artifacts from image content to keep containerized applications portable. For example, you can download and run the same container image to spin up containers for the purposes of local development, system test, or running a live end-user workload.This page provides a series of usage examples demonstrating how to create ConfigMaps and configure Pods using data stored in ConfigMaps.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 KubernetesYou need to have the wget tool installed. If you have a different tool such as curl, and you do not have wget, you will need to adapt the step that downloads example data.Create a ConfigMapYou can use either kubectl create configmap or a ConfigMap generator in kustomization.yaml to create a ConfigMap.Create a ConfigMap using kubectl create configmapUse the kubectl create configmap command to create ConfigMaps from directories, files, or literal values:kubectl create configmap <map-name> <data-source> where <map-name> is the name you want to assign to the ConfigMap and <data-source> is the directory, file, or literal value to draw the data from. The name of a ConfigMap object must be a valid DNS subdomain name.When you are creating a ConfigMap based on a file, the key in the <data-source> defaults to the basename of the file, and the value defaults to the file content.You can use kubectl describe or kubectl get to retrieve information about a ConfigMap.Create a ConfigMap from a directoryYou can use kubectl create configmap to create a ConfigMap from multiple files in the same directory. When you are creating a ConfigMap based on a directory, kubectl identifies files whose filename is a valid key in the directory and packages each of those files into the new ConfigMap. Any directory entries except regular files are ignored (for example: subdirectories, symlinks, devices, pipes, and more).Note:Each filename being used for ConfigMap creation must consist of only acceptable characters, which are: letters (A to Z and a to z), digits (0 to 9), '-', '_', or '.'. If you use kubectl create configmap with a directory where any of the file names contains an unacceptable character, the kubectl command may fail.The kubectl command does not print an error when it encounters


Question: How does Configure a Pod to Use a ConfigMap work?

Answer: Configure a Pod to Use a ConfigMapMany applications rely on configuration which is used during either application initialization or runtime. Most times, there is a requirement to adjust values assigned to configuration parameters. ConfigMaps are a Kubernetes mechanism that let you inject configuration data into application pods.The ConfigMap concept allow you to decouple configuration artifacts from image content to keep containerized applications portable. For example, you can download and run the same container image to spin up containers for the purposes of local development, system test, or running a live end-user workload.This page provides a series of usage examples demonstrating how to create ConfigMaps and configure Pods using data stored in ConfigMaps.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 KubernetesYou need to have the wget tool installed. If you have a different tool such as curl, and you do not have wget, you will need to adapt the step that downloads example data.Create a ConfigMapYou can use either kubectl create configmap or a ConfigMap generator in kustomization.yaml to create a ConfigMap.Create a ConfigMap using kubectl create configmapUse the kubectl create configmap command to create ConfigMaps from directories, files, or literal values:kubectl create configmap <map-name> <data-source> where <map-name> is the name you want to assign to the ConfigMap and <data-source> is the directory, file, or literal value to draw the data from. The name of a ConfigMap object must be a valid DNS subdomain name.When you are creating a ConfigMap based on a file, the key in the <data-source> defaults to the basename of the file, and the value defaults to the file content.You can use kubectl describe or kubectl get to retrieve information about a ConfigMap.Create a ConfigMap from a directoryYou can use kubectl create configmap to create a ConfigMap from multiple files in the same directory. When you are creating a ConfigMap based on a directory, kubectl identifies files whose filename is a valid key in the directory and packages each of those files into the new ConfigMap. Any directory entries except regular files are ignored (for example: subdirectories, symlinks, devices, pipes, and more).Note:Each filename being used for ConfigMap creation must consist of only acceptable characters, which are: letters (A to Z and a to z), digits (0 to 9), '-', '_', or '.'. If you use kubectl create configmap with a directory where any of the file names contains an unacceptable character, the kubectl command may fail.The kubectl command does not print an error when it encounters


Question: When would you use Configure a Pod to Use a ConfigMap?

Answer: Configure a Pod to Use a ConfigMapMany applications rely on configuration which is used during either application initialization or runtime. Most times, there is a requirement to adjust values assigned to configuration parameters. ConfigMaps are a Kubernetes mechanism that let you inject configuration data into application pods.The ConfigMap concept allow you to decouple configuration artifacts from image content to keep containerized applications portable. For example, you can download and run the same container image to spin up containers for the purposes of local development, system test, or running a live end-user workload.This page provides a series of usage examples demonstrating how to create ConfigMaps and configure Pods using data stored in ConfigMaps.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 KubernetesYou need to have the wget tool installed. If you have a different tool such as curl, and you do not have wget, you will need to adapt the step that downloads example data.Create a ConfigMapYou can use either kubectl create configmap or a ConfigMap generator in kustomization.yaml to create a ConfigMap.Create a ConfigMap using kubectl create configmapUse the kubectl create configmap command to create ConfigMaps from directories, files, or literal values:kubectl create configmap <map-name> <data-source> where <map-name> is the name you want to assign to the ConfigMap and <data-source> is the directory, file, or literal value to draw the data from. The name of a ConfigMap object must be a valid DNS subdomain name.When you are creating a ConfigMap based on a file, the key in the <data-source> defaults to the basename of the file, and the value defaults to the file content.You can use kubectl describe or kubectl get to retrieve information about a ConfigMap.Create a ConfigMap from a directoryYou can use kubectl create configmap to create a ConfigMap from multiple files in the same directory. When you are creating a ConfigMap based on a directory, kubectl identifies files whose filename is a valid key in the directory and packages each of those files into the new ConfigMap. Any directory entries except regular files are ignored (for example: subdirectories, symlinks, devices, pipes, and more).Note:Each filename being used for ConfigMap creation must consist of only acceptable characters, which are: letters (A to Z and a to z), digits (0 to 9), '-', '_', or '.'. If you use kubectl create configmap with a directory where any of the file names contains an unacceptable character, the kubectl command may fail.The kubectl command does not print an error when it encounters


Question: What are the benefits of Configure a Pod to Use a ConfigMap?

Answer: Configure a Pod to Use a ConfigMapMany applications rely on configuration which is used during either application initialization or runtime. Most times, there is a requirement to adjust values assigned to configuration parameters. ConfigMaps are a Kubernetes mechanism that let you inject configuration data into application pods.The ConfigMap concept allow you to decouple configuration artifacts from image content to keep containerized applications portable. For example, you can download and run the same container image to spin up containers for the purposes of local development, system test, or running a live end-user workload.This page provides a series of usage examples demonstrating how to create ConfigMaps and configure Pods using data stored in ConfigMaps.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 KubernetesYou need to have the wget tool installed. If you have a different tool such as curl, and you do not have wget, you will need to adapt the step that downloads example data.Create a ConfigMapYou can use either kubectl create configmap or a ConfigMap generator in kustomization.yaml to create a ConfigMap.Create a ConfigMap using kubectl create configmapUse the kubectl create configmap command to create ConfigMaps from directories, files, or literal values:kubectl create configmap <map-name> <data-source> where <map-name> is the name you want to assign to the ConfigMap and <data-source> is the directory, file, or literal value to draw the data from. The name of a ConfigMap object must be a valid DNS subdomain name.When you are creating a ConfigMap based on a file, the key in the <data-source> defaults to the basename of the file, and the value defaults to the file content.You can use kubectl describe or kubectl get to retrieve information about a ConfigMap.Create a ConfigMap from a directoryYou can use kubectl create configmap to create a ConfigMap from multiple files in the same directory. When you are creating a ConfigMap based on a directory, kubectl identifies files whose filename is a valid key in the directory and packages each of those files into the new ConfigMap. Any directory entries except regular files are ignored (for example: subdirectories, symlinks, devices, pipes, and more).Note:Each filename being used for ConfigMap creation must consist of only acceptable characters, which are: letters (A to Z and a to z), digits (0 to 9), '-', '_', or '.'. If you use kubectl create configmap with a directory where any of the file names contains an unacceptable character, the kubectl command may fail.The kubectl command does not print an error when it encounters


Question: What is Configure a Pod to Use a ConfigMap?

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


Question: What is Before you begin?

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


Question: What is Create a ConfigMap?

Answer: Y o u   c a n   u s e   e i t h e r   k u b e c t l   c r e a t e   c o n f i g m a p   o r   a   C o n f i g M a p   g e n e r a t o r   i n   k u s t o m i z a t i o n . y a m l   t o   c r e a t e   a   C o n f i g M a p .


Question: What is Create a ConfigMap using kubectl create configmap?

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


Question: What is Create a ConfigMap from a directory?

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


Question: What is Note:?

Answer: E a c h   f i l e n a m e   b e i n g   u s e d   f o r   C o n f i g M a p   c r e a t i o n   m u s t   c o n s i s t   o f   o n l y   a c c e p t a b l e   c h a r a c t e r s ,   w h i c h   a r e :   l e t t e r s   ( A   t o   Z   a n d   a   t o   z ) ,   d i g i t s   ( 0   t o   9 ) ,   ' - ' ,   ' _ ' ,   o r   ' . ' .   I f   y o u   u s e   k u b e c t l   c r e a t e   c o n f i g m a p   w i t h   a   d i r e c t o r y   w h e r e   a n y   o f   t h e   f i l e   n a m e s   c o n t a i n s   a n   u n a c c e p t a b l e   c h a r a c t e r ,   t h e   k u b e c t l   c o m m a n d   m a y   f a i l .   T h e   k u b e c t l   c o m m a n d   d o e s   n o t   p r i n t   a n   e r r o r   w h e n   i t   e n c o u n t e r s   a n   i n v a l i d   f i l e n a m e .   C r e a t e   t h e   l o c a l   d i r e c t o r y :   m k d i r   - p   c o n f i g u r e - p o d - c o n t a i n e r / c o n f i g m a p /   N o w ,   d o w n l o a d   t h e   s a m p l e   c o n f i g u r a t i o n   a n d   c r e a t e   t h e   C o n f i g M a p :   #   D o w n l o a d   t h e   s a m p l e   f i l e s   i n t o   ` c o n f i g u r e - p o d - c o n t a i n e r / c o n f i g m a p / `   d i r e c t o r y   w g e t   h t t p s : / / k u b e r n e t e s . i o / e x a m p l e s / c o n f i g m a p / g a m e . p r o p e r t i e s   - O   c o n f i g u r e - p o d - c o n t a i n e r / c o n f i g m a p / g a m e . p r o p e r t i e s   w g e t   h t t p s : / / k u b e r n e t e s . i o / e x a m p l e s / c o n f i g m a p / u i . p r o p e r t i e s   - O   c o n f i g u r e - p o d - c o n t a i n e r / c o n f i g m a p / u i . p r o p e r t i e s   #   C r e a t e   t h e   C o n f i g M a p   k u b e c t l   c r e a t e   c o n f i g m a p   g a m e - c o n f i g   - - f r o m - f i l e = c o n f i g u r e - p o d - c o n t a i n e r / c o n f i g m a p /   T h e   a b o v e   c o m m a n d   p a c k a g e s   e a c h   f i l e ,   i n   t h i s   c a s e ,


Question: What is Create ConfigMaps from files?

Answer: Y o u   c a n   u s e   k u b e c t l   c r e a t e   c o n f i g m a p   t o   c r e a t e   a   C o n f i g M a p   f r o m   a n   i n d i v i d u a l   f i l e ,   o r   f r o m   m u l t i p l e   f i l e s .   F o r   e x a m p l e ,   k u b e c t l   c r e a t e   c o n f i g m a p   g a m e - c o n f i g - 2   - - f r o m - f i l e = c o n f i g u r e - p o d - c o n t a i n e r / c o n f i g m a p / g a m e . p r o p e r t i e s   w o u l d   p r o d u c e   t h e   f o l l o w i n g   C o n f i g M a p :   k u b e c t l   d e s c r i b e   c o n f i g m a p s   g a m e - c o n f i g - 2   w h e r e   t h e   o u t p u t   i s   s i m i l a r   t o   t h i s :   N a m e :   g a m e - c o n f i g - 2   N a m e s p a c e :   d e f a u l t   L a b e l s :   < n o n e >   A n n o t a t i o n s :   < n o n e >   D a t a   = = = =   g a m e . p r o p e r t i e s :   - - - -   e n e m i e s = a l i e n s   l i v e s = 3   e n e m i e s . c h e a t = t r u e   e n e m i e s . c h e a t . l e v e l = n o G o o d R o t t e n   s e c r e t . c o d e . p a s s p h r a s e = U U D D L R L R B A B A S   s e c r e t . c o d e . a l l o w e d = t r u e   s e c r e t . c o d e . l i v e s = 3 0   Y o u   c a n   p a s s   i n   t h e   - - f r o m - f i l e   a r g u m e n t   m u l t i p l e   t i m e s   t o   c r e a t e   a   C o n f i g M a p   f r o m   m u l t i p l e   d a t a   s o u r c e s .   k u b e c t l   c r e a t e   c o n f i g m a p   g a m e - c o n f i g - 2   - - f r o m - f i l e = c o n f i g u r e - p o d - c o n t a i n e r / c o n f i g m a p / g a m e . p r o p e r t i e s   - - f r o m - f i l e = c o n f i g u r e - p o d - c o n t a i n e r / c o n f i g m a p / u i . p r o p e r t i e s   Y o u   c a n   d i s p l a y   d e t a i l s   o f   t h e   g a m e - c o n f i g - 2   C o n f i g M a p   u s i n g   t h e   f o l l o w i n g   c o m m a n d :   k u b e c t l   d e s c r i b e   c o n f i g m a p s   g a m e - c o n f i g - 2   T h e


Question: What is Define the key to use when creating a ConfigMap from a file?

Answer: Y o u   c a n   d e f i n e   a   k e y   o t h e r   t h a n   t h e   f i l e   n a m e   t o   u s e   i n   t h e   d a t a   s e c t i o n   o f   y o u r   C o n f i g M a p   w h e n   u s i n g   t h e   - - f r o m - f i l e   a r g u m e n t :   k u b e c t l   c r e a t e   c o n f i g m a p   g a m e - c o n f i g - 3   - - f r o m - f i l e = < m y - k e y - n a m e > = < p a t h - t o - f i l e >   w h e r e   < m y - k e y - n a m e >   i s   t h e   k e y   y o u   w a n t   t o   u s e   i n   t h e   C o n f i g M a p   a n d   < p a t h - t o - f i l e >   i s   t h e   l o c a t i o n   o f   t h e   d a t a   s o u r c e   f i l e   y o u   w a n t   t h e   k e y   t o   r e p r e s e n t .   F o r   e x a m p l e :   k u b e c t l   c r e a t e   c o n f i g m a p   g a m e - c o n f i g - 3   - - f r o m - f i l e = g a m e - s p e c i a l - k e y = c o n f i g u r e - p o d - c o n t a i n e r / c o n f i g m a p / g a m e . p r o p e r t i e s   w o u l d   p r o d u c e   t h e   f o l l o w i n g   C o n f i g M a p :   k u b e c t l   g e t   c o n f i g m a p s   g a m e - c o n f i g - 3   - o   y a m l   w h e r e   t h e   o u t p u t   i s   s i m i l a r   t o   t h i s :   a p i V e r s i o n :   v 1   k i n d :   C o n f i g M a p   m e t a d a t a :   c r e a t i o n T i m e s t a m p :   2 0 2 2 - 0 2 - 1 8 T 1 8 : 5 4 : 2 2 Z   n a m e :   g a m e - c o n f i g - 3   n a m e s p a c e :   d e f a u l t   r e s o u r c e V e r s i o n :   " 5 3 0 "   u i d :   0 5 f 8 d a 2 2 - d 6 7 1 - 1 1 e 5 - 8 c d 0 - 6 8 f 7 2 8 d b 1 9 8 5   d a t a :   g a m e - s p e c i a l - k e y :   |   e n e m i e s = a l i e n s   l i v e s = 3   e n e m i e s . c h e a t = t r u e   e n e m i e s . c h e a t . l e v e l = n o G o o d R o t t e n   s e c r e t . c o d e . p a s s p h r a s e = U U D D L R L R B A B A S   s e c r e t . c o d e . a l l o w e d = t r u e   s e c r e t . c o d e . l i v e s = 3 0


Question: What is Create ConfigMaps from literal values?

Answer: Y o u   c a n   u s e   k u b e c t l   c r e a t e   c o n f i g m a p   w i t h   t h e   - - f r o m - l i t e r a l   a r g u m e n t   t o   d e f i n e   a   l i t e r a l   v a l u e   f r o m   t h e   c o m m a n d   l i n e :   k u b e c t l   c r e a t e   c o n f i g m a p   s p e c i a l - c o n f i g   - - f r o m - l i t e r a l = s p e c i a l . h o w = v e r y   - - f r o m - l i t e r a l = s p e c i a l . t y p e = c h a r m   Y o u   c a n   p a s s   i n   m u l t i p l e   k e y - v a l u e   p a i r s .   E a c h   p a i r   p r o v i d e d   o n   t h e   c o m m a n d   l i n e   i s   r e p r e s e n t e d   a s   a   s e p a r a t e   e n t r y   i n   t h e   d a t a   s e c t i o n   o f   t h e   C o n f i g M a p .   k u b e c t l   g e t   c o n f i g m a p s   s p e c i a l - c o n f i g   - o   y a m l   T h e   o u t p u t   i s   s i m i l a r   t o   t h i s :   a p i V e r s i o n :   v 1   k i n d :   C o n f i g M a p   m e t a d a t a :   c r e a t i o n T i m e s t a m p :   2 0 2 2 - 0 2 - 1 8 T 1 9 : 1 4 : 3 8 Z   n a m e :   s p e c i a l - c o n f i g   n a m e s p a c e :   d e f a u l t   r e s o u r c e V e r s i o n :   " 6 5 1 "   u i d :   d a d c e 0 4 6 - d 6 7 3 - 1 1 e 5 - 8 c d 0 - 6 8 f 7 2 8 d b 1 9 8 5   d a t a :   s p e c i a l . h o w :   v e r y   s p e c i a l . t y p e :   c h a r m


Question: What is Create a ConfigMap from generator?

Answer: Y o u   c a n   a l s o   c r e a t e   a   C o n f i g M a p   f r o m   g e n e r a t o r s   a n d   t h e n   a p p l y   i t   t o   c r e a t e   t h e   o b j e c t   i n   t h e   c l u s t e r ' s   A P I   s e r v e r .   Y o u   s h o u l d   s p e c i f y   t h e   g e n e r a t o r s   i n   a   k u s t o m i z a t i o n . y a m l   f i l e   w i t h i n   a   d i r e c t o r y .


Question: What is Generate ConfigMaps from files?

Answer: F o r   e x a m p l e ,   t o   g e n e r a t e   a   C o n f i g M a p   f r o m   f i l e s   c o n f i g u r e - p o d - c o n t a i n e r / c o n f i g m a p / g a m e . p r o p e r t i e s   #   C r e a t e   a   k u s t o m i z a t i o n . y a m l   f i l e   w i t h   C o n f i g M a p G e n e r a t o r   c a t   < < E O F   > . / k u s t o m i z a t i o n . y a m l   c o n f i g M a p G e n e r a t o r :   -   n a m e :   g a m e - c o n f i g - 4   o p t i o n s :   l a b e l s :   g a m e - c o n f i g :   c o n f i g - 4   f i l e s :   -   c o n f i g u r e - p o d - c o n t a i n e r / c o n f i g m a p / g a m e . p r o p e r t i e s   E O F   A p p l y   t h e   k u s t o m i z a t i o n   d i r e c t o r y   t o   c r e a t e   t h e   C o n f i g M a p   o b j e c t :   k u b e c t l   a p p l y   - k   .   c o n f i g m a p / g a m e - c o n f i g - 4 - m 9 d m 2 f 9 2 b t   c r e a t e d   Y o u   c a n   c h e c k   t h a t   t h e   C o n f i g M a p   w a s   c r e a t e d   l i k e   t h i s :   k u b e c t l   g e t   c o n f i g m a p   N A M E   D A T A   A G E   g a m e - c o n f i g - 4 - m 9 d m 2 f 9 2 b t   1   3 7 s   a n d   a l s o :   k u b e c t l   d e s c r i b e   c o n f i g m a p s / g a m e - c o n f i g - 4 - m 9 d m 2 f 9 2 b t   N a m e :   g a m e - c o n f i g - 4 - m 9 d m 2 f 9 2 b t   N a m e s p a c e :   d e f a u l t   L a b e l s :   g a m e - c o n f i g = c o n f i g - 4   A n n o t a t i o n s :   k u b e c t l . k u b e r n e t e s . i o / l a s t - a p p l i e d - c o n f i g u r a t i o n :   { " a p i V e r s i o n " : " v 1 " , " d a t a " : { " g a m e . p r o p e r t i e s " : " e n e m i e s = a l i e n s \ n l i v e s = 3 \ n e n e m i e s . c h e a t = t r u e \ n e n e m i e s . c h e a t . l e v e l = n o G o o d R o t t e n \ n s e c r e t . c o d e . p . . .   D a t a   = = = =   g a m e . p r o p e r t i e s :   - - - -   e n e m i e s = a l i e n s   l i v e s = 3   e n e m i e s . c h e a t =


Question: What is Define the key to use when generating a ConfigMap from a file?

Answer: Y o u   c a n   d e f i n e   a   k e y   o t h e r   t h a n   t h e   f i l e   n a m e   t o   u s e   i n   t h e   C o n f i g M a p   g e n e r a t o r .   F o r   e x a m p l e ,   t o   g e n e r a t e   a   C o n f i g M a p   f r o m   f i l e s   c o n f i g u r e - p o d - c o n t a i n e r / c o n f i g m a p / g a m e . p r o p e r t i e s   w i t h   t h e   k e y   g a m e - s p e c i a l - k e y   #   C r e a t e   a   k u s t o m i z a t i o n . y a m l   f i l e   w i t h   C o n f i g M a p G e n e r a t o r   c a t   < < E O F   > . / k u s t o m i z a t i o n . y a m l   c o n f i g M a p G e n e r a t o r :   -   n a m e :   g a m e - c o n f i g - 5   o p t i o n s :   l a b e l s :   g a m e - c o n f i g :   c o n f i g - 5   f i l e s :   -   g a m e - s p e c i a l - k e y = c o n f i g u r e - p o d - c o n t a i n e r / c o n f i g m a p / g a m e . p r o p e r t i e s   E O F   A p p l y   t h e   k u s t o m i z a t i o n   d i r e c t o r y   t o   c r e a t e   t h e   C o n f i g M a p   o b j e c t .   k u b e c t l   a p p l y   - k   .   c o n f i g m a p / g a m e - c o n f i g - 5 - m 6 7 d t 6 7 7 9 4   c r e a t e d


Question: What is Generate ConfigMaps from literals?

Answer: T h i s   e x a m p l e   s h o w s   y o u   h o w   t o   c r e a t e   a   C o n f i g M a p   f r o m   t w o   l i t e r a l   k e y / v a l u e   p a i r s :   s p e c i a l . t y p e = c h a r m   a n d   s p e c i a l . h o w = v e r y ,   u s i n g   K u s t o m i z e   a n d   k u b e c t l .   T o   a c h i e v e   t h i s ,   y o u   c a n   s p e c i f y   t h e   C o n f i g M a p   g e n e r a t o r .   C r e a t e   ( o r   r e p l a c e )   k u s t o m i z a t i o n . y a m l   s o   t h a t   i t   h a s   t h e   f o l l o w i n g   c o n t e n t s :   - - -   #   k u s t o m i z a t i o n . y a m l   c o n t e n t s   f o r   c r e a t i n g   a   C o n f i g M a p   f r o m   l i t e r a l s   c o n f i g M a p G e n e r a t o r :   -   n a m e :   s p e c i a l - c o n f i g - 2   l i t e r a l s :   -   s p e c i a l . h o w = v e r y   -   s p e c i a l . t y p e = c h a r m   A p p l y   t h e   k u s t o m i z a t i o n   d i r e c t o r y   t o   c r e a t e   t h e   C o n f i g M a p   o b j e c t :   k u b e c t l   a p p l y   - k   .   c o n f i g m a p / s p e c i a l - c o n f i g - 2 - c 9 2 b 5 m m c f 2   c r e a t e d


Question: What is Interim cleanup?

Answer: B e f o r e   p r o c e e d i n g ,   c l e a n   u p   s o m e   o f   t h e   C o n f i g M a p s   y o u   m a d e :   k u b e c t l   d e l e t e   c o n f i g m a p   s p e c i a l - c o n f i g   k u b e c t l   d e l e t e   c o n f i g m a p   e n v - c o n f i g   k u b e c t l   d e l e t e   c o n f i g m a p   - l   ' g a m e - c o n f i g   i n   ( c o n f i g - 4 , c o n f i g - 5 ) '   N o w   t h a t   y o u   h a v e   l e a r n e d   t o   d e f i n e   C o n f i g M a p s ,   y o u   c a n   m o v e   o n   t o   t h e   n e x t   s e c t i o n ,   a n d   l e a r n   h o w   t o   u s e   t h e s e   o b j e c t s   w i t h   P o d s .


Question: What is Define a container environment variable with data from a single ConfigMap?

Answer: D e f i n e   a n   e n v i r o n m e n t   v a r i a b l e   a s   a   k e y - v a l u e   p a i r   i n   a   C o n f i g M a p : k u b e c t l   c r e a t e   c o n f i g m a p   s p e c i a l - c o n f i g   - - f r o m - l i t e r a l = s p e c i a l . h o w = v e r y   A s s i g n   t h e   s p e c i a l . h o w   v a l u e   d e f i n e d   i n   t h e   C o n f i g M a p   t o   t h e   S P E C I A L _ L E V E L _ K E Y   e n v i r o n m e n t   v a r i a b l e   i n   t h e   P o d   s p e c i f i c a t i o n . p o d s / p o d - s i n g l e - c o n f i g m a p - e n v - v a r i a b l e . y a m l   a p i V e r s i o n :   v 1   k i n d :   P o d   m e t a d a t a :   n a m e :   d a p i - t e s t - p o d   s p e c :   c o n t a i n e r s :   -   n a m e :   t e s t - c o n t a i n e r   i m a g e :   r e g i s t r y . k 8 s . i o / b u s y b o x : 1 . 2 7 . 2   c o m m a n d :   [   " / b i n / s h " ,   " - c " ,   " e n v "   ]   e n v :   #   D e f i n e   t h e   e n v i r o n m e n t   v a r i a b l e   -   n a m e :   S P E C I A L _ L E V E L _ K E Y   v a l u e F r o m :   c o n f i g M a p K e y R e f :   #   T h e   C o n f i g M a p   c o n t a i n i n g   t h e   v a l u e   y o u   w a n t   t o   a s s i g n   t o   S P E C I A L _ L E V E L _ K E Y   n a m e :   s p e c i a l - c o n f i g   #   S p e c i f y   t h e   k e y   a s s o c i a t e d   w i t h   t h e   v a l u e   k e y :   s p e c i a l . h o w   r e s t a r t P o l i c y :   N e v e r   C r e a t e   t h e   P o d : k u b e c t l   c r e a t e   - f   h t t p s : / / k u b e r n e t e s . i o / e x a m p l e s / p o d s / p o d - s i n g l e - c o n f i g m a p - e n v - v a r i a b l e . y a m l   N o w ,   t h e   P o d ' s   o u t p u t   i n c l u d e s   e n v i r o n m e n t   v a r i a b l e   S P E C I A L _ L E V E L _ K E Y = v e r y .   D e f i n e   a n   e n v i r o n m e n t   v a r i a b l e   a s   a   k e y - v a l u e   p a i r   i n   a   C o n f i g M a p :


Question: What is Define container environment variables with data from multiple ConfigMaps?

Answer: A s   w i t h   t h e   p r e v i o u s   e x a m p l e ,   c r e a t e   t h e   C o n f i g M a p s   f i r s t .   H e r e   i s   t h e   m a n i f e s t   y o u   w i l l   u s e :   a p i V e r s i o n :   v 1   k i n d :   C o n f i g M a p   m e t a d a t a :   n a m e :   s p e c i a l - c o n f i g   n a m e s p a c e :   d e f a u l t   d a t a :   s p e c i a l . h o w :   v e r y   - - -   a p i V e r s i o n :   v 1   k i n d :   C o n f i g M a p   m e t a d a t a :   n a m e :   e n v - c o n f i g   n a m e s p a c e :   d e f a u l t   d a t a :   l o g _ l e v e l :   I N F O   C r e a t e   t h e   C o n f i g M a p : k u b e c t l   c r e a t e   - f   h t t p s : / / k u b e r n e t e s . i o / e x a m p l e s / c o n f i g m a p / c o n f i g m a p s . y a m l   D e f i n e   t h e   e n v i r o n m e n t   v a r i a b l e s   i n   t h e   P o d   s p e c i f i c a t i o n . p o d s / p o d - m u l t i p l e - c o n f i g m a p - e n v - v a r i a b l e . y a m l   a p i V e r s i o n :   v 1   k i n d :   P o d   m e t a d a t a :   n a m e :   d a p i - t e s t - p o d   s p e c :   c o n t a i n e r s :   -   n a m e :   t e s t - c o n t a i n e r   i m a g e :   r e g i s t r y . k 8 s . i o / b u s y b o x : 1 . 2 7 . 2   c o m m a n d :   [   " / b i n / s h " ,   " - c " ,   " e n v "   ]   e n v :   -   n a m e :   S P E C I A L _ L E V E L _ K E Y   v a l u e F r o m :   c o n f i g M a p K e y R e f :   n a m e :   s p e c i a l - c o n f i g   k e y :   s p e c i a l . h o w   -   n a m e :   L O G _ L E V E L   v a l u e F r o m :   c o n f i g M a p K e y R e f :   n a m e :   e n v - c o n f i g   k e y :   l o g _ l e v e l   r e s t a r t P o l i c y :   N e v e r   C r e a t e   t h e   P o d : k u b e c t l   c r e a t e   - f   h t t p s : / / k u b e r n e t e s . i o / e x a m p l e s / p o d s / p o d - m u l t i p l e - c o n f i g m a p - e n v - v a r i a b l e . y a m l   N o w ,   t h e   P o d ' s   o u t p u t


Question: What is Configure all key-value pairs in a ConfigMap as container environment variables?

Answer: C r e a t e   a   C o n f i g M a p   c o n t a i n i n g   m u l t i p l e   k e y - v a l u e   p a i r s . c o n f i g m a p / c o n f i g m a p - m u l t i k e y s . y a m l   a p i V e r s i o n :   v 1   k i n d :   C o n f i g M a p   m e t a d a t a :   n a m e :   s p e c i a l - c o n f i g   n a m e s p a c e :   d e f a u l t   d a t a :   S P E C I A L _ L E V E L :   v e r y   S P E C I A L _ T Y P E :   c h a r m   C r e a t e   t h e   C o n f i g M a p : k u b e c t l   c r e a t e   - f   h t t p s : / / k u b e r n e t e s . i o / e x a m p l e s / c o n f i g m a p / c o n f i g m a p - m u l t i k e y s . y a m l   U s e   e n v F r o m   t o   d e f i n e   a l l   o f   t h e   C o n f i g M a p ' s   d a t a   a s   c o n t a i n e r   e n v i r o n m e n t   v a r i a b l e s .   T h e   k e y   f r o m   t h e   C o n f i g M a p   b e c o m e s   t h e   e n v i r o n m e n t   v a r i a b l e   n a m e   i n   t h e   P o d . p o d s / p o d - c o n f i g m a p - e n v F r o m . y a m l   a p i V e r s i o n :   v 1   k i n d :   P o d   m e t a d a t a :   n a m e :   d a p i - t e s t - p o d   s p e c :   c o n t a i n e r s :   -   n a m e :   t e s t - c o n t a i n e r   i m a g e :   r e g i s t r y . k 8 s . i o / b u s y b o x : 1 . 2 7 . 2   c o m m a n d :   [   " / b i n / s h " ,   " - c " ,   " e n v "   ]   e n v F r o m :   -   c o n f i g M a p R e f :   n a m e :   s p e c i a l - c o n f i g   r e s t a r t P o l i c y :   N e v e r   C r e a t e   t h e   P o d : k u b e c t l   c r e a t e   - f   h t t p s : / / k u b e r n e t e s . i o / e x a m p l e s / p o d s / p o d - c o n f i g m a p - e n v F r o m . y a m l   N o w ,   t h e   P o d ' s   o u t p u t   i n c l u d e s   e n v i r o n m e n t   v a r i a b l e s   S P E C I A L _ L E V E L = v e r y   a n d   S P E C I A L _ T Y P E = c h a r m . O n c e   y o u ' r e   h a p p y   t o   m o v e   o n ,   d e l e t e   t h a t   P o d : k u b e c t l   d e


Question: What is Use ConfigMap-defined environment variables in Pod commands?

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


Question: What is Add ConfigMap data to a Volume?

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


Question: What is Populate a Volume with data stored in a ConfigMap?

Answer: A d d   t h e   C o n f i g M a p   n a m e   u n d e r   t h e   v o l u m e s   s e c t i o n   o f   t h e   P o d   s p e c i f i c a t i o n .   T h i s   a d d s   t h e   C o n f i g M a p   d a t a   t o   t h e   d i r e c t o r y   s p e c i f i e d   a s   v o l u m e M o u n t s . m o u n t P a t h   ( i n   t h i s   c a s e ,   / e t c / c o n f i g ) .   T h e   c o m m a n d   s e c t i o n   l i s t s   d i r e c t o r y   f i l e s   w i t h   n a m e s   t h a t   m a t c h   t h e   k e y s   i n   C o n f i g M a p .   a p i V e r s i o n :   v 1   k i n d :   P o d   m e t a d a t a :   n a m e :   d a p i - t e s t - p o d   s p e c :   c o n t a i n e r s :   -   n a m e :   t e s t - c o n t a i n e r   i m a g e :   r e g i s t r y . k 8 s . i o / b u s y b o x : 1 . 2 7 . 2   c o m m a n d :   [   " / b i n / s h " ,   " - c " ,   " l s   / e t c / c o n f i g / "   ]   v o l u m e M o u n t s :   -   n a m e :   c o n f i g - v o l u m e   m o u n t P a t h :   / e t c / c o n f i g   v o l u m e s :   -   n a m e :   c o n f i g - v o l u m e   c o n f i g M a p :   #   P r o v i d e   t h e   n a m e   o f   t h e   C o n f i g M a p   c o n t a i n i n g   t h e   f i l e s   y o u   w a n t   #   t o   a d d   t o   t h e   c o n t a i n e r   n a m e :   s p e c i a l - c o n f i g   r e s t a r t P o l i c y :   N e v e r   C r e a t e   t h e   P o d :   k u b e c t l   c r e a t e   - f   h t t p s : / / k u b e r n e t e s . i o / e x a m p l e s / p o d s / p o d - c o n f i g m a p - v o l u m e . y a m l   W h e n   t h e   p o d   r u n s ,   t h e   c o m m a n d   l s   / e t c / c o n f i g /   p r o d u c e s   t h e   o u t p u t   b e l o w :   S P E C I A L _ L E V E L   S P E C I A L _ T Y P E   T e x t   d a t a   i s   e x p o s e d   a s   f i l e s   u s i n g   t h e   U T F - 8   c h a r a c t e r   e n c o d i n g .   T o   u s e   s o m e   o t h e r   c h a r a c t e r   e n c o d i n g ,   u s e   b i n a r


Question: What is Note:?

Answer: O n c e   y o u ' r e   h a p p y   t o   m o v e   o n ,   d e l e t e   t h a t   P o d :   k u b e c t l   d e l e t e   p o d   d a p i - t e s t - p o d   - - n o w


Question: What is Add ConfigMap data to a specific path in the Volume?

Answer: U s e   t h e   p a t h   f i e l d   t o   s p e c i f y   t h e   d e s i r e d   f i l e   p a t h   f o r   s p e c i f i c   C o n f i g M a p   i t e m s .   I n   t h i s   c a s e ,   t h e   S P E C I A L _ L E V E L   i t e m   w i l l   b e   m o u n t e d   i n   t h e   c o n f i g - v o l u m e   v o l u m e   a t   / e t c / c o n f i g / k e y s .   a p i V e r s i o n :   v 1   k i n d :   P o d   m e t a d a t a :   n a m e :   d a p i - t e s t - p o d   s p e c :   c o n t a i n e r s :   -   n a m e :   t e s t - c o n t a i n e r   i m a g e :   r e g i s t r y . k 8 s . i o / b u s y b o x : 1 . 2 7 . 2   c o m m a n d :   [   " / b i n / s h " , " - c " , " c a t   / e t c / c o n f i g / k e y s "   ]   v o l u m e M o u n t s :   -   n a m e :   c o n f i g - v o l u m e   m o u n t P a t h :   / e t c / c o n f i g   v o l u m e s :   -   n a m e :   c o n f i g - v o l u m e   c o n f i g M a p :   n a m e :   s p e c i a l - c o n f i g   i t e m s :   -   k e y :   S P E C I A L _ L E V E L   p a t h :   k e y s   r e s t a r t P o l i c y :   N e v e r   C r e a t e   t h e   P o d :   k u b e c t l   c r e a t e   - f   h t t p s : / / k u b e r n e t e s . i o / e x a m p l e s / p o d s / p o d - c o n f i g m a p - v o l u m e - s p e c i f i c - k e y . y a m l   W h e n   t h e   p o d   r u n s ,   t h e   c o m m a n d   c a t   / e t c / c o n f i g / k e y s   p r o d u c e s   t h e   o u t p u t   b e l o w :   v e r y


Question: What is Caution:?

Answer: D e l e t e   t h a t   P o d :   k u b e c t l   d e l e t e   p o d   d a p i - t e s t - p o d   - - n o w


Question: What is Project keys to specific paths and file permissions?

Answer: Y o u   c a n   p r o j e c t   k e y s   t o   s p e c i f i c   p a t h s .   R e f e r   t o   t h e   c o r r e s p o n d i n g   s e c t i o n   i n   t h e   S e c r e t s   g u i d e   f o r   t h e   s y n t a x . Y o u   c a n   s e t   P O S I X   p e r m i s s i o n s   f o r   k e y s .   R e f e r   t o   t h e   c o r r e s p o n d i n g   s e c t i o n   i n   t h e   S e c r e t s   g u i d e   f o r   t h e   s y n t a x .


Question: What is Optional references?

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


Question: What is Mounted ConfigMaps are updated automatically?

Answer: W h e n   a   m o u n t e d   C o n f i g M a p   i s   u p d a t e d ,   t h e   p r o j e c t e d   c o n t e n t   i s   e v e n t u a l l y   u p d a t e d   t o o .   T h i s   a p p l i e s   i n   t h e   c a s e   w h e r e   a n   o p t i o n a l l y   r e f e r e n c e d   C o n f i g M a p   c o m e s   i n t o   e x i s t e n c e   a f t e r   a   p o d   h a s   s t a r t e d .   K u b e l e t   c h e c k s   w h e t h e r   t h e   m o u n t e d   C o n f i g M a p   i s   f r e s h   o n   e v e r y   p e r i o d i c   s y n c .   H o w e v e r ,   i t   u s e s   i t s   l o c a l   T T L - b a s e d   c a c h e   f o r   g e t t i n g   t h e   c u r r e n t   v a l u e   o f   t h e   C o n f i g M a p .   A s   a   r e s u l t ,   t h e   t o t a l   d e l a y   f r o m   t h e   m o m e n t   w h e n   t h e   C o n f i g M a p   i s   u p d a t e d   t o   t h e   m o m e n t   w h e n   n e w   k e y s   a r e   p r o j e c t e d   t o   t h e   p o d   c a n   b e   a s   l o n g   a s   k u b e l e t   s y n c   p e r i o d   ( 1   m i n u t e   b y   d e f a u l t )   +   T T L   o f   C o n f i g M a p s   c a c h e   ( 1   m i n u t e   b y   d e f a u l t )   i n   k u b e l e t .   Y o u   c a n   t r i g g e r   a n   i m m e d i a t e   r e f r e s h   b y   u p d a t i n g   o n e   o f   t h e   p o d ' s   a n n o t a t i o n s .


Question: What is Understanding ConfigMaps and Pods?

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


Question: What is Note:?

Answer: T h e   C o n f i g M a p ' s   d a t a   f i e l d   c o n t a i n s   t h e   c o n f i g u r a t i o n   d a t a .   A s   s h o w n   i n   t h e   e x a m p l e   b e l o w ,   t h i s   c a n   b e   s i m p l e   ( l i k e   i n d i v i d u a l   p r o p e r t i e s   d e f i n e d   u s i n g   - - f r o m - l i t e r a l )   o r   c o m p l e x   ( l i k e   c o n f i g u r a t i o n   f i l e s   o r   J S O N   b l o b s   d e f i n e d   u s i n g   - - f r o m - f i l e ) .   a p i V e r s i o n :   v 1   k i n d :   C o n f i g M a p   m e t a d a t a :   c r e a t i o n T i m e s t a m p :   2 0 1 6 - 0 2 - 1 8 T 1 9 : 1 4 : 3 8 Z   n a m e :   e x a m p l e - c o n f i g   n a m e s p a c e :   d e f a u l t   d a t a :   #   e x a m p l e   o f   a   s i m p l e   p r o p e r t y   d e f i n e d   u s i n g   - - f r o m - l i t e r a l   e x a m p l e . p r o p e r t y . 1 :   h e l l o   e x a m p l e . p r o p e r t y . 2 :   w o r l d   #   e x a m p l e   o f   a   c o m p l e x   p r o p e r t y   d e f i n e d   u s i n g   - - f r o m - f i l e   e x a m p l e . p r o p e r t y . f i l e :   | -   p r o p e r t y . 1 = v a l u e - 1   p r o p e r t y . 2 = v a l u e - 2   p r o p e r t y . 3 = v a l u e - 3   W h e n   k u b e c t l   c r e a t e s   a   C o n f i g M a p   f r o m   i n p u t s   t h a t   a r e   n o t   A S C I I   o r   U T F - 8 ,   t h e   t o o l   p u t s   t h e s e   i n t o   t h e   b i n a r y D a t a   f i e l d   o f   t h e   C o n f i g M a p ,   a n d   n o t   i n   d a t a .   B o t h   t e x t   a n d   b i n a r y   d a t a   s o u r c e s   c a n   b e   c o m b i n e d   i n   o n e   C o n f i g M a p .   I f   y o u   w a n t   t o   v i e w   t h e   b i n a r y D a t a   k e y s   ( a n d   t h e i r   v a l u e s )   i n   a   C o n f i g M a p ,   y o u   c a n   r u n   k u b e c t l   g e t   c o n f i g m a p   - o   j s o n p a t h = ' { . b i n a r y D a t a } '   < n a m e > .   P o d s


Question: What is Optional ConfigMaps?

Answer: Y o u   c a n   m a r k   a   r e f e r e n c e   t o   a   C o n f i g M a p   a s   o p t i o n a l   i n   a   P o d   s p e c i f i c a t i o n .   I f   t h e   C o n f i g M a p   d o e s n ' t   e x i s t ,   t h e   c o n f i g u r a t i o n   f o r   w h i c h   i t   p r o v i d e s   d a t a   i n   t h e   P o d   ( f o r   e x a m p l e :   e n v i r o n m e n t   v a r i a b l e ,   m o u n t e d   v o l u m e )   w i l l   b e   e m p t y .   I f   t h e   C o n f i g M a p   e x i s t s ,   b u t   t h e   r e f e r e n c e d   k e y   i s   n o n - e x i s t e n t   t h e   d a t a   i s   a l s o   e m p t y .   F o r   e x a m p l e ,   t h e   f o l l o w i n g   P o d   s p e c i f i c a t i o n   m a r k s   a n   e n v i r o n m e n t   v a r i a b l e   f r o m   a   C o n f i g M a p   a s   o p t i o n a l :   a p i V e r s i o n :   v 1   k i n d :   P o d   m e t a d a t a :   n a m e :   d a p i - t e s t - p o d   s p e c :   c o n t a i n e r s :   -   n a m e :   t e s t - c o n t a i n e r   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   c o m m a n d :   [ " / b i n / s h " ,   " - c " ,   " e n v " ]   e n v :   -   n a m e :   S P E C I A L _ L E V E L _ K E Y   v a l u e F r o m :   c o n f i g M a p K e y R e f :   n a m e :   a - c o n f i g   k e y :   a k e y   o p t i o n a l :   t r u e   #   m a r k   t h e   v a r i a b l e   a s   o p t i o n a l   r e s t a r t P o l i c y :   N e v e r   I f   y o u   r u n   t h i s   p o d ,   a n d   t h e r e   i s   n o   C o n f i g M a p   n a m e d   a - c o n f i g ,   t h e   o u t p u t   i s   e m p t y .   I f   y o u   r u n   t h i s   p o d ,   a n d   t h e r e   i s   a   C o n f i g M a p   n a m e d   a - c o n f i g   b u t   t h a t   C o n f i g M a p   d o e s n ' t   h a v e   a   k e y   n a m e d   a k e y ,   t h e   o u t p u t   i s   a l s o   e m p t y .   I f   y o u   d o   s e t   a   v a l u e   f o r   a k e y   i n


Question: What is Restrictions?

Answer: Y o u   m u s t   c r e a t e   t h e   C o n f i g M a p   o b j e c t   b e f o r e   y o u   r e f e r e n c e   i t   i n   a   P o d   s p e c i f i c a t i o n .   A l t e r n a t i v e l y ,   m a r k   t h e   C o n f i g M a p   r e f e r e n c e   a s   o p t i o n a l   i n   t h e   P o d   s p e c   ( s e e   O p t i o n a l   C o n f i g M a p s ) .   I f   y o u   r e f e r e n c e   a   C o n f i g M a p   t h a t   d o e s n ' t   e x i s t   a n d   y o u   d o n ' t   m a r k   t h e   r e f e r e n c e   a s   o p t i o n a l ,   t h e   P o d   w o n ' t   s t a r t .   S i m i l a r l y ,   r e f e r e n c e s   t o   k e y s   t h a t   d o n ' t   e x i s t   i n   t h e   C o n f i g M a p   w i l l   a l s o   p r e v e n t   t h e   P o d   f r o m   s t a r t i n g ,   u n l e s s   y o u   m a r k   t h e   k e y   r e f e r e n c e s   a s   o p t i o n a l . I f   y o u   u s e   e n v F r o m   t o   d e f i n e   e n v i r o n m e n t   v a r i a b l e s   f r o m   C o n f i g M a p s ,   k e y s   t h a t   a r e   c o n s i d e r e d   i n v a l i d   w i l l   b e   s k i p p e d .   T h e   p o d   w i l l   b e   a l l o w e d   t o   s t a r t ,   b u t   t h e   i n v a l i d   n a m e s   w i l l   b e   r e c o r d e d   i n   t h e   e v e n t   l o g   ( I n v a l i d V a r i a b l e N a m e s ) .   T h e   l o g   m e s s a g e   l i s t s   e a c h   s k i p p e d   k e y .   F o r   e x a m p l e : k u b e c t l   g e t   e v e n t s   T h e   o u t p u t   i s   s i m i l a r   t o   t h i s : L A S T S E E N   F I R S T S E E N   C O U N T   N A M E   K I N D   S U B O B J E C T   T Y P E   R E A S O N   S O U R C E   M E S S A G E   0 s   0 s   1   d a p i - t e s t - p o d   P o d   W a r n i n g   I n v a l i d E n v i r o n m e n t V a r i a b l e N a m e s   { k u b e l e t ,   1 2 7 . 0 . 0 . 1 }   K e y s   [ 1 b a d k e y ,   2 a l s o b a d ]   f r o m   t h e   E n v F r o m   c o n f i g M a p   d e f a u


Question: What is Cleaning up?

Answer: D e l e t e   t h e   C o n f i g M a p s   a n d   P o d s   t h a t   y o u   m a d e :   k u b e c t l   d e l e t e   c o n f i g m a p s / g a m e - c o n f i g   c o n f i g m a p s / g a m e - c o n f i g - 2   c o n f i g m a p s / g a m e - c o n f i g - 3   \   c o n f i g m a p s / g a m e - c o n f i g - e n v - f i l e   k u b e c t l   d e l e t e   p o d   d a p i - t e s t - p o d   - - n o w   #   Y o u   m i g h t   a l r e a d y   h a v e   r e m o v e d   t h e   n e x t   s e t   k u b e c t l   d e l e t e   c o n f i g m a p s / s p e c i a l - c o n f i g   c o n f i g m a p s / e n v - c o n f i g   k u b e c t l   d e l e t e   c o n f i g m a p   - l   ' g a m e - c o n f i g   i n   ( c o n f i g - 4 , c o n f i g - 5 ) '   R e m o v e   t h e   k u s t o m i z a t i o n . y a m l   f i l e   t h a t   y o u   u s e d   t o   g e n e r a t e   t h e   C o n f i g M a p :   r m   k u s t o m i z a t i o n . y a m l   I f   y o u   c r e a t e d   a   d i r e c t o r y   c o n f i g u r e - p o d - c o n t a i n e r   a n d   n o   l o n g e r   n e e d   i t ,   y o u   s h o u l d   r e m o v e   t h a t   t o o ,   o r   m o v e   i t   i n t o   t h e   t r a s h   c a n   /   d e l e t e d   f i l e s   l o c a t i o n .   r m   - r   c o n f i g u r e - p o d - c o n t a i n e r


Question: What is What's next?

Answer: F o l l o w   a   r e a l   w o r l d   e x a m p l e   o f   C o n f i g u r i n g   R e d i s   u s i n g   a   C o n f i g M a p . F o l l o w   a n   e x a m p l e   o f   U p d a t i n g   c o n f i g u r a t i o n   v i a   a   C o n f i g M a p .


Question: What is Configure Service Accounts for Pods?

Answer: Configure Service Accounts for PodsKubernetes offers two distinct ways for clients that run within your cluster, or that otherwise have a relationship to your cluster's control plane to authenticate to the API server.A service account provides an identity for processes that run in a Pod, and maps to a ServiceAccount object. When you authenticate to the API server, you identify yourself as a particular user. Kubernetes recognises the concept of a user, however, Kubernetes itself does not have a User API.This task guide is about ServiceAccounts, which do exist in the Kubernetes API. The guide shows you some ways to configure ServiceAccounts for Pods.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 KubernetesUse the default service account to access the API serverWhen Pods contact the API server, Pods authenticate as a particular ServiceAccount (for example, default). There is always at least one ServiceAccount in each namespace.Every Kubernetes namespace contains at least one ServiceAccount: the default ServiceAccount for that namespace, named default. If you do not specify a ServiceAccount when you create a Pod, Kubernetes automatically assigns the ServiceAccount named default in that namespace.You can fetch the details for a Pod you have created. For example:kubectl get pods/<podname> -o yaml In the output, you see a field spec.serviceAccountName. Kubernetes automatically sets that value if you don't specify it when you create a Pod.An application running inside a Pod can access the Kubernetes API using automatically mounted service account credentials. See accessing the Cluster to learn more.When a Pod authenticates as a ServiceAccount, its level of access depends on the authorization plugin and policy in use.The API credentials are automatically revoked when the Pod is deleted, even if finalizers are in place. In particular, the API credentials are revoked 60 seconds beyond the .metadata.deletionTimestamp set on the Pod (the deletion timestamp is typically the time that the delete request was accepted plus the Pod's termination grace period).Opt out of API credential automountingIf you don't want the kubelet to automatically mount a ServiceAccount's API credentials, you can opt out of the default behavior. You can opt out of automounting API credentials on /var/run/secrets/kubernetes.io/serviceaccount/token for a service account by setting automountServiceAccountToken: false on the ServiceAccount:For example:apiVersion: v1 kind: ServiceAccount metadata: name: build-robot automountServiceAccountToken: false ... You can also opt out of automounting API credentials for a par