Question: What is Foreground cascading deletion?

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


Question: What is Background cascading deletion?

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


Question: What is Orphaned dependents?

Answer: W h e n   K u b e r n e t e s   d e l e t e s   a n   o w n e r   o b j e c t ,   t h e   d e p e n d e n t s   l e f t   b e h i n d   a r e   c a l l e d   o r p h a n   o b j e c t s .   B y   d e f a u l t ,   K u b e r n e t e s   d e l e t e s   d e p e n d e n t   o b j e c t s .   T o   l e a r n   h o w   t o   o v e r r i d e   t h i s   b e h a v i o u r ,   s e e   D e l e t e   o w n e r   o b j e c t s   a n d   o r p h a n   d e p e n d e n t s .


Question: What is Garbage collection of unused containers and images?

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


Question: What is Container image lifecycle?

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


Question: What is Garbage collection for unused container images?

Answer: A s   a   b e t a   f e a t u r e ,   y o u   c a n   s p e c i f y   t h e   m a x i m u m   t i m e   a   l o c a l   i m a g e   c a n   b e   u n u s e d   f o r ,   r e g a r d l e s s   o f   d i s k   u s a g e .   T h i s   i s   a   k u b e l e t   s e t t i n g   t h a t   y o u   c o n f i g u r e   f o r   e a c h   n o d e .   T o   c o n f i g u r e   t h e   s e t t i n g ,   y o u   n e e d   t o   s e t   a   v a l u e   f o r   t h e   i m a g e M a x i m u m G C A g e   f i e l d   i n   t h e   k u b e l e t   c o n f i g u r a t i o n   f i l e .   T h e   v a l u e   i s   s p e c i f i e d   a s   a   K u b e r n e t e s   d u r a t i o n .   S e e   d u r a t i o n   i n   t h e   g l o s s a r y   f o r   m o r e   d e t a i l s .   F o r   e x a m p l e ,   y o u   c a n   s e t   t h e   c o n f i g u r a t i o n   f i e l d   t o   1 2 h 4 5 m ,   w h i c h   m e a n s   1 2   h o u r s   a n d   4 5   m i n u t e s .


Question: What is Container garbage collection?

Answer: T h e   k u b e l e t   g a r b a g e   c o l l e c t s   u n u s e d   c o n t a i n e r s   b a s e d   o n   t h e   f o l l o w i n g   v a r i a b l e s ,   w h i c h   y o u   c a n   d e f i n e :   M i n A g e :   t h e   m i n i m u m   a g e   a t   w h i c h   t h e   k u b e l e t   c a n   g a r b a g e   c o l l e c t   a   c o n t a i n e r .   D i s a b l e   b y   s e t t i n g   t o   0 . M a x P e r P o d C o n t a i n e r :   t h e   m a x i m u m   n u m b e r   o f   d e a d   c o n t a i n e r s   e a c h   P o d   c a n   h a v e .   D i s a b l e   b y   s e t t i n g   t o   l e s s   t h a n   0 . M a x C o n t a i n e r s :   t h e   m a x i m u m   n u m b e r   o f   d e a d   c o n t a i n e r s   t h e   c l u s t e r   c a n   h a v e .   D i s a b l e   b y   s e t t i n g   t o   l e s s   t h a n   0 .   I n   a d d i t i o n   t o   t h e s e   v a r i a b l e s ,   t h e   k u b e l e t   g a r b a g e   c o l l e c t s   u n i d e n t i f i e d   a n d   d e l e t e d   c o n t a i n e r s ,   t y p i c a l l y   s t a r t i n g   w i t h   t h e   o l d e s t   f i r s t .   M a x P e r P o d C o n t a i n e r   a n d   M a x C o n t a i n e r s   m a y   p o t e n t i a l l y   c o n f l i c t   w i t h   e a c h   o t h e r   i n   s i t u a t i o n s   w h e r e   r e t a i n i n g   t h e   m a x i m u m   n u m b e r   o f   c o n t a i n e r s   p e r   P o d   ( M a x P e r P o d C o n t a i n e r )   w o u l d   g o   o u t s i d e   t h e   a l l o w a b l e   t o t a l   o f   g l o b a l   d e a d   c o n t a i n e r s   ( M a x C o n t a i n e r s ) .   I n   t h i s   s i t u a t i o n ,   t h e   k u b e l e t   a d j u s t s   M a x P e r P o d C o n t a i n e r   t o   a d d r e s s   t h e   c o n f l i c t .   A   w o r s t - c a s e   s c e n a r i o   w o u l d   b e   t o   d o w n g r a d e   M a x P e r P o d C o n t a i n e r   t o   1   a n d   e v i c t   t h e   o l d e s t   c o n t a i n e r s .


Question: What is Configuring garbage collection?

Answer: Y o u   c a n   t u n e   g a r b a g e   c o l l e c t i o n   o f   r e s o u r c e s   b y   c o n f i g u r i n g   o p t i o n s   s p e c i f i c   t o   t h e   c o n t r o l l e r s   m a n a g i n g   t h o s e   r e s o u r c e s .   T h e   f o l l o w i n g   p a g e s   s h o w   y o u   h o w   t o   c o n f i g u r e   g a r b a g e   c o l l e c t i o n :   C o n f i g u r i n g   c a s c a d i n g   d e l e t i o n   o f   K u b e r n e t e s   o b j e c t s C o n f i g u r i n g   c l e a n u p   o f   f i n i s h e d   J o b s


Question: What is What's next?

Answer: L e a r n   m o r e   a b o u t   o w n e r s h i p   o f   K u b e r n e t e s   o b j e c t s . L e a r n   m o r e   a b o u t   K u b e r n e t e s   f i n a l i z e r s . L e a r n   a b o u t   t h e   T T L   c o n t r o l l e r   t h a t   c l e a n s   u p   f i n i s h e d   J o b s .


Question: What is Parallel Processing using Expansions?

Answer: Parallel Processing using ExpansionsThis task demonstrates running multiple Jobs based on a common template. You can use this approach to process batches of work in parallel.For this example there are only three items: apple, banana, and cherry. The sample Jobs process each item by printing a string then pausing.See using Jobs in real workloads to learn about how this pattern fits more realistic use cases.Before you beginYou should be familiar with the basic, non-parallel, use of Job.You 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 KubernetesFor basic templating you need the command-line utility sed.To follow the advanced templating example, you need a working installation of Python, and the Jinja2 template library for Python.Once you have Python set up, you can install Jinja2 by running:pip install --user jinja2 Create Jobs based on a templateFirst, download the following template of a Job to a file called job-tmpl.yaml. Here's what you'll download:application/job/job-tmpl.yaml apiVersion: batch/v1 kind: Job metadata: name: process-item-$ITEM labels: jobgroup: jobexample spec: template: metadata: name: jobexample labels: jobgroup: jobexample spec: containers: - name: c image: busybox:1.28 command: ["sh", "-c", "echo Processing item $ITEM && sleep 5"] restartPolicy: Never # Use curl to download job-tmpl.yaml curl -L -s -O https://k8s.io/examples/application/job/job-tmpl.yaml The file you downloaded is not yet a valid Kubernetes manifest. Instead that template is a YAML representation of a Job object with some placeholders that need to be filled in before it can be used. The $ITEM syntax is not meaningful to Kubernetes.Create manifests from the templateThe following shell snippet uses sed to replace the string $ITEM with the loop variable, writing into a temporary directory named jobs. Run this now:# Expand the template into multiple files, one for each item to be processed. mkdir ./jobs for i in apple banana cherry do cat job-tmpl.yaml | sed "s/\$ITEM/$i/" > ./jobs/job-$i.yaml done Check if it worked:ls jobs/ The output is similar to this:job-apple.yaml job-banana.yaml job-cherry.yaml You could use any type of template language (for example: Jinja2; ERB), or write a program to generate the Job manifests.Create Jobs from the manifestsNext, create all the Jobs with one kubectl command:kubectl create -f ./jobs The output is similar to this:job.batch/process-item-apple created job.batch/process-item-banana created job.batch/process-item-cherry created Now, check on the jobs:kubectl get jobs -l jobgroup=jobexample The output is similar to this:NAME COMPLETIONS DURATION AGE process-item-apple 1/


Question: How does Parallel Processing using Expansions work?

Answer: Parallel Processing using ExpansionsThis task demonstrates running multiple Jobs based on a common template. You can use this approach to process batches of work in parallel.For this example there are only three items: apple, banana, and cherry. The sample Jobs process each item by printing a string then pausing.See using Jobs in real workloads to learn about how this pattern fits more realistic use cases.Before you beginYou should be familiar with the basic, non-parallel, use of Job.You 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 KubernetesFor basic templating you need the command-line utility sed.To follow the advanced templating example, you need a working installation of Python, and the Jinja2 template library for Python.Once you have Python set up, you can install Jinja2 by running:pip install --user jinja2 Create Jobs based on a templateFirst, download the following template of a Job to a file called job-tmpl.yaml. Here's what you'll download:application/job/job-tmpl.yaml apiVersion: batch/v1 kind: Job metadata: name: process-item-$ITEM labels: jobgroup: jobexample spec: template: metadata: name: jobexample labels: jobgroup: jobexample spec: containers: - name: c image: busybox:1.28 command: ["sh", "-c", "echo Processing item $ITEM && sleep 5"] restartPolicy: Never # Use curl to download job-tmpl.yaml curl -L -s -O https://k8s.io/examples/application/job/job-tmpl.yaml The file you downloaded is not yet a valid Kubernetes manifest. Instead that template is a YAML representation of a Job object with some placeholders that need to be filled in before it can be used. The $ITEM syntax is not meaningful to Kubernetes.Create manifests from the templateThe following shell snippet uses sed to replace the string $ITEM with the loop variable, writing into a temporary directory named jobs. Run this now:# Expand the template into multiple files, one for each item to be processed. mkdir ./jobs for i in apple banana cherry do cat job-tmpl.yaml | sed "s/\$ITEM/$i/" > ./jobs/job-$i.yaml done Check if it worked:ls jobs/ The output is similar to this:job-apple.yaml job-banana.yaml job-cherry.yaml You could use any type of template language (for example: Jinja2; ERB), or write a program to generate the Job manifests.Create Jobs from the manifestsNext, create all the Jobs with one kubectl command:kubectl create -f ./jobs The output is similar to this:job.batch/process-item-apple created job.batch/process-item-banana created job.batch/process-item-cherry created Now, check on the jobs:kubectl get jobs -l jobgroup=jobexample The output is similar to this:NAME COMPLETIONS DURATION AGE process-item-apple 1/


Question: When would you use Parallel Processing using Expansions?

Answer: Parallel Processing using ExpansionsThis task demonstrates running multiple Jobs based on a common template. You can use this approach to process batches of work in parallel.For this example there are only three items: apple, banana, and cherry. The sample Jobs process each item by printing a string then pausing.See using Jobs in real workloads to learn about how this pattern fits more realistic use cases.Before you beginYou should be familiar with the basic, non-parallel, use of Job.You 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 KubernetesFor basic templating you need the command-line utility sed.To follow the advanced templating example, you need a working installation of Python, and the Jinja2 template library for Python.Once you have Python set up, you can install Jinja2 by running:pip install --user jinja2 Create Jobs based on a templateFirst, download the following template of a Job to a file called job-tmpl.yaml. Here's what you'll download:application/job/job-tmpl.yaml apiVersion: batch/v1 kind: Job metadata: name: process-item-$ITEM labels: jobgroup: jobexample spec: template: metadata: name: jobexample labels: jobgroup: jobexample spec: containers: - name: c image: busybox:1.28 command: ["sh", "-c", "echo Processing item $ITEM && sleep 5"] restartPolicy: Never # Use curl to download job-tmpl.yaml curl -L -s -O https://k8s.io/examples/application/job/job-tmpl.yaml The file you downloaded is not yet a valid Kubernetes manifest. Instead that template is a YAML representation of a Job object with some placeholders that need to be filled in before it can be used. The $ITEM syntax is not meaningful to Kubernetes.Create manifests from the templateThe following shell snippet uses sed to replace the string $ITEM with the loop variable, writing into a temporary directory named jobs. Run this now:# Expand the template into multiple files, one for each item to be processed. mkdir ./jobs for i in apple banana cherry do cat job-tmpl.yaml | sed "s/\$ITEM/$i/" > ./jobs/job-$i.yaml done Check if it worked:ls jobs/ The output is similar to this:job-apple.yaml job-banana.yaml job-cherry.yaml You could use any type of template language (for example: Jinja2; ERB), or write a program to generate the Job manifests.Create Jobs from the manifestsNext, create all the Jobs with one kubectl command:kubectl create -f ./jobs The output is similar to this:job.batch/process-item-apple created job.batch/process-item-banana created job.batch/process-item-cherry created Now, check on the jobs:kubectl get jobs -l jobgroup=jobexample The output is similar to this:NAME COMPLETIONS DURATION AGE process-item-apple 1/


Question: What are the benefits of Parallel Processing using Expansions?

Answer: Parallel Processing using ExpansionsThis task demonstrates running multiple Jobs based on a common template. You can use this approach to process batches of work in parallel.For this example there are only three items: apple, banana, and cherry. The sample Jobs process each item by printing a string then pausing.See using Jobs in real workloads to learn about how this pattern fits more realistic use cases.Before you beginYou should be familiar with the basic, non-parallel, use of Job.You 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 KubernetesFor basic templating you need the command-line utility sed.To follow the advanced templating example, you need a working installation of Python, and the Jinja2 template library for Python.Once you have Python set up, you can install Jinja2 by running:pip install --user jinja2 Create Jobs based on a templateFirst, download the following template of a Job to a file called job-tmpl.yaml. Here's what you'll download:application/job/job-tmpl.yaml apiVersion: batch/v1 kind: Job metadata: name: process-item-$ITEM labels: jobgroup: jobexample spec: template: metadata: name: jobexample labels: jobgroup: jobexample spec: containers: - name: c image: busybox:1.28 command: ["sh", "-c", "echo Processing item $ITEM && sleep 5"] restartPolicy: Never # Use curl to download job-tmpl.yaml curl -L -s -O https://k8s.io/examples/application/job/job-tmpl.yaml The file you downloaded is not yet a valid Kubernetes manifest. Instead that template is a YAML representation of a Job object with some placeholders that need to be filled in before it can be used. The $ITEM syntax is not meaningful to Kubernetes.Create manifests from the templateThe following shell snippet uses sed to replace the string $ITEM with the loop variable, writing into a temporary directory named jobs. Run this now:# Expand the template into multiple files, one for each item to be processed. mkdir ./jobs for i in apple banana cherry do cat job-tmpl.yaml | sed "s/\$ITEM/$i/" > ./jobs/job-$i.yaml done Check if it worked:ls jobs/ The output is similar to this:job-apple.yaml job-banana.yaml job-cherry.yaml You could use any type of template language (for example: Jinja2; ERB), or write a program to generate the Job manifests.Create Jobs from the manifestsNext, create all the Jobs with one kubectl command:kubectl create -f ./jobs The output is similar to this:job.batch/process-item-apple created job.batch/process-item-banana created job.batch/process-item-cherry created Now, check on the jobs:kubectl get jobs -l jobgroup=jobexample The output is similar to this:NAME COMPLETIONS DURATION AGE process-item-apple 1/


Question: What is Parallel Processing using Expansions?

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


Question: What is Before you begin?

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


Question: What is Create Jobs based on a template?

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


Question: What is Create manifests from the template?

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


Question: What is Create Jobs from the manifests?

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


Question: What is Clean up?

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


Question: What is Use advanced template parameters?

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


Question: What is Clean up?

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


Question: What is Using Jobs in real workloads?

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


Question: What is Labels on Jobs and Pods?

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


Question: What is Alternatives?

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


Question: What is Configure Multiple Schedulers?

Answer: Configure Multiple SchedulersKubernetes ships with a default scheduler that is described here. If the default scheduler does not suit your needs you can implement your own scheduler. Moreover, you can even run multiple schedulers simultaneously alongside the default scheduler and instruct Kubernetes what scheduler to use for each of your pods. Let's learn how to run multiple schedulers in Kubernetes with an example.A detailed description of how to implement a scheduler is outside the scope of this document. Please refer to the kube-scheduler implementation in pkg/scheduler in the Kubernetes source directory for a canonical example.Before you beginYou need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. It is recommended to run this tutorial on a cluster with at least two nodes that are not acting as control plane hosts. If you do not already have a cluster, you can create one by using minikube or you can use one of these Kubernetes playgrounds:iximiuz LabsKillercodaKodeKloudPlay with KubernetesTo check the version, enter kubectl version.Package the schedulerPackage your scheduler binary into a container image. For the purposes of this example, you can use the default scheduler (kube-scheduler) as your second scheduler. Clone the Kubernetes source code from GitHub and build the source.git clone https://github.com/kubernetes/kubernetes.git cd kubernetes make Create a container image containing the kube-scheduler binary. Here is the Dockerfile to build the image:FROM busybox ADD ./_output/local/bin/linux/amd64/kube-scheduler /usr/local/bin/kube-scheduler Save the file as Dockerfile, build the image and push it to a registry. This example pushes the image to Google Container Registry (GCR). For more details, please read the GCR documentation. Alternatively you can also use the docker hub. For more details refer to the docker hub documentation.docker build -t gcr.io/my-gcp-project/my-kube-scheduler:1.0 . # The image name and the repository gcloud docker -- push gcr.io/my-gcp-project/my-kube-scheduler:1.0 # used in here is just an example Define a Kubernetes Deployment for the schedulerNow that you have your scheduler in a container image, create a pod configuration for it and run it in your Kubernetes cluster. But instead of creating a pod directly in the cluster, you can use a Deployment for this example. A Deployment manages a Replica Set which in turn manages the pods, thereby making the scheduler resilient to failures. Here is the deployment config. Save it as my-scheduler.yaml:admin/sched/my-scheduler.yaml apiVersion: v1 kind: ServiceAccount metadata: name: my-scheduler namespace: kube-system --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: my-scheduler-as-kube-scheduler subjects: - kind: ServiceAccount name: my-scheduler namespace: kube-system roleRef: kind: ClusterRole name: system:kube-scheduler apiGroup: rbac.authorization.k8s.io --- apiV


Question: How does Configure Multiple Schedulers work?

Answer: Configure Multiple SchedulersKubernetes ships with a default scheduler that is described here. If the default scheduler does not suit your needs you can implement your own scheduler. Moreover, you can even run multiple schedulers simultaneously alongside the default scheduler and instruct Kubernetes what scheduler to use for each of your pods. Let's learn how to run multiple schedulers in Kubernetes with an example.A detailed description of how to implement a scheduler is outside the scope of this document. Please refer to the kube-scheduler implementation in pkg/scheduler in the Kubernetes source directory for a canonical example.Before you beginYou need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. It is recommended to run this tutorial on a cluster with at least two nodes that are not acting as control plane hosts. If you do not already have a cluster, you can create one by using minikube or you can use one of these Kubernetes playgrounds:iximiuz LabsKillercodaKodeKloudPlay with KubernetesTo check the version, enter kubectl version.Package the schedulerPackage your scheduler binary into a container image. For the purposes of this example, you can use the default scheduler (kube-scheduler) as your second scheduler. Clone the Kubernetes source code from GitHub and build the source.git clone https://github.com/kubernetes/kubernetes.git cd kubernetes make Create a container image containing the kube-scheduler binary. Here is the Dockerfile to build the image:FROM busybox ADD ./_output/local/bin/linux/amd64/kube-scheduler /usr/local/bin/kube-scheduler Save the file as Dockerfile, build the image and push it to a registry. This example pushes the image to Google Container Registry (GCR). For more details, please read the GCR documentation. Alternatively you can also use the docker hub. For more details refer to the docker hub documentation.docker build -t gcr.io/my-gcp-project/my-kube-scheduler:1.0 . # The image name and the repository gcloud docker -- push gcr.io/my-gcp-project/my-kube-scheduler:1.0 # used in here is just an example Define a Kubernetes Deployment for the schedulerNow that you have your scheduler in a container image, create a pod configuration for it and run it in your Kubernetes cluster. But instead of creating a pod directly in the cluster, you can use a Deployment for this example. A Deployment manages a Replica Set which in turn manages the pods, thereby making the scheduler resilient to failures. Here is the deployment config. Save it as my-scheduler.yaml:admin/sched/my-scheduler.yaml apiVersion: v1 kind: ServiceAccount metadata: name: my-scheduler namespace: kube-system --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: my-scheduler-as-kube-scheduler subjects: - kind: ServiceAccount name: my-scheduler namespace: kube-system roleRef: kind: ClusterRole name: system:kube-scheduler apiGroup: rbac.authorization.k8s.io --- apiV


Question: When would you use Configure Multiple Schedulers?

Answer: Configure Multiple SchedulersKubernetes ships with a default scheduler that is described here. If the default scheduler does not suit your needs you can implement your own scheduler. Moreover, you can even run multiple schedulers simultaneously alongside the default scheduler and instruct Kubernetes what scheduler to use for each of your pods. Let's learn how to run multiple schedulers in Kubernetes with an example.A detailed description of how to implement a scheduler is outside the scope of this document. Please refer to the kube-scheduler implementation in pkg/scheduler in the Kubernetes source directory for a canonical example.Before you beginYou need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. It is recommended to run this tutorial on a cluster with at least two nodes that are not acting as control plane hosts. If you do not already have a cluster, you can create one by using minikube or you can use one of these Kubernetes playgrounds:iximiuz LabsKillercodaKodeKloudPlay with KubernetesTo check the version, enter kubectl version.Package the schedulerPackage your scheduler binary into a container image. For the purposes of this example, you can use the default scheduler (kube-scheduler) as your second scheduler. Clone the Kubernetes source code from GitHub and build the source.git clone https://github.com/kubernetes/kubernetes.git cd kubernetes make Create a container image containing the kube-scheduler binary. Here is the Dockerfile to build the image:FROM busybox ADD ./_output/local/bin/linux/amd64/kube-scheduler /usr/local/bin/kube-scheduler Save the file as Dockerfile, build the image and push it to a registry. This example pushes the image to Google Container Registry (GCR). For more details, please read the GCR documentation. Alternatively you can also use the docker hub. For more details refer to the docker hub documentation.docker build -t gcr.io/my-gcp-project/my-kube-scheduler:1.0 . # The image name and the repository gcloud docker -- push gcr.io/my-gcp-project/my-kube-scheduler:1.0 # used in here is just an example Define a Kubernetes Deployment for the schedulerNow that you have your scheduler in a container image, create a pod configuration for it and run it in your Kubernetes cluster. But instead of creating a pod directly in the cluster, you can use a Deployment for this example. A Deployment manages a Replica Set which in turn manages the pods, thereby making the scheduler resilient to failures. Here is the deployment config. Save it as my-scheduler.yaml:admin/sched/my-scheduler.yaml apiVersion: v1 kind: ServiceAccount metadata: name: my-scheduler namespace: kube-system --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: my-scheduler-as-kube-scheduler subjects: - kind: ServiceAccount name: my-scheduler namespace: kube-system roleRef: kind: ClusterRole name: system:kube-scheduler apiGroup: rbac.authorization.k8s.io --- apiV


Question: What are the benefits of Configure Multiple Schedulers?

Answer: Configure Multiple SchedulersKubernetes ships with a default scheduler that is described here. If the default scheduler does not suit your needs you can implement your own scheduler. Moreover, you can even run multiple schedulers simultaneously alongside the default scheduler and instruct Kubernetes what scheduler to use for each of your pods. Let's learn how to run multiple schedulers in Kubernetes with an example.A detailed description of how to implement a scheduler is outside the scope of this document. Please refer to the kube-scheduler implementation in pkg/scheduler in the Kubernetes source directory for a canonical example.Before you beginYou need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. It is recommended to run this tutorial on a cluster with at least two nodes that are not acting as control plane hosts. If you do not already have a cluster, you can create one by using minikube or you can use one of these Kubernetes playgrounds:iximiuz LabsKillercodaKodeKloudPlay with KubernetesTo check the version, enter kubectl version.Package the schedulerPackage your scheduler binary into a container image. For the purposes of this example, you can use the default scheduler (kube-scheduler) as your second scheduler. Clone the Kubernetes source code from GitHub and build the source.git clone https://github.com/kubernetes/kubernetes.git cd kubernetes make Create a container image containing the kube-scheduler binary. Here is the Dockerfile to build the image:FROM busybox ADD ./_output/local/bin/linux/amd64/kube-scheduler /usr/local/bin/kube-scheduler Save the file as Dockerfile, build the image and push it to a registry. This example pushes the image to Google Container Registry (GCR). For more details, please read the GCR documentation. Alternatively you can also use the docker hub. For more details refer to the docker hub documentation.docker build -t gcr.io/my-gcp-project/my-kube-scheduler:1.0 . # The image name and the repository gcloud docker -- push gcr.io/my-gcp-project/my-kube-scheduler:1.0 # used in here is just an example Define a Kubernetes Deployment for the schedulerNow that you have your scheduler in a container image, create a pod configuration for it and run it in your Kubernetes cluster. But instead of creating a pod directly in the cluster, you can use a Deployment for this example. A Deployment manages a Replica Set which in turn manages the pods, thereby making the scheduler resilient to failures. Here is the deployment config. Save it as my-scheduler.yaml:admin/sched/my-scheduler.yaml apiVersion: v1 kind: ServiceAccount metadata: name: my-scheduler namespace: kube-system --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: my-scheduler-as-kube-scheduler subjects: - kind: ServiceAccount name: my-scheduler namespace: kube-system roleRef: kind: ClusterRole name: system:kube-scheduler apiGroup: rbac.authorization.k8s.io --- apiV


Question: What is Configure Multiple Schedulers?

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


Question: What is Before you begin?

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


Question: What is Package the scheduler?

Answer: P a c k a g e   y o u r   s c h e d u l e r   b i n a r y   i n t o   a   c o n t a i n e r   i m a g e .   F o r   t h e   p u r p o s e s   o f   t h i s   e x a m p l e ,   y o u   c a n   u s e   t h e   d e f a u l t   s c h e d u l e r   ( k u b e - s c h e d u l e r )   a s   y o u r   s e c o n d   s c h e d u l e r .   C l o n e   t h e   K u b e r n e t e s   s o u r c e   c o d e   f r o m   G i t H u b   a n d   b u i l d   t h e   s o u r c e .   g i t   c l o n e   h t t p s : / / g i t h u b . c o m / k u b e r n e t e s / k u b e r n e t e s . g i t   c d   k u b e r n e t e s   m a k e   C r e a t e   a   c o n t a i n e r   i m a g e   c o n t a i n i n g   t h e   k u b e - s c h e d u l e r   b i n a r y .   H e r e   i s   t h e   D o c k e r f i l e   t o   b u i l d   t h e   i m a g e :   F R O M   b u s y b o x   A D D   . / _ o u t p u t / l o c a l / b i n / l i n u x / a m d 6 4 / k u b e - s c h e d u l e r   / u s r / l o c a l / b i n / k u b e - s c h e d u l e r   S a v e   t h e   f i l e   a s   D o c k e r f i l e ,   b u i l d   t h e   i m a g e   a n d   p u s h   i t   t o   a   r e g i s t r y .   T h i s   e x a m p l e   p u s h e s   t h e   i m a g e   t o   G o o g l e   C o n t a i n e r   R e g i s t r y   ( G C R ) .   F o r   m o r e   d e t a i l s ,   p l e a s e   r e a d   t h e   G C R   d o c u m e n t a t i o n .   A l t e r n a t i v e l y   y o u   c a n   a l s o   u s e   t h e   d o c k e r   h u b .   F o r   m o r e   d e t a i l s   r e f e r   t o   t h e   d o c k e r   h u b   d o c u m e n t a t i o n .   d o c k e r   b u i l d   - t   g c r . i o / m y - g c p - p r o j e c t / m y - k u b e - s c h e d u l e r : 1 . 0   .   #   T h e   i m a g e   n a m e   a n d   t h e   r e p o s i t o r y   g c l o u d   d o c k e r   - -   p u s h   g c r . i o / m y - g c p - p r o j e c t / m y - k u b e - s c h e d u l e r : 1 . 0   #   u s e d   i n   h e r e   i s   j u s t   a n   e x a m p l e


Question: What is Define a Kubernetes Deployment for the scheduler?

Answer: N o w   t h a t   y o u   h a v e   y o u r   s c h e d u l e r   i n   a   c o n t a i n e r   i m a g e ,   c r e a t e   a   p o d   c o n f i g u r a t i o n   f o r   i t   a n d   r u n   i t   i n   y o u r   K u b e r n e t e s   c l u s t e r .   B u t   i n s t e a d   o f   c r e a t i n g   a   p o d   d i r e c t l y   i n   t h e   c l u s t e r ,   y o u   c a n   u s e   a   D e p l o y m e n t   f o r   t h i s   e x a m p l e .   A   D e p l o y m e n t   m a n a g e s   a   R e p l i c a   S e t   w h i c h   i n   t u r n   m a n a g e s   t h e   p o d s ,   t h e r e b y   m a k i n g   t h e   s c h e d u l e r   r e s i l i e n t   t o   f a i l u r e s .   H e r e   i s   t h e   d e p l o y m e n t   c o n f i g .   S a v e   i t   a s   m y - s c h e d u l e r . y a m l :   a p i V e r s i o n :   v 1   k i n d :   S e r v i c e A c c o u n t   m e t a d a t a :   n a m e :   m y - s c h e d u l e r   n a m e s p a c e :   k u b e - s y s t e m   - - -   a p i V e r s i o n :   r b a c . a u t h o r i z a t i o n . k 8 s . i o / v 1   k i n d :   C l u s t e r R o l e B i n d i n g   m e t a d a t a :   n a m e :   m y - s c h e d u l e r - a s - k u b e - s c h e d u l e r   s u b j e c t s :   -   k i n d :   S e r v i c e A c c o u n t   n a m e :   m y - s c h e d u l e r   n a m e s p a c e :   k u b e - s y s t e m   r o l e R e f :   k i n d :   C l u s t e r R o l e   n a m e :   s y s t e m : k u b e - s c h e d u l e r   a p i G r o u p :   r b a c . a u t h o r i z a t i o n . k 8 s . i o   - - -   a p i V e r s i o n :   r b a c . a u t h o r i z a t i o n . k 8 s . i o / v 1   k i n d :   C l u s t e r R o l e B i n d i n g   m e t a d a t a :   n a m e :   m y - s c h e d u l e r - a s - v o l u m e - s c h e d u l e r   s u b j e c t s :   -   k i n d :   S e r v i c e A c c o u n t   n a m e :   m y - s c h e d u l e r   n a m e s p a c e :   k u b e - s y s t e m   r o l e R e f :   k i n d :   C l u s t e r R o l e   n a


Question: What is Note:?

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


Question: What is Run the second scheduler in the cluster?

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


Question: What is Enable leader election?

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


Question: What is Note:?

Answer: I f   R B A C   i s   e n a b l e d   o n   y o u r   c l u s t e r ,   y o u   m u s t   u p d a t e   t h e   s y s t e m : k u b e - s c h e d u l e r   c l u s t e r   r o l e .   A d d   y o u r   s c h e d u l e r   n a m e   t o   t h e   r e s o u r c e N a m e s   o f   t h e   r u l e   a p p l i e d   f o r   e n d p o i n t s   a n d   l e a s e s   r e s o u r c e s ,   a s   i n   t h e   f o l l o w i n g   e x a m p l e :   k u b e c t l   e d i t   c l u s t e r r o l e   s y s t e m : k u b e - s c h e d u l e r   a p i V e r s i o n :   r b a c . a u t h o r i z a t i o n . k 8 s . i o / v 1   k i n d :   C l u s t e r R o l e   m e t a d a t a :   a n n o t a t i o n s :   r b a c . a u t h o r i z a t i o n . k u b e r n e t e s . i o / a u t o u p d a t e :   " t r u e "   l a b e l s :   k u b e r n e t e s . i o / b o o t s t r a p p i n g :   r b a c - d e f a u l t s   n a m e :   s y s t e m : k u b e - s c h e d u l e r   r u l e s :   -   a p i G r o u p s :   -   c o o r d i n a t i o n . k 8 s . i o   r e s o u r c e s :   -   l e a s e s   v e r b s :   -   c r e a t e   -   a p i G r o u p s :   -   c o o r d i n a t i o n . k 8 s . i o   r e s o u r c e N a m e s :   -   k u b e - s c h e d u l e r   -   m y - s c h e d u l e r   r e s o u r c e s :   -   l e a s e s   v e r b s :   -   g e t   -   u p d a t e   -   a p i G r o u p s :   -   " "   r e s o u r c e N a m e s :   -   k u b e - s c h e d u l e r   -   m y - s c h e d u l e r   r e s o u r c e s :   -   e n d p o i n t s   v e r b s :   -   d e l e t e   -   g e t   -   p a t c h   -   u p d a t e


Question: What is Specify schedulers for pods?

Answer: N o w   t h a t   y o u r   s e c o n d   s c h e d u l e r   i s   r u n n i n g ,   c r e a t e   s o m e   p o d s ,   a n d   d i r e c t   t h e m   t o   b e   s c h e d u l e d   b y   e i t h e r   t h e   d e f a u l t   s c h e d u l e r   o r   t h e   o n e   y o u   d e p l o y e d .   I n   o r d e r   t o   s c h e d u l e   a   g i v e n   p o d   u s i n g   a   s p e c i f i c   s c h e d u l e r ,   s p e c i f y   t h e   n a m e   o f   t h e   s c h e d u l e r   i n   t h a t   p o d   s p e c .   L e t ' s   l o o k   a t   t h r e e   e x a m p l e s .   P o d   s p e c   w i t h o u t   a n y   s c h e d u l e r   n a m e a d m i n / s c h e d / p o d 1 . 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 :   n o - a n n o t a t i o n   l a b e l s :   n a m e :   m u l t i s c h e d u l e r - e x a m p l e   s p e c :   c o n t a i n e r s :   -   n a m e :   p o d - w i t h - n o - a n n o t a t i o n - 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 / p a u s e : 3 . 8 W h e n   n o   s c h e d u l e r   n a m e   i s   s u p p l i e d ,   t h e   p o d   i s   a u t o m a t i c a l l y   s c h e d u l e d   u s i n g   t h e   d e f a u l t - s c h e d u l e r . S a v e   t h i s   f i l e   a s   p o d 1 . y a m l   a n d   s u b m i t   i t   t o   t h e   K u b e r n e t e s   c l u s t e r . k u b e c t l   c r e a t e   - f   p o d 1 . y a m l   P o d   s p e c   w i t h   d e f a u l t - s c h e d u l e r a d m i n / s c h e d / p o d 2 . y a m l   a p i V e r s i o n :   v 1   k i n d :   P o d   m e t a d a t a :   n a m e :   a n n o t a t i o n - d e f a u l t - s c h e d u l e r   l a b e l s :   n a m e :   m u l t i s c h e d u l e r - e x a m p l e   s p e c :   s c h e d u l e r N a m e :   d e f a u l t - s c h e d u l e r   c o n t a i n e r s :   -   n a m e :   p o d - w i t h - d e f a u l t - a n n o t a t i o n - c o n t a i n e r   i m a g e :   r e g i s t r y


Question: What is Verifying that the pods were scheduled using the desired schedulers?

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


Question: What is Operating etcd clusters for Kubernetes?

Answer: Operating etcd clusters for Kubernetesetcd is a consistent and highly-available key value store used as Kubernetes' backing store for all cluster data.If your Kubernetes cluster uses etcd as its backing store, make sure you have a back up plan for the data.You can find in-depth information about etcd in the official documentation.Before you beginBefore you follow steps in this page to deploy, manage, back up or restore etcd, you need to understand the typical expectations for operating an etcd cluster. Refer to the etcd documentation for more context.Key details include:The minimum recommended etcd versions to run in production are 3.4.22+ and 3.5.6+.etcd is a leader-based distributed system. Ensure that the leader periodically send heartbeats on time to all followers to keep the cluster stable.You should run etcd as a cluster with an odd number of members.Aim to ensure that no resource starvation occurs.Performance and stability of the cluster is sensitive to network and disk I/O. Any resource starvation can lead to heartbeat timeout, causing instability of the cluster. An unstable etcd indicates that no leader is elected. Under such circumstances, a cluster cannot make any changes to its current state, which implies no new pods can be scheduled.Resource requirements for etcdOperating etcd with limited resources is suitable only for testing purposes. For deploying in production, advanced hardware configuration is required. Before deploying etcd in production, see resource requirement reference.Keeping etcd clusters stable is critical to the stability of Kubernetes clusters. Therefore, run etcd clusters on dedicated machines or isolated environments for guaranteed resource requirements.ToolsDepending on which specific outcome you're working on, you will need the etcdctl tool or the etcdutl tool (you may need both).Understanding etcdctl and etcdutletcdctl and etcdutl are command-line tools used to interact with etcd clusters, but they serve different purposes:etcdctl: This is the primary command-line client for interacting with etcd over a network. It is used for day-to-day operations such as managing keys and values, administering the cluster, checking health, and more.etcdutl: This is an administration utility designed to operate directly on etcd data files, including migrating data between etcd versions, defragmenting the database, restoring snapshots, and validating data consistency. For network operations, etcdctl should be used.For more information on etcdutl, you can refer to the etcd recovery documentation.Starting etcd clustersThis section covers starting a single-node and multi-node etcd cluster.This guide assumes that etcd is already installed.Single-node etcd clusterUse a single-node etcd cluster only for testing purposes.Run the following:etcd --listen-client-urls=http://$PRIVATE_IP:2379 \ --advertise-client-urls=http://$PRIVATE_IP:2379 Start the Kubernetes API server with the flag --etcd-servers=$PRIVATE_IP:2379.Make sure PRIVATE_IP


Question: How does Operating etcd clusters for Kubernetes work?

Answer: Operating etcd clusters for Kubernetesetcd is a consistent and highly-available key value store used as Kubernetes' backing store for all cluster data.If your Kubernetes cluster uses etcd as its backing store, make sure you have a back up plan for the data.You can find in-depth information about etcd in the official documentation.Before you beginBefore you follow steps in this page to deploy, manage, back up or restore etcd, you need to understand the typical expectations for operating an etcd cluster. Refer to the etcd documentation for more context.Key details include:The minimum recommended etcd versions to run in production are 3.4.22+ and 3.5.6+.etcd is a leader-based distributed system. Ensure that the leader periodically send heartbeats on time to all followers to keep the cluster stable.You should run etcd as a cluster with an odd number of members.Aim to ensure that no resource starvation occurs.Performance and stability of the cluster is sensitive to network and disk I/O. Any resource starvation can lead to heartbeat timeout, causing instability of the cluster. An unstable etcd indicates that no leader is elected. Under such circumstances, a cluster cannot make any changes to its current state, which implies no new pods can be scheduled.Resource requirements for etcdOperating etcd with limited resources is suitable only for testing purposes. For deploying in production, advanced hardware configuration is required. Before deploying etcd in production, see resource requirement reference.Keeping etcd clusters stable is critical to the stability of Kubernetes clusters. Therefore, run etcd clusters on dedicated machines or isolated environments for guaranteed resource requirements.ToolsDepending on which specific outcome you're working on, you will need the etcdctl tool or the etcdutl tool (you may need both).Understanding etcdctl and etcdutletcdctl and etcdutl are command-line tools used to interact with etcd clusters, but they serve different purposes:etcdctl: This is the primary command-line client for interacting with etcd over a network. It is used for day-to-day operations such as managing keys and values, administering the cluster, checking health, and more.etcdutl: This is an administration utility designed to operate directly on etcd data files, including migrating data between etcd versions, defragmenting the database, restoring snapshots, and validating data consistency. For network operations, etcdctl should be used.For more information on etcdutl, you can refer to the etcd recovery documentation.Starting etcd clustersThis section covers starting a single-node and multi-node etcd cluster.This guide assumes that etcd is already installed.Single-node etcd clusterUse a single-node etcd cluster only for testing purposes.Run the following:etcd --listen-client-urls=http://$PRIVATE_IP:2379 \ --advertise-client-urls=http://$PRIVATE_IP:2379 Start the Kubernetes API server with the flag --etcd-servers=$PRIVATE_IP:2379.Make sure PRIVATE_IP


Question: When would you use Operating etcd clusters for Kubernetes?

Answer: Operating etcd clusters for Kubernetesetcd is a consistent and highly-available key value store used as Kubernetes' backing store for all cluster data.If your Kubernetes cluster uses etcd as its backing store, make sure you have a back up plan for the data.You can find in-depth information about etcd in the official documentation.Before you beginBefore you follow steps in this page to deploy, manage, back up or restore etcd, you need to understand the typical expectations for operating an etcd cluster. Refer to the etcd documentation for more context.Key details include:The minimum recommended etcd versions to run in production are 3.4.22+ and 3.5.6+.etcd is a leader-based distributed system. Ensure that the leader periodically send heartbeats on time to all followers to keep the cluster stable.You should run etcd as a cluster with an odd number of members.Aim to ensure that no resource starvation occurs.Performance and stability of the cluster is sensitive to network and disk I/O. Any resource starvation can lead to heartbeat timeout, causing instability of the cluster. An unstable etcd indicates that no leader is elected. Under such circumstances, a cluster cannot make any changes to its current state, which implies no new pods can be scheduled.Resource requirements for etcdOperating etcd with limited resources is suitable only for testing purposes. For deploying in production, advanced hardware configuration is required. Before deploying etcd in production, see resource requirement reference.Keeping etcd clusters stable is critical to the stability of Kubernetes clusters. Therefore, run etcd clusters on dedicated machines or isolated environments for guaranteed resource requirements.ToolsDepending on which specific outcome you're working on, you will need the etcdctl tool or the etcdutl tool (you may need both).Understanding etcdctl and etcdutletcdctl and etcdutl are command-line tools used to interact with etcd clusters, but they serve different purposes:etcdctl: This is the primary command-line client for interacting with etcd over a network. It is used for day-to-day operations such as managing keys and values, administering the cluster, checking health, and more.etcdutl: This is an administration utility designed to operate directly on etcd data files, including migrating data between etcd versions, defragmenting the database, restoring snapshots, and validating data consistency. For network operations, etcdctl should be used.For more information on etcdutl, you can refer to the etcd recovery documentation.Starting etcd clustersThis section covers starting a single-node and multi-node etcd cluster.This guide assumes that etcd is already installed.Single-node etcd clusterUse a single-node etcd cluster only for testing purposes.Run the following:etcd --listen-client-urls=http://$PRIVATE_IP:2379 \ --advertise-client-urls=http://$PRIVATE_IP:2379 Start the Kubernetes API server with the flag --etcd-servers=$PRIVATE_IP:2379.Make sure PRIVATE_IP


Question: What are the benefits of Operating etcd clusters for Kubernetes?

Answer: Operating etcd clusters for Kubernetesetcd is a consistent and highly-available key value store used as Kubernetes' backing store for all cluster data.If your Kubernetes cluster uses etcd as its backing store, make sure you have a back up plan for the data.You can find in-depth information about etcd in the official documentation.Before you beginBefore you follow steps in this page to deploy, manage, back up or restore etcd, you need to understand the typical expectations for operating an etcd cluster. Refer to the etcd documentation for more context.Key details include:The minimum recommended etcd versions to run in production are 3.4.22+ and 3.5.6+.etcd is a leader-based distributed system. Ensure that the leader periodically send heartbeats on time to all followers to keep the cluster stable.You should run etcd as a cluster with an odd number of members.Aim to ensure that no resource starvation occurs.Performance and stability of the cluster is sensitive to network and disk I/O. Any resource starvation can lead to heartbeat timeout, causing instability of the cluster. An unstable etcd indicates that no leader is elected. Under such circumstances, a cluster cannot make any changes to its current state, which implies no new pods can be scheduled.Resource requirements for etcdOperating etcd with limited resources is suitable only for testing purposes. For deploying in production, advanced hardware configuration is required. Before deploying etcd in production, see resource requirement reference.Keeping etcd clusters stable is critical to the stability of Kubernetes clusters. Therefore, run etcd clusters on dedicated machines or isolated environments for guaranteed resource requirements.ToolsDepending on which specific outcome you're working on, you will need the etcdctl tool or the etcdutl tool (you may need both).Understanding etcdctl and etcdutletcdctl and etcdutl are command-line tools used to interact with etcd clusters, but they serve different purposes:etcdctl: This is the primary command-line client for interacting with etcd over a network. It is used for day-to-day operations such as managing keys and values, administering the cluster, checking health, and more.etcdutl: This is an administration utility designed to operate directly on etcd data files, including migrating data between etcd versions, defragmenting the database, restoring snapshots, and validating data consistency. For network operations, etcdctl should be used.For more information on etcdutl, you can refer to the etcd recovery documentation.Starting etcd clustersThis section covers starting a single-node and multi-node etcd cluster.This guide assumes that etcd is already installed.Single-node etcd clusterUse a single-node etcd cluster only for testing purposes.Run the following:etcd --listen-client-urls=http://$PRIVATE_IP:2379 \ --advertise-client-urls=http://$PRIVATE_IP:2379 Start the Kubernetes API server with the flag --etcd-servers=$PRIVATE_IP:2379.Make sure PRIVATE_IP


Question: What is Operating etcd clusters for Kubernetes?

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


Question: What is Before you begin?

Answer: B e f o r e   y o u   f o l l o w   s t e p s   i n   t h i s   p a g e   t o   d e p l o y ,   m a n a g e ,   b a c k   u p   o r   r e s t o r e   e t c d ,   y o u   n e e d   t o   u n d e r s t a n d   t h e   t y p i c a l   e x p e c t a t i o n s   f o r   o p e r a t i n g   a n   e t c d   c l u s t e r .   R e f e r   t o   t h e   e t c d   d o c u m e n t a t i o n   f o r   m o r e   c o n t e x t .   K e y   d e t a i l s   i n c l u d e :   T h e   m i n i m u m   r e c o m m e n d e d   e t c d   v e r s i o n s   t o   r u n   i n   p r o d u c t i o n   a r e   3 . 4 . 2 2 +   a n d   3 . 5 . 6 + . e t c d   i s   a   l e a d e r - b a s e d   d i s t r i b u t e d   s y s t e m .   E n s u r e   t h a t   t h e   l e a d e r   p e r i o d i c a l l y   s e n d   h e a r t b e a t s   o n   t i m e   t o   a l l   f o l l o w e r s   t o   k e e p   t h e   c l u s t e r   s t a b l e . Y o u   s h o u l d   r u n   e t c d   a s   a   c l u s t e r   w i t h   a n   o d d   n u m b e r   o f   m e m b e r s . A i m   t o   e n s u r e   t h a t   n o   r e s o u r c e   s t a r v a t i o n   o c c u r s . P e r f o r m a n c e   a n d   s t a b i l i t y   o f   t h e   c l u s t e r   i s   s e n s i t i v e   t o   n e t w o r k   a n d   d i s k   I / O .   A n y   r e s o u r c e   s t a r v a t i o n   c a n   l e a d   t o   h e a r t b e a t   t i m e o u t ,   c a u s i n g   i n s t a b i l i t y   o f   t h e   c l u s t e r .   A n   u n s t a b l e   e t c d   i n d i c a t e s   t h a t   n o   l e a d e r   i s   e l e c t e d .   U n d e r   s u c h   c i r c u m s t a n c e s ,   a   c l u s t e r   c a n n o t   m a k e   a n y   c h a n g e s   t o   i t s   c u r r e n t   s t a t e ,   w h i c h   i m p l i e s   n o   n e w   p o d s   c a n   b e   s c h e d u l e d .   T h e   m i n i m u m   r e c o m m e n d e d   e t c d   v e r s i o n s   t o   r u n   i n   p r o d u c t i o n   a r e   3 . 4 . 2 2 +   a n d   3 . 5


Question: What is Resource requirements for etcd?

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


Question: What is Tools?

Answer: D e p e n d i n g   o n   w h i c h   s p e c i f i c   o u t c o m e   y o u ' r e   w o r k i n g   o n ,   y o u   w i l l   n e e d   t h e   e t c d c t l   t o o l   o r   t h e   e t c d u t l   t o o l   ( y o u   m a y   n e e d   b o t h ) .


Question: What is Understanding etcdctl and etcdutl?

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


Question: What is Starting etcd clusters?

Answer: T h i s   s e c t i o n   c o v e r s   s t a r t i n g   a   s i n g l e - n o d e   a n d   m u l t i - n o d e   e t c d   c l u s t e r .   T h i s   g u i d e   a s s u m e s   t h a t   e t c d   i s   a l r e a d y   i n s t a l l e d .


Question: What is Single-node etcd cluster?

Answer: U s e   a   s i n g l e - n o d e   e t c d   c l u s t e r   o n l y   f o r   t e s t i n g   p u r p o s e s .   R u n   t h e   f o l l o w i n g : e t c d   - - l i s t e n - c l i e n t - u r l s = h t t p : / / $ P R I V A T E _ I P : 2 3 7 9   \   - - a d v e r t i s e - c l i e n t - u r l s = h t t p : / / $ P R I V A T E _ I P : 2 3 7 9   S t a r t   t h e   K u b e r n e t e s   A P I   s e r v e r   w i t h   t h e   f l a g   - - e t c d - s e r v e r s = $ P R I V A T E _ I P : 2 3 7 9 . M a k e   s u r e   P R I V A T E _ I P   i s   s e t   t o   y o u r   e t c d   c l i e n t   I P .   R u n   t h e   f o l l o w i n g :   e t c d   - - l i s t e n - c l i e n t - u r l s = h t t p : / / $ P R I V A T E _ I P : 2 3 7 9   \   - - a d v e r t i s e - c l i e n t - u r l s = h t t p : / / $ P R I V A T E _ I P : 2 3 7 9   S t a r t   t h e   K u b e r n e t e s   A P I   s e r v e r   w i t h   t h e   f l a g   - - e t c d - s e r v e r s = $ P R I V A T E _ I P : 2 3 7 9 .   M a k e   s u r e   P R I V A T E _ I P   i s   s e t   t o   y o u r   e t c d   c l i e n t   I P .


Question: What is Multi-node etcd cluster?

Answer: F o r   d u r a b i l i t y   a n d   h i g h   a v a i l a b i l i t y ,   r u n   e t c d   a s   a   m u l t i - n o d e   c l u s t e r   i n   p r o d u c t i o n   a n d   b a c k   i t   u p   p e r i o d i c a l l y .   A   f i v e - m e m b e r   c l u s t e r   i s   r e c o m m e n d e d   i n   p r o d u c t i o n .   F o r   m o r e   i n f o r m a t i o n ,   s e e   F A Q   d o c u m e n t a t i o n .   A s   y o u ' r e   u s i n g   K u b e r n e t e s ,   y o u   h a v e   t h e   o p t i o n   t o   r u n   e t c d   a s   a   c o n t a i n e r   i n s i d e   o n e   o r   m o r e   P o d s .   T h e   k u b e a d m   t o o l   s e t s   u p   e t c d   s t a t i c   p o d s   b y   d e f a u l t ,   o r   y o u   c a n   d e p l o y   a   s e p a r a t e   c l u s t e r   a n d   i n s t r u c t   k u b e a d m   t o   u s e   t h a t   e t c d   c l u s t e r   a s   t h e   c o n t r o l   p l a n e ' s   b a c k i n g   s t o r e .   Y o u   c o n f i g u r e   a n   e t c d   c l u s t e r   e i t h e r   b y   s t a t i c   m e m b e r   i n f o r m a t i o n   o r   b y   d y n a m i c   d i s c o v e r y .   F o r   m o r e   i n f o r m a t i o n   o n   c l u s t e r i n g ,   s e e   e t c d   c l u s t e r i n g   d o c u m e n t a t i o n .   F o r   a n   e x a m p l e ,   c o n s i d e r   a   f i v e - m e m b e r   e t c d   c l u s t e r   r u n n i n g   w i t h   t h e   f o l l o w i n g   c l i e n t   U R L s :   h t t p : / / $ I P 1 : 2 3 7 9 ,   h t t p : / / $ I P 2 : 2 3 7 9 ,   h t t p : / / $ I P 3 : 2 3 7 9 ,   h t t p : / / $ I P 4 : 2 3 7 9 ,   a n d   h t t p : / / $ I P 5 : 2 3 7 9 .   T o   s t a r t   a   K u b e r n e t e s   A P I   s e r v e r :   R u n   t h e   f o l l o w i n g : e t c d   - - l i s t e n - c l i e n t - u r l s = h t t p : / / $ I P 1 : 2 3 7 9 , h t t p : / / $ I P 2 : 2 3 7 9 , h t t p : / / $ I P 3 : 2 3 7 9 , h t t p : / / $ I P 4 : 2 3 7 9 , h t t p : / / $ I P 5 : 2 3 7 9   - - a


Question: What is Multi-node etcd cluster with load balancer?

Answer: T o   r u n   a   l o a d   b a l a n c i n g   e t c d   c l u s t e r :   S e t   u p   a n   e t c d   c l u s t e r . C o n f i g u r e   a   l o a d   b a l a n c e r   i n   f r o n t   o f   t h e   e t c d   c l u s t e r .   F o r   e x a m p l e ,   l e t   t h e   a d d r e s s   o f   t h e   l o a d   b a l a n c e r   b e   $ L B . S t a r t   K u b e r n e t e s   A P I   S e r v e r s   w i t h   t h e   f l a g   - - e t c d - s e r v e r s = $ L B : 2 3 7 9 .


Question: What is Securing etcd clusters?

Answer: A c c e s s   t o   e t c d   i s   e q u i v a l e n t   t o   r o o t   p e r m i s s i o n   i n   t h e   c l u s t e r   s o   i d e a l l y   o n l y   t h e   A P I   s e r v e r   s h o u l d   h a v e   a c c e s s   t o   i t .   C o n s i d e r i n g   t h e   s e n s i t i v i t y   o f   t h e   d a t a ,   i t   i s   r e c o m m e n d e d   t o   g r a n t   p e r m i s s i o n   t o   o n l y   t h o s e   n o d e s   t h a t   r e q u i r e   a c c e s s   t o   e t c d   c l u s t e r s .   T o   s e c u r e   e t c d ,   e i t h e r   s e t   u p   f i r e w a l l   r u l e s   o r   u s e   t h e   s e c u r i t y   f e a t u r e s   p r o v i d e d   b y   e t c d .   e t c d   s e c u r i t y   f e a t u r e s   d e p e n d   o n   x 5 0 9   P u b l i c   K e y   I n f r a s t r u c t u r e   ( P K I ) .   T o   b e g i n ,   e s t a b l i s h   s e c u r e   c o m m u n i c a t i o n   c h a n n e l s   b y   g e n e r a t i n g   a   k e y   a n d   c e r t i f i c a t e   p a i r .   F o r   e x a m p l e ,   u s e   k e y   p a i r s   p e e r . k e y   a n d   p e e r . c e r t   f o r   s e c u r i n g   c o m m u n i c a t i o n   b e t w e e n   e t c d   m e m b e r s ,   a n d   c l i e n t . k e y   a n d   c l i e n t . c e r t   f o r   s e c u r i n g   c o m m u n i c a t i o n   b e t w e e n   e t c d   a n d   i t s   c l i e n t s .   S e e   t h e   e x a m p l e   s c r i p t s   p r o v i d e d   b y   t h e   e t c d   p r o j e c t   t o   g e n e r a t e   k e y   p a i r s   a n d   C A   f i l e s   f o r   c l i e n t   a u t h e n t i c a t i o n .


Question: What is Securing communication?

Answer: T o   c o n f i g u r e   e t c d   w i t h   s e c u r e   p e e r   c o m m u n i c a t i o n ,   s p e c i f y   f l a g s   - - p e e r - k e y - f i l e = p e e r . k e y   a n d   - - p e e r - c e r t - f i l e = p e e r . c e r t ,   a n d   u s e   H T T P S   a s   t h e   U R L   s c h e m a .   S i m i l a r l y ,   t o   c o n f i g u r e   e t c d   w i t h   s e c u r e   c l i e n t   c o m m u n i c a t i o n ,   s p e c i f y   f l a g s   - - k e y = k 8 s c l i e n t . k e y   a n d   - - c e r t = k 8 s c l i e n t . c e r t ,   a n d   u s e   H T T P S   a s   t h e   U R L   s c h e m a .   H e r e   i s   a n   e x a m p l e   o n   a   c l i e n t   c o m m a n d   t h a t   u s e s   s e c u r e   c o m m u n i c a t i o n :   E T C D C T L _ A P I = 3   e t c d c t l   - - e n d p o i n t s   1 0 . 2 . 0 . 9 : 2 3 7 9   \   - - c e r t = / e t c / k u b e r n e t e s / p k i / e t c d / s e r v e r . c r t   \   - - k e y = / e t c / k u b e r n e t e s / p k i / e t c d / s e r v e r . k e y   \   - - c a c e r t = / e t c / k u b e r n e t e s / p k i / e t c d / c a . c r t   \   m e m b e r   l i s t


Question: What is Limiting access of etcd clusters?

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


Question: What is Replacing a failed etcd member?

Answer: e t c d   c l u s t e r   a c h i e v e s   h i g h   a v a i l a b i l i t y   b y   t o l e r a t i n g   m i n o r   m e m b e r   f a i l u r e s .   H o w e v e r ,   t o   i m p r o v e   t h e   o v e r a l l   h e a l t h   o f   t h e   c l u s t e r ,   r e p l a c e   f a i l e d   m e m b e r s   i m m e d i a t e l y .   W h e n   m u l t i p l e   m e m b e r s   f a i l ,   r e p l a c e   t h e m   o n e   b y   o n e .   R e p l a c i n g   a   f a i l e d   m e m b e r   i n v o l v e s   t w o   s t e p s :   r e m o v i n g   t h e   f a i l e d   m e m b e r   a n d   a d d i n g   a   n e w   m e m b e r .   T h o u g h   e t c d   k e e p s   u n i q u e   m e m b e r   I D s   i n t e r n a l l y ,   i t   i s   r e c o m m e n d e d   t o   u s e   a   u n i q u e   n a m e   f o r   e a c h   m e m b e r   t o   a v o i d   h u m a n   e r r o r s .   F o r   e x a m p l e ,   c o n s i d e r   a   t h r e e - m e m b e r   e t c d   c l u s t e r .   L e t   t h e   U R L s   b e ,   m e m b e r 1 = h t t p : / / 1 0 . 0 . 0 . 1 ,   m e m b e r 2 = h t t p : / / 1 0 . 0 . 0 . 2 ,   a n d   m e m b e r 3 = h t t p : / / 1 0 . 0 . 0 . 3 .   W h e n   m e m b e r 1   f a i l s ,   r e p l a c e   i t   w i t h   m e m b e r 4 = h t t p : / / 1 0 . 0 . 0 . 4 .   G e t   t h e   m e m b e r   I D   o f   t h e   f a i l e d   m e m b e r 1 : e t c d c t l   - - e n d p o i n t s = h t t p : / / 1 0 . 0 . 0 . 2 , h t t p : / / 1 0 . 0 . 0 . 3   m e m b e r   l i s t   T h e   f o l l o w i n g   m e s s a g e   i s   d i s p l a y e d : 8 2 1 1 f 1 d 0 f 6 4 f 3 2 6 9 ,   s t a r t e d ,   m e m b e r 1 ,   h t t p : / / 1 0 . 0 . 0 . 1 : 2 3 8 0 ,   h t t p : / / 1 0 . 0 . 0 . 1 : 2 3 7 9   9 1 b c 3 c 3 9 8 f b 3 c 1 4 6 ,   s t a r t e d ,   m e m b e r 2 ,   h t t p : / / 1 0 . 0 . 0 . 2 : 2 3 8 0 ,   h t t p : / / 1 0 . 0 . 0 . 2 : 2 3 7 9   f d 4 2 2 3 7 9 f d a 5 0 e 4 8 ,   s t a r t e d ,   m e m b e r 3 ,   h t t p : / / 1 0 . 0 . 0 .


Question: What is Backing up an etcd cluster?

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


Question: What is Built-in snapshot?

Answer: e t c d   s u p p o r t s   b u i l t - i n   s n a p s h o t .   A   s n a p s h o t   m a y   e i t h e r   b e   c r e a t e d   f r o m   a   l i v e   m e m b e r   w i t h   t h e   e t c d c t l   s n a p s h o t   s a v e   c o m m a n d   o r   b y   c o p y i n g   t h e   m e m b e r / s n a p / d b   f i l e   f r o m   a n   e t c d   d a t a   d i r e c t o r y   t h a t   i s   n o t   c u r r e n t l y   u s e d   b y   a n   e t c d   p r o c e s s .   C r e a t i n g   t h e   s n a p s h o t   w i l l   n o t   a f f e c t   t h e   p e r f o r m a n c e   o f   t h e   m e m b e r .   B e l o w   i s   a n   e x a m p l e   f o r   c r e a t i n g   a   s n a p s h o t   o f   t h e   k e y s p a c e   s e r v e d   b y   $ E N D P O I N T   t o   t h e   f i l e   s n a p s h o t . d b :   E T C D C T L _ A P I = 3   e t c d c t l   - - e n d p o i n t s   $ E N D P O I N T   s n a p s h o t   s a v e   s n a p s h o t . d b   V e r i f y   t h e   s n a p s h o t :   T h e   b e l o w   e x a m p l e   d e p i c t s   t h e   u s a g e   o f   t h e   e t c d u t l   t o o l   f o r   v e r i f y i n g   a   s n a p s h o t : e t c d u t l   - - w r i t e - o u t = t a b l e   s n a p s h o t   s t a t u s   s n a p s h o t . d b   T h i s   s h o u l d   g e n e r a t e   a n   o u t p u t   r e s e m b l i n g   t h e   e x a m p l e   p r o v i d e d   b e l o w : + - - - - - - - - - - + - - - - - - - - - - + - - - - - - - - - - - - + - - - - - - - - - - - - +   |   H A S H   |   R E V I S I O N   |   T O T A L   K E Y S   |   T O T A L   S I Z E   |   + - - - - - - - - - - + - - - - - - - - - - + - - - - - - - - - - - - + - - - - - - - - - - - - +   |   f e 0 1 c f 5 7   |   1 0   |   7   |   2 . 1   M B   |   + - - - - - - - - - - + - - - - - - - - - - + - - - - - - - - - - - - + - - - - - - - - - - - - +   T h e   b e l o w   e x a m p l e   d e p i c t s   t h e   u s a g e   o f   t h e   e t c d u t l   t o o l   f o r   v e r i f y i


Question: What is Note:?

Answer: T h e   b e l o w   e x a m p l e   d e p i c t s   t h e   u s a g e   o f   t h e   e t c d c t l   t o o l   f o r   v e r i f y i n g   a   s n a p s h o t :   e x p o r t   E T C D C T L _ A P I = 3   e t c d c t l   - - w r i t e - o u t = t a b l e   s n a p s h o t   s t a t u s   s n a p s h o t . d b   T h i s   s h o u l d   g e n e r a t e   a n   o u t p u t   r e s e m b l i n g   t h e   e x a m p l e   p r o v i d e d   b e l o w :   D e p r e c a t e d :   U s e   ` e t c d u t l   s n a p s h o t   s t a t u s `   i n s t e a d .   + - - - - - - - - - - + - - - - - - - - - - + - - - - - - - - - - - - + - - - - - - - - - - - - +   |   H A S H   |   R E V I S I O N   |   T O T A L   K E Y S   |   T O T A L   S I Z E   |   + - - - - - - - - - - + - - - - - - - - - - + - - - - - - - - - - - - + - - - - - - - - - - - - +   |   f e 0 1 c f 5 7   |   1 0   |   7   |   2 . 1   M B   |   + - - - - - - - - - - + - - - - - - - - - - + - - - - - - - - - - - - + - - - - - - - - - - - - +


Question: What is Volume snapshot?

Answer: I f   e t c d   i s   r u n n i n g   o n   a   s t o r a g e   v o l u m e   t h a t   s u p p o r t s   b a c k u p ,   s u c h   a s   A m a z o n   E l a s t i c   B l o c k   S t o r e ,   b a c k   u p   e t c d   d a t a   b y   c r e a t i n g   a   s n a p s h o t   o f   t h e   s t o r a g e   v o l u m e .


Question: What is Snapshot using etcdctl options?

Answer: W e   c a n   a l s o   c r e a t e   t h e   s n a p s h o t   u s i n g   v a r i o u s   o p t i o n s   g i v e n   b y   e t c d c t l .   F o r   e x a m p l e :   E T C D C T L _ A P I = 3   e t c d c t l   - h   w i l l   l i s t   v a r i o u s   o p t i o n s   a v a i l a b l e   f r o m   e t c d c t l .   F o r   e x a m p l e ,   y o u   c a n   c r e a t e   a   s n a p s h o t   b y   s p e c i f y i n g   t h e   e n d p o i n t ,   c e r t i f i c a t e s   a n d   k e y   a s   s h o w n   b e l o w :   E T C D C T L _ A P I = 3   e t c d c t l   - - e n d p o i n t s = h t t p s : / / 1 2 7 . 0 . 0 . 1 : 2 3 7 9   \   - - c a c e r t = < t r u s t e d - c a - f i l e >   - - c e r t = < c e r t - f i l e >   - - k e y = < k e y - f i l e >   \   s n a p s h o t   s a v e   < b a c k u p - f i l e - l o c a t i o n >   w h e r e   t r u s t e d - c a - f i l e ,   c e r t - f i l e   a n d   k e y - f i l e   c a n   b e   o b t a i n e d   f r o m   t h e   d e s c r i p t i o n   o f   t h e   e t c d   P o d .