Question: What is Performing a Rolling Update?

Answer: Performing a Rolling UpdateObjectivesPerform a rolling update using kubectl.Updating an applicationRolling updates allow Deployments' update to take place with zero downtime by incrementally updating Pods instances with new ones.Users expect applications to be available all the time, and developers are expected to deploy new versions of them several times a day. In Kubernetes this is done with rolling updates. A rolling update allows a Deployment update to take place with zero downtime. It does this by incrementally replacing the current Pods with new ones. The new Pods are scheduled on Nodes with available resources, and Kubernetes waits for those new Pods to start before removing the old Pods.In the previous module we scaled our application to run multiple instances. This is a requirement for performing updates without affecting application availability. By default, the maximum number of Pods that can be unavailable during the update and the maximum number of new Pods that can be created, is one. Both options can be configured to either numbers or percentages (of Pods). In Kubernetes, updates are versioned and any Deployment update can be reverted to a previous (stable) version.Rolling updates overviewIf a Deployment is exposed publicly, the Service will load-balance the traffic only to available Pods during the update.Similar to application Scaling, if a Deployment is exposed publicly, the Service will load-balance the traffic only to available Pods during the update. An available Pod is an instance that is available to the users of the application.Rolling updates allow the following actions:Promote an application from one environment to another (via container image updates)Rollback to previous versionsContinuous Integration and Continuous Delivery of applications with zero downtimeIn the following interactive tutorial, we'll update our application to a new version, and also perform a rollback.Update the version of the appTo list your Deployments, run the get deployments subcommand:kubectl get deployments To list the running Pods, run the get pods subcommand:kubectl get pods To view the current image version of the app, run the describe pods subcommand and look for the Image field:kubectl describe pods To update the image of the application to version 2, use the set image subcommand, followed by the deployment name and the new image version:kubectl set image deployments/kubernetes-bootcamp kubernetes-bootcamp=docker.io/jocatalin/kubernetes-bootcamp:v2 The command notified the Deployment to use a different image for your app and initiated a rolling update. Check the status of the new Pods, and view the old one terminating with the get pods subcommand:kubectl get pods Verify an updateFirst, check that the service is running, as you might have deleted it in previous tutorial step, run describe services/kubernetes-bootcamp. If it's missing, you can create it again with:kubectl expose deployment/kubernetes-bootcamp --type="NodePort" --port 8080 Cre


Question: How does Performing a Rolling Update work?

Answer: Performing a Rolling UpdateObjectivesPerform a rolling update using kubectl.Updating an applicationRolling updates allow Deployments' update to take place with zero downtime by incrementally updating Pods instances with new ones.Users expect applications to be available all the time, and developers are expected to deploy new versions of them several times a day. In Kubernetes this is done with rolling updates. A rolling update allows a Deployment update to take place with zero downtime. It does this by incrementally replacing the current Pods with new ones. The new Pods are scheduled on Nodes with available resources, and Kubernetes waits for those new Pods to start before removing the old Pods.In the previous module we scaled our application to run multiple instances. This is a requirement for performing updates without affecting application availability. By default, the maximum number of Pods that can be unavailable during the update and the maximum number of new Pods that can be created, is one. Both options can be configured to either numbers or percentages (of Pods). In Kubernetes, updates are versioned and any Deployment update can be reverted to a previous (stable) version.Rolling updates overviewIf a Deployment is exposed publicly, the Service will load-balance the traffic only to available Pods during the update.Similar to application Scaling, if a Deployment is exposed publicly, the Service will load-balance the traffic only to available Pods during the update. An available Pod is an instance that is available to the users of the application.Rolling updates allow the following actions:Promote an application from one environment to another (via container image updates)Rollback to previous versionsContinuous Integration and Continuous Delivery of applications with zero downtimeIn the following interactive tutorial, we'll update our application to a new version, and also perform a rollback.Update the version of the appTo list your Deployments, run the get deployments subcommand:kubectl get deployments To list the running Pods, run the get pods subcommand:kubectl get pods To view the current image version of the app, run the describe pods subcommand and look for the Image field:kubectl describe pods To update the image of the application to version 2, use the set image subcommand, followed by the deployment name and the new image version:kubectl set image deployments/kubernetes-bootcamp kubernetes-bootcamp=docker.io/jocatalin/kubernetes-bootcamp:v2 The command notified the Deployment to use a different image for your app and initiated a rolling update. Check the status of the new Pods, and view the old one terminating with the get pods subcommand:kubectl get pods Verify an updateFirst, check that the service is running, as you might have deleted it in previous tutorial step, run describe services/kubernetes-bootcamp. If it's missing, you can create it again with:kubectl expose deployment/kubernetes-bootcamp --type="NodePort" --port 8080 Cre


Question: When would you use Performing a Rolling Update?

Answer: Performing a Rolling UpdateObjectivesPerform a rolling update using kubectl.Updating an applicationRolling updates allow Deployments' update to take place with zero downtime by incrementally updating Pods instances with new ones.Users expect applications to be available all the time, and developers are expected to deploy new versions of them several times a day. In Kubernetes this is done with rolling updates. A rolling update allows a Deployment update to take place with zero downtime. It does this by incrementally replacing the current Pods with new ones. The new Pods are scheduled on Nodes with available resources, and Kubernetes waits for those new Pods to start before removing the old Pods.In the previous module we scaled our application to run multiple instances. This is a requirement for performing updates without affecting application availability. By default, the maximum number of Pods that can be unavailable during the update and the maximum number of new Pods that can be created, is one. Both options can be configured to either numbers or percentages (of Pods). In Kubernetes, updates are versioned and any Deployment update can be reverted to a previous (stable) version.Rolling updates overviewIf a Deployment is exposed publicly, the Service will load-balance the traffic only to available Pods during the update.Similar to application Scaling, if a Deployment is exposed publicly, the Service will load-balance the traffic only to available Pods during the update. An available Pod is an instance that is available to the users of the application.Rolling updates allow the following actions:Promote an application from one environment to another (via container image updates)Rollback to previous versionsContinuous Integration and Continuous Delivery of applications with zero downtimeIn the following interactive tutorial, we'll update our application to a new version, and also perform a rollback.Update the version of the appTo list your Deployments, run the get deployments subcommand:kubectl get deployments To list the running Pods, run the get pods subcommand:kubectl get pods To view the current image version of the app, run the describe pods subcommand and look for the Image field:kubectl describe pods To update the image of the application to version 2, use the set image subcommand, followed by the deployment name and the new image version:kubectl set image deployments/kubernetes-bootcamp kubernetes-bootcamp=docker.io/jocatalin/kubernetes-bootcamp:v2 The command notified the Deployment to use a different image for your app and initiated a rolling update. Check the status of the new Pods, and view the old one terminating with the get pods subcommand:kubectl get pods Verify an updateFirst, check that the service is running, as you might have deleted it in previous tutorial step, run describe services/kubernetes-bootcamp. If it's missing, you can create it again with:kubectl expose deployment/kubernetes-bootcamp --type="NodePort" --port 8080 Cre


Question: What are the benefits of Performing a Rolling Update?

Answer: Performing a Rolling UpdateObjectivesPerform a rolling update using kubectl.Updating an applicationRolling updates allow Deployments' update to take place with zero downtime by incrementally updating Pods instances with new ones.Users expect applications to be available all the time, and developers are expected to deploy new versions of them several times a day. In Kubernetes this is done with rolling updates. A rolling update allows a Deployment update to take place with zero downtime. It does this by incrementally replacing the current Pods with new ones. The new Pods are scheduled on Nodes with available resources, and Kubernetes waits for those new Pods to start before removing the old Pods.In the previous module we scaled our application to run multiple instances. This is a requirement for performing updates without affecting application availability. By default, the maximum number of Pods that can be unavailable during the update and the maximum number of new Pods that can be created, is one. Both options can be configured to either numbers or percentages (of Pods). In Kubernetes, updates are versioned and any Deployment update can be reverted to a previous (stable) version.Rolling updates overviewIf a Deployment is exposed publicly, the Service will load-balance the traffic only to available Pods during the update.Similar to application Scaling, if a Deployment is exposed publicly, the Service will load-balance the traffic only to available Pods during the update. An available Pod is an instance that is available to the users of the application.Rolling updates allow the following actions:Promote an application from one environment to another (via container image updates)Rollback to previous versionsContinuous Integration and Continuous Delivery of applications with zero downtimeIn the following interactive tutorial, we'll update our application to a new version, and also perform a rollback.Update the version of the appTo list your Deployments, run the get deployments subcommand:kubectl get deployments To list the running Pods, run the get pods subcommand:kubectl get pods To view the current image version of the app, run the describe pods subcommand and look for the Image field:kubectl describe pods To update the image of the application to version 2, use the set image subcommand, followed by the deployment name and the new image version:kubectl set image deployments/kubernetes-bootcamp kubernetes-bootcamp=docker.io/jocatalin/kubernetes-bootcamp:v2 The command notified the Deployment to use a different image for your app and initiated a rolling update. Check the status of the new Pods, and view the old one terminating with the get pods subcommand:kubectl get pods Verify an updateFirst, check that the service is running, as you might have deleted it in previous tutorial step, run describe services/kubernetes-bootcamp. If it's missing, you can create it again with:kubectl expose deployment/kubernetes-bootcamp --type="NodePort" --port 8080 Cre


Question: What is Objectives?

Answer: P e r f o r m   a   r o l l i n g   u p d a t e   u s i n g   k u b e c t l .


Question: What is Updating an application?

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


Question: What is Rolling updates overview?

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


Question: What is Update the version of the app?

Answer: T o   l i s t   y o u r   D e p l o y m e n t s ,   r u n   t h e   g e t   d e p l o y m e n t s   s u b c o m m a n d :   k u b e c t l   g e t   d e p l o y m e n t s   T o   l i s t   t h e   r u n n i n g   P o d s ,   r u n   t h e   g e t   p o d s   s u b c o m m a n d :   k u b e c t l   g e t   p o d s   T o   v i e w   t h e   c u r r e n t   i m a g e   v e r s i o n   o f   t h e   a p p ,   r u n   t h e   d e s c r i b e   p o d s   s u b c o m m a n d   a n d   l o o k   f o r   t h e   I m a g e   f i e l d :   k u b e c t l   d e s c r i b e   p o d s   T o   u p d a t e   t h e   i m a g e   o f   t h e   a p p l i c a t i o n   t o   v e r s i o n   2 ,   u s e   t h e   s e t   i m a g e   s u b c o m m a n d ,   f o l l o w e d   b y   t h e   d e p l o y m e n t   n a m e   a n d   t h e   n e w   i m a g e   v e r s i o n :   k u b e c t l   s e t   i m a g e   d e p l o y m e n t s / k u b e r n e t e s - b o o t c a m p   k u b e r n e t e s - b o o t c a m p = d o c k e r . i o / j o c a t a l i n / k u b e r n e t e s - b o o t c a m p : v 2   T h e   c o m m a n d   n o t i f i e d   t h e   D e p l o y m e n t   t o   u s e   a   d i f f e r e n t   i m a g e   f o r   y o u r   a p p   a n d   i n i t i a t e d   a   r o l l i n g   u p d a t e .   C h e c k   t h e   s t a t u s   o f   t h e   n e w   P o d s ,   a n d   v i e w   t h e   o l d   o n e   t e r m i n a t i n g   w i t h   t h e   g e t   p o d s   s u b c o m m a n d :   k u b e c t l   g e t   p o d s


Question: What is Verify an update?

Answer: F i r s t ,   c h e c k   t h a t   t h e   s e r v i c e   i s   r u n n i n g ,   a s   y o u   m i g h t   h a v e   d e l e t e d   i t   i n   p r e v i o u s   t u t o r i a l   s t e p ,   r u n   d e s c r i b e   s e r v i c e s / k u b e r n e t e s - b o o t c a m p .   I f   i t ' s   m i s s i n g ,   y o u   c a n   c r e a t e   i t   a g a i n   w i t h :   k u b e c t l   e x p o s e   d e p l o y m e n t / k u b e r n e t e s - b o o t c a m p   - - t y p e = " N o d e P o r t "   - - p o r t   8 0 8 0   C r e a t e   a n   e n v i r o n m e n t   v a r i a b l e   c a l l e d   N O D E _ P O R T   t h a t   h a s   t h e   v a l u e   o f   t h e   N o d e   p o r t   a s s i g n e d :   e x p o r t   N O D E _ P O R T = " $ ( k u b e c t l   g e t   s e r v i c e s / k u b e r n e t e s - b o o t c a m p   - o   g o - t e m p l a t e = ' { { ( i n d e x   . s p e c . p o r t s   0 ) . n o d e P o r t } } ' ) "   e c h o   " N O D E _ P O R T = $ N O D E _ P O R T "   N e x t ,   d o   a   c u r l   t o   t h e   e x p o s e d   I P   a n d   p o r t :   c u r l   h t t p : / / " $ ( m i n i k u b e   i p ) : $ N O D E _ P O R T "   E v e r y   t i m e   y o u   r u n   t h e   c u r l   c o m m a n d ,   y o u   w i l l   h i t   a   d i f f e r e n t   P o d .   N o t i c e   t h a t   a l l   P o d s   a r e   n o w   r u n n i n g   t h e   l a t e s t   v e r s i o n   ( v 2 ) .   Y o u   c a n   a l s o   c o n f i r m   t h e   u p d a t e   b y   r u n n i n g   t h e   r o l l o u t   s t a t u s   s u b c o m m a n d :   k u b e c t l   r o l l o u t   s t a t u s   d e p l o y m e n t s / k u b e r n e t e s - b o o t c a m p   T o   v i e w   t h e   c u r r e n t   i m a g e   v e r s i o n   o f   t h e   a p p ,   r u n   t h e   d e s c r i b e   p o d s   s u b c o m m a n d :   k u b e c t l   d e s c r i b e   p o d s   I n   t h e   I m a g e   f i e l d   o f   t h e   o u t p u t ,   v e r i f y   t h a t   y o u   a r e   r


Question: What is Roll back an update?

Answer: L e t ’ s   p e r f o r m   a n o t h e r   u p d a t e ,   a n d   t r y   t o   d e p l o y   a n   i m a g e   t a g g e d   w i t h   v 1 0 :   k u b e c t l   s e t   i m a g e   d e p l o y m e n t s / k u b e r n e t e s - b o o t c a m p   k u b e r n e t e s - b o o t c a m p = g c r . i o / g o o g l e - s a m p l e s / k u b e r n e t e s - b o o t c a m p : v 1 0   U s e   g e t   d e p l o y m e n t s   t o   s e e   t h e   s t a t u s   o f   t h e   d e p l o y m e n t :   k u b e c t l   g e t   d e p l o y m e n t s   N o t i c e   t h a t   t h e   o u t p u t   d o e s n ' t   l i s t   t h e   d e s i r e d   n u m b e r   o f   a v a i l a b l e   P o d s .   R u n   t h e   g e t   p o d s   s u b c o m m a n d   t o   l i s t   a l l   P o d s :   k u b e c t l   g e t   p o d s   N o t i c e   t h a t   s o m e   o f   t h e   P o d s   h a v e   a   s t a t u s   o f   I m a g e P u l l B a c k O f f .   T o   g e t   m o r e   i n s i g h t   i n t o   t h e   p r o b l e m ,   r u n   t h e   d e s c r i b e   p o d s   s u b c o m m a n d :   k u b e c t l   d e s c r i b e   p o d s   I n   t h e   E v e n t s   s e c t i o n   o f   t h e   o u t p u t   f o r   t h e   a f f e c t e d   P o d s ,   n o t i c e   t h a t   t h e   v 1 0   i m a g e   v e r s i o n   d i d   n o t   e x i s t   i n   t h e   r e p o s i t o r y .   T o   r o l l   b a c k   t h e   d e p l o y m e n t   t o   y o u r   l a s t   w o r k i n g   v e r s i o n ,   u s e   t h e   r o l l o u t   u n d o   s u b c o m m a n d :   k u b e c t l   r o l l o u t   u n d o   d e p l o y m e n t s / k u b e r n e t e s - b o o t c a m p   T h e   r o l l o u t   u n d o   c o m m a n d   r e v e r t s   t h e   d e p l o y m e n t   t o   t h e   p r e v i o u s   k n o w n   s t a t e   ( v 2   o f   t h e   i m a g e ) .   U p d a t e s   a r e   v e r s i o n e d   a n d   y o u   c a n   r e v e r t   t o   a n y   p r e v i o u s l y   k n o w n   s t a t


Question: What is What's next?

Answer: L e a r n   m o r e   a b o u t   D e p l o y m e n t s .


Question: What is Safely Drain a Node?

Answer: Safely Drain a NodeThis page shows how to safely drain a node, optionally respecting the PodDisruptionBudget you have defined.Before you beginThis task assumes that you have met the following prerequisites:You do not require your applications to be highly available during the node drain, orYou have read about the PodDisruptionBudget concept, and have configured PodDisruptionBudgets for applications that need them.(Optional) Configure a disruption budgetTo ensure that your workloads remain available during maintenance, you can configure a PodDisruptionBudget.If availability is important for any applications that run or could run on the node(s) that you are draining, configure a PodDisruptionBudgets first and then continue following this guide.It is recommended to set AlwaysAllow Unhealthy Pod Eviction Policy to your PodDisruptionBudgets to support eviction of misbehaving applications during a node drain. The default behavior is to wait for the application pods to become healthy before the drain can proceed.Use kubectl drain to remove a node from serviceYou can use kubectl drain to safely evict all of your pods from a node before you perform maintenance on the node (e.g. kernel upgrade, hardware maintenance, etc.). Safe evictions allow the pod's containers to gracefully terminate and will respect the PodDisruptionBudgets you have specified.Note:By default kubectl drain ignores certain system pods on the node that cannot be killed; see the kubectl drain documentation for more details.When kubectl drain returns successfully, that indicates that all of the pods (except the ones excluded as described in the previous paragraph) have been safely evicted (respecting the desired graceful termination period, and respecting the PodDisruptionBudget you have defined). It is then safe to bring down the node by powering down its physical machine or, if running on a cloud platform, deleting its virtual machine.Note:If any new Pods tolerate the node.kubernetes.io/unschedulable taint, then those Pods might be scheduled to the node you have drained. Avoid tolerating that taint other than for DaemonSets.If you or another API user directly set the nodeName field for a Pod (bypassing the scheduler), then the Pod is bound to the specified node and will run there, even though you have drained that node and marked it unschedulable.First, identify the name of the node you wish to drain. You can list all of the nodes in your cluster withkubectl get nodes Next, tell Kubernetes to drain the node:kubectl drain --ignore-daemonsets <node name> If there are pods managed by a DaemonSet, you will need to specify --ignore-daemonsets with kubectl to successfully drain the node. The kubectl drain subcommand on its own does not actually drain a node of its DaemonSet pods: the DaemonSet controller (part of the control plane) immediately replaces missing Pods with new equivalent Pods. The DaemonSet controller also creates Pods that ignore unschedulable taints, which allows the new Pods t


Question: How does Safely Drain a Node work?

Answer: Safely Drain a NodeThis page shows how to safely drain a node, optionally respecting the PodDisruptionBudget you have defined.Before you beginThis task assumes that you have met the following prerequisites:You do not require your applications to be highly available during the node drain, orYou have read about the PodDisruptionBudget concept, and have configured PodDisruptionBudgets for applications that need them.(Optional) Configure a disruption budgetTo ensure that your workloads remain available during maintenance, you can configure a PodDisruptionBudget.If availability is important for any applications that run or could run on the node(s) that you are draining, configure a PodDisruptionBudgets first and then continue following this guide.It is recommended to set AlwaysAllow Unhealthy Pod Eviction Policy to your PodDisruptionBudgets to support eviction of misbehaving applications during a node drain. The default behavior is to wait for the application pods to become healthy before the drain can proceed.Use kubectl drain to remove a node from serviceYou can use kubectl drain to safely evict all of your pods from a node before you perform maintenance on the node (e.g. kernel upgrade, hardware maintenance, etc.). Safe evictions allow the pod's containers to gracefully terminate and will respect the PodDisruptionBudgets you have specified.Note:By default kubectl drain ignores certain system pods on the node that cannot be killed; see the kubectl drain documentation for more details.When kubectl drain returns successfully, that indicates that all of the pods (except the ones excluded as described in the previous paragraph) have been safely evicted (respecting the desired graceful termination period, and respecting the PodDisruptionBudget you have defined). It is then safe to bring down the node by powering down its physical machine or, if running on a cloud platform, deleting its virtual machine.Note:If any new Pods tolerate the node.kubernetes.io/unschedulable taint, then those Pods might be scheduled to the node you have drained. Avoid tolerating that taint other than for DaemonSets.If you or another API user directly set the nodeName field for a Pod (bypassing the scheduler), then the Pod is bound to the specified node and will run there, even though you have drained that node and marked it unschedulable.First, identify the name of the node you wish to drain. You can list all of the nodes in your cluster withkubectl get nodes Next, tell Kubernetes to drain the node:kubectl drain --ignore-daemonsets <node name> If there are pods managed by a DaemonSet, you will need to specify --ignore-daemonsets with kubectl to successfully drain the node. The kubectl drain subcommand on its own does not actually drain a node of its DaemonSet pods: the DaemonSet controller (part of the control plane) immediately replaces missing Pods with new equivalent Pods. The DaemonSet controller also creates Pods that ignore unschedulable taints, which allows the new Pods t


Question: When would you use Safely Drain a Node?

Answer: Safely Drain a NodeThis page shows how to safely drain a node, optionally respecting the PodDisruptionBudget you have defined.Before you beginThis task assumes that you have met the following prerequisites:You do not require your applications to be highly available during the node drain, orYou have read about the PodDisruptionBudget concept, and have configured PodDisruptionBudgets for applications that need them.(Optional) Configure a disruption budgetTo ensure that your workloads remain available during maintenance, you can configure a PodDisruptionBudget.If availability is important for any applications that run or could run on the node(s) that you are draining, configure a PodDisruptionBudgets first and then continue following this guide.It is recommended to set AlwaysAllow Unhealthy Pod Eviction Policy to your PodDisruptionBudgets to support eviction of misbehaving applications during a node drain. The default behavior is to wait for the application pods to become healthy before the drain can proceed.Use kubectl drain to remove a node from serviceYou can use kubectl drain to safely evict all of your pods from a node before you perform maintenance on the node (e.g. kernel upgrade, hardware maintenance, etc.). Safe evictions allow the pod's containers to gracefully terminate and will respect the PodDisruptionBudgets you have specified.Note:By default kubectl drain ignores certain system pods on the node that cannot be killed; see the kubectl drain documentation for more details.When kubectl drain returns successfully, that indicates that all of the pods (except the ones excluded as described in the previous paragraph) have been safely evicted (respecting the desired graceful termination period, and respecting the PodDisruptionBudget you have defined). It is then safe to bring down the node by powering down its physical machine or, if running on a cloud platform, deleting its virtual machine.Note:If any new Pods tolerate the node.kubernetes.io/unschedulable taint, then those Pods might be scheduled to the node you have drained. Avoid tolerating that taint other than for DaemonSets.If you or another API user directly set the nodeName field for a Pod (bypassing the scheduler), then the Pod is bound to the specified node and will run there, even though you have drained that node and marked it unschedulable.First, identify the name of the node you wish to drain. You can list all of the nodes in your cluster withkubectl get nodes Next, tell Kubernetes to drain the node:kubectl drain --ignore-daemonsets <node name> If there are pods managed by a DaemonSet, you will need to specify --ignore-daemonsets with kubectl to successfully drain the node. The kubectl drain subcommand on its own does not actually drain a node of its DaemonSet pods: the DaemonSet controller (part of the control plane) immediately replaces missing Pods with new equivalent Pods. The DaemonSet controller also creates Pods that ignore unschedulable taints, which allows the new Pods t


Question: What are the benefits of Safely Drain a Node?

Answer: Safely Drain a NodeThis page shows how to safely drain a node, optionally respecting the PodDisruptionBudget you have defined.Before you beginThis task assumes that you have met the following prerequisites:You do not require your applications to be highly available during the node drain, orYou have read about the PodDisruptionBudget concept, and have configured PodDisruptionBudgets for applications that need them.(Optional) Configure a disruption budgetTo ensure that your workloads remain available during maintenance, you can configure a PodDisruptionBudget.If availability is important for any applications that run or could run on the node(s) that you are draining, configure a PodDisruptionBudgets first and then continue following this guide.It is recommended to set AlwaysAllow Unhealthy Pod Eviction Policy to your PodDisruptionBudgets to support eviction of misbehaving applications during a node drain. The default behavior is to wait for the application pods to become healthy before the drain can proceed.Use kubectl drain to remove a node from serviceYou can use kubectl drain to safely evict all of your pods from a node before you perform maintenance on the node (e.g. kernel upgrade, hardware maintenance, etc.). Safe evictions allow the pod's containers to gracefully terminate and will respect the PodDisruptionBudgets you have specified.Note:By default kubectl drain ignores certain system pods on the node that cannot be killed; see the kubectl drain documentation for more details.When kubectl drain returns successfully, that indicates that all of the pods (except the ones excluded as described in the previous paragraph) have been safely evicted (respecting the desired graceful termination period, and respecting the PodDisruptionBudget you have defined). It is then safe to bring down the node by powering down its physical machine or, if running on a cloud platform, deleting its virtual machine.Note:If any new Pods tolerate the node.kubernetes.io/unschedulable taint, then those Pods might be scheduled to the node you have drained. Avoid tolerating that taint other than for DaemonSets.If you or another API user directly set the nodeName field for a Pod (bypassing the scheduler), then the Pod is bound to the specified node and will run there, even though you have drained that node and marked it unschedulable.First, identify the name of the node you wish to drain. You can list all of the nodes in your cluster withkubectl get nodes Next, tell Kubernetes to drain the node:kubectl drain --ignore-daemonsets <node name> If there are pods managed by a DaemonSet, you will need to specify --ignore-daemonsets with kubectl to successfully drain the node. The kubectl drain subcommand on its own does not actually drain a node of its DaemonSet pods: the DaemonSet controller (part of the control plane) immediately replaces missing Pods with new equivalent Pods. The DaemonSet controller also creates Pods that ignore unschedulable taints, which allows the new Pods t


Question: What is Safely Drain a Node?

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


Question: What is Before you begin?

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


Question: What is (Optional) Configure a disruption budget?

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


Question: What is Use kubectl drain to remove a node from service?

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


Question: What is Note:?

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


Question: What is Note:?

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


Question: What is Draining multiple nodes in parallel?

Answer: T h e   k u b e c t l   d r a i n   c o m m a n d   s h o u l d   o n l y   b e   i s s u e d   t o   a   s i n g l e   n o d e   a t   a   t i m e .   H o w e v e r ,   y o u   c a n   r u n   m u l t i p l e   k u b e c t l   d r a i n   c o m m a n d s   f o r   d i f f e r e n t   n o d e s   i n   p a r a l l e l ,   i n   d i f f e r e n t   t e r m i n a l s   o r   i n   t h e   b a c k g r o u n d .   M u l t i p l e   d r a i n   c o m m a n d s   r u n n i n g   c o n c u r r e n t l y   w i l l   s t i l l   r e s p e c t   t h e   P o d D i s r u p t i o n B u d g e t   y o u   s p e c i f y .   F o r   e x a m p l e ,   i f   y o u   h a v e   a   S t a t e f u l S e t   w i t h   t h r e e   r e p l i c a s   a n d   h a v e   s e t   a   P o d D i s r u p t i o n B u d g e t   f o r   t h a t   s e t   s p e c i f y i n g   m i n A v a i l a b l e :   2 ,   k u b e c t l   d r a i n   o n l y   e v i c t s   a   p o d   f r o m   t h e   S t a t e f u l S e t   i f   a l l   t h r e e   r e p l i c a s   p o d s   a r e   h e a l t h y ;   i f   t h e n   y o u   i s s u e   m u l t i p l e   d r a i n   c o m m a n d s   i n   p a r a l l e l ,   K u b e r n e t e s   r e s p e c t s   t h e   P o d D i s r u p t i o n B u d g e t   a n d   e n s u r e s   t h a t   o n l y   1   ( c a l c u l a t e d   a s   r e p l i c a s   -   m i n A v a i l a b l e )   P o d   i s   u n a v a i l a b l e   a t   a n y   g i v e n   t i m e .   A n y   d r a i n s   t h a t   w o u l d   c a u s e   t h e   n u m b e r   o f   h e a l t h y   r e p l i c a s   t o   f a l l   b e l o w   t h e   s p e c i f i e d   b u d g e t   a r e   b l o c k e d .


Question: What is The Eviction API?

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


Question: What is What's next?

Answer: F o l l o w   s t e p s   t o   p r o t e c t   y o u r   a p p l i c a t i o n   b y   c o n f i g u r i n g   a   P o d   D i s r u p t i o n   B u d g e t .


Question: What is Understand Pressure Stall Information (PSI) Metrics?

Answer: Understand Pressure Stall Information (PSI) MetricsDetailed explanation of Pressure Stall Information (PSI) metrics and how to use them to identify resource pressure in Kubernetes.FEATURE STATE: Kubernetes v1.34 [beta]As a beta feature, Kubernetes lets you configure the kubelet to collect Linux kernel Pressure Stall Information (PSI) for CPU, memory, and I/O usage. The information is collected at node, pod and container level. This feature is enabled by default by setting the KubeletPSI feature gate.PSI metrics are exposed through two different sources:The kubelet's Summary API, which provides PSI data at the node, pod, and container level.The /metrics/cadvisor endpoint on the kubelet, which exposes PSI metrics in the Prometheus format.RequirementsPressure Stall Information requires the following on your Linux nodes:The Linux kernel must be version 4.20 or newer.The kernel must be compiled with the CONFIG_PSI=y option. Most modern distributions enable this by default. You can check your kernel's configuration by running zgrep CONFIG_PSI /proc/config.gz.Some Linux distributions may compile PSI into the kernel but disable it by default. If so, you need to enable it at boot time by adding the psi=1 parameter to the kernel command line.The node must be using cgroup v2.Understanding PSI MetricsPressure Stall Information (PSI) metrics are provided for three resources: CPU, memory, and I/O. They are categorized into two main types of pressure: some and full.some: This value indicates that some tasks (one or more) are stalled on a resource. For example, if some tasks are waiting for I/O, this metric will increase. This can be an early indicator of resource contention.full: This value indicates that all non-idle tasks are stalled on a resource simultaneously. This signifies a more severe resource shortage, where the entire system is unable to make progress.Each pressure type provides four metrics: avg10, avg60, avg300, and total. The avg values represent the percentage of wall-clock time that tasks were stalled over 10-second, 60-second, and 3-minute moving averages. The total value is a cumulative counter in microseconds showing the total time tasks have been stalled.Example ScenariosYou can use a simple Pod with a stress-testing tool to generate resource pressure and observe the PSI metrics. The following examples use the agnhost container image, which includes the stress tool.Generating CPU PressureCreate a Pod that generates CPU pressure using the stress utility. This workload will put a heavy load on one CPU core.Create a file named cpu-pressure-pod.yaml:apiVersion: v1 kind: Pod metadata: name: cpu-pressure-pod spec: restartPolicy: Never containers: - name: cpu-stress image: registry.k8s.io/e2e-test-images/agnhost:2.47 args: - "stress" - "--cpus" - "1" resources: limits: cpu: "500m" requests: cpu: "500m" Apply it to your cluster: kubectl apply -f cpu-pressure-pod.yamlObserving CPU PressureAfter the Pod is running, you can observe the CPU pressure thr


Question: How does Understand Pressure Stall Information (PSI) Metrics work?

Answer: Understand Pressure Stall Information (PSI) MetricsDetailed explanation of Pressure Stall Information (PSI) metrics and how to use them to identify resource pressure in Kubernetes.FEATURE STATE: Kubernetes v1.34 [beta]As a beta feature, Kubernetes lets you configure the kubelet to collect Linux kernel Pressure Stall Information (PSI) for CPU, memory, and I/O usage. The information is collected at node, pod and container level. This feature is enabled by default by setting the KubeletPSI feature gate.PSI metrics are exposed through two different sources:The kubelet's Summary API, which provides PSI data at the node, pod, and container level.The /metrics/cadvisor endpoint on the kubelet, which exposes PSI metrics in the Prometheus format.RequirementsPressure Stall Information requires the following on your Linux nodes:The Linux kernel must be version 4.20 or newer.The kernel must be compiled with the CONFIG_PSI=y option. Most modern distributions enable this by default. You can check your kernel's configuration by running zgrep CONFIG_PSI /proc/config.gz.Some Linux distributions may compile PSI into the kernel but disable it by default. If so, you need to enable it at boot time by adding the psi=1 parameter to the kernel command line.The node must be using cgroup v2.Understanding PSI MetricsPressure Stall Information (PSI) metrics are provided for three resources: CPU, memory, and I/O. They are categorized into two main types of pressure: some and full.some: This value indicates that some tasks (one or more) are stalled on a resource. For example, if some tasks are waiting for I/O, this metric will increase. This can be an early indicator of resource contention.full: This value indicates that all non-idle tasks are stalled on a resource simultaneously. This signifies a more severe resource shortage, where the entire system is unable to make progress.Each pressure type provides four metrics: avg10, avg60, avg300, and total. The avg values represent the percentage of wall-clock time that tasks were stalled over 10-second, 60-second, and 3-minute moving averages. The total value is a cumulative counter in microseconds showing the total time tasks have been stalled.Example ScenariosYou can use a simple Pod with a stress-testing tool to generate resource pressure and observe the PSI metrics. The following examples use the agnhost container image, which includes the stress tool.Generating CPU PressureCreate a Pod that generates CPU pressure using the stress utility. This workload will put a heavy load on one CPU core.Create a file named cpu-pressure-pod.yaml:apiVersion: v1 kind: Pod metadata: name: cpu-pressure-pod spec: restartPolicy: Never containers: - name: cpu-stress image: registry.k8s.io/e2e-test-images/agnhost:2.47 args: - "stress" - "--cpus" - "1" resources: limits: cpu: "500m" requests: cpu: "500m" Apply it to your cluster: kubectl apply -f cpu-pressure-pod.yamlObserving CPU PressureAfter the Pod is running, you can observe the CPU pressure thr


Question: When would you use Understand Pressure Stall Information (PSI) Metrics?

Answer: Understand Pressure Stall Information (PSI) MetricsDetailed explanation of Pressure Stall Information (PSI) metrics and how to use them to identify resource pressure in Kubernetes.FEATURE STATE: Kubernetes v1.34 [beta]As a beta feature, Kubernetes lets you configure the kubelet to collect Linux kernel Pressure Stall Information (PSI) for CPU, memory, and I/O usage. The information is collected at node, pod and container level. This feature is enabled by default by setting the KubeletPSI feature gate.PSI metrics are exposed through two different sources:The kubelet's Summary API, which provides PSI data at the node, pod, and container level.The /metrics/cadvisor endpoint on the kubelet, which exposes PSI metrics in the Prometheus format.RequirementsPressure Stall Information requires the following on your Linux nodes:The Linux kernel must be version 4.20 or newer.The kernel must be compiled with the CONFIG_PSI=y option. Most modern distributions enable this by default. You can check your kernel's configuration by running zgrep CONFIG_PSI /proc/config.gz.Some Linux distributions may compile PSI into the kernel but disable it by default. If so, you need to enable it at boot time by adding the psi=1 parameter to the kernel command line.The node must be using cgroup v2.Understanding PSI MetricsPressure Stall Information (PSI) metrics are provided for three resources: CPU, memory, and I/O. They are categorized into two main types of pressure: some and full.some: This value indicates that some tasks (one or more) are stalled on a resource. For example, if some tasks are waiting for I/O, this metric will increase. This can be an early indicator of resource contention.full: This value indicates that all non-idle tasks are stalled on a resource simultaneously. This signifies a more severe resource shortage, where the entire system is unable to make progress.Each pressure type provides four metrics: avg10, avg60, avg300, and total. The avg values represent the percentage of wall-clock time that tasks were stalled over 10-second, 60-second, and 3-minute moving averages. The total value is a cumulative counter in microseconds showing the total time tasks have been stalled.Example ScenariosYou can use a simple Pod with a stress-testing tool to generate resource pressure and observe the PSI metrics. The following examples use the agnhost container image, which includes the stress tool.Generating CPU PressureCreate a Pod that generates CPU pressure using the stress utility. This workload will put a heavy load on one CPU core.Create a file named cpu-pressure-pod.yaml:apiVersion: v1 kind: Pod metadata: name: cpu-pressure-pod spec: restartPolicy: Never containers: - name: cpu-stress image: registry.k8s.io/e2e-test-images/agnhost:2.47 args: - "stress" - "--cpus" - "1" resources: limits: cpu: "500m" requests: cpu: "500m" Apply it to your cluster: kubectl apply -f cpu-pressure-pod.yamlObserving CPU PressureAfter the Pod is running, you can observe the CPU pressure thr


Question: What are the benefits of Understand Pressure Stall Information (PSI) Metrics?

Answer: Understand Pressure Stall Information (PSI) MetricsDetailed explanation of Pressure Stall Information (PSI) metrics and how to use them to identify resource pressure in Kubernetes.FEATURE STATE: Kubernetes v1.34 [beta]As a beta feature, Kubernetes lets you configure the kubelet to collect Linux kernel Pressure Stall Information (PSI) for CPU, memory, and I/O usage. The information is collected at node, pod and container level. This feature is enabled by default by setting the KubeletPSI feature gate.PSI metrics are exposed through two different sources:The kubelet's Summary API, which provides PSI data at the node, pod, and container level.The /metrics/cadvisor endpoint on the kubelet, which exposes PSI metrics in the Prometheus format.RequirementsPressure Stall Information requires the following on your Linux nodes:The Linux kernel must be version 4.20 or newer.The kernel must be compiled with the CONFIG_PSI=y option. Most modern distributions enable this by default. You can check your kernel's configuration by running zgrep CONFIG_PSI /proc/config.gz.Some Linux distributions may compile PSI into the kernel but disable it by default. If so, you need to enable it at boot time by adding the psi=1 parameter to the kernel command line.The node must be using cgroup v2.Understanding PSI MetricsPressure Stall Information (PSI) metrics are provided for three resources: CPU, memory, and I/O. They are categorized into two main types of pressure: some and full.some: This value indicates that some tasks (one or more) are stalled on a resource. For example, if some tasks are waiting for I/O, this metric will increase. This can be an early indicator of resource contention.full: This value indicates that all non-idle tasks are stalled on a resource simultaneously. This signifies a more severe resource shortage, where the entire system is unable to make progress.Each pressure type provides four metrics: avg10, avg60, avg300, and total. The avg values represent the percentage of wall-clock time that tasks were stalled over 10-second, 60-second, and 3-minute moving averages. The total value is a cumulative counter in microseconds showing the total time tasks have been stalled.Example ScenariosYou can use a simple Pod with a stress-testing tool to generate resource pressure and observe the PSI metrics. The following examples use the agnhost container image, which includes the stress tool.Generating CPU PressureCreate a Pod that generates CPU pressure using the stress utility. This workload will put a heavy load on one CPU core.Create a file named cpu-pressure-pod.yaml:apiVersion: v1 kind: Pod metadata: name: cpu-pressure-pod spec: restartPolicy: Never containers: - name: cpu-stress image: registry.k8s.io/e2e-test-images/agnhost:2.47 args: - "stress" - "--cpus" - "1" resources: limits: cpu: "500m" requests: cpu: "500m" Apply it to your cluster: kubectl apply -f cpu-pressure-pod.yamlObserving CPU PressureAfter the Pod is running, you can observe the CPU pressure thr


Question: What is Understand Pressure Stall Information (PSI) Metrics?

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


Question: What is Requirements?

Answer: P r e s s u r e   S t a l l   I n f o r m a t i o n   r e q u i r e s   t h e   f o l l o w i n g   o n   y o u r   L i n u x   n o d e s :   T h e   L i n u x   k e r n e l   m u s t   b e   v e r s i o n   4 . 2 0   o r   n e w e r . T h e   k e r n e l   m u s t   b e   c o m p i l e d   w i t h   t h e   C O N F I G _ P S I = y   o p t i o n .   M o s t   m o d e r n   d i s t r i b u t i o n s   e n a b l e   t h i s   b y   d e f a u l t .   Y o u   c a n   c h e c k   y o u r   k e r n e l ' s   c o n f i g u r a t i o n   b y   r u n n i n g   z g r e p   C O N F I G _ P S I   / p r o c / c o n f i g . g z . S o m e   L i n u x   d i s t r i b u t i o n s   m a y   c o m p i l e   P S I   i n t o   t h e   k e r n e l   b u t   d i s a b l e   i t   b y   d e f a u l t .   I f   s o ,   y o u   n e e d   t o   e n a b l e   i t   a t   b o o t   t i m e   b y   a d d i n g   t h e   p s i = 1   p a r a m e t e r   t o   t h e   k e r n e l   c o m m a n d   l i n e . T h e   n o d e   m u s t   b e   u s i n g   c g r o u p   v 2 .


Question: What is Understanding PSI Metrics?

Answer: P r e s s u r e   S t a l l   I n f o r m a t i o n   ( P S I )   m e t r i c s   a r e   p r o v i d e d   f o r   t h r e e   r e s o u r c e s :   C P U ,   m e m o r y ,   a n d   I / O .   T h e y   a r e   c a t e g o r i z e d   i n t o   t w o   m a i n   t y p e s   o f   p r e s s u r e :   s o m e   a n d   f u l l .   s o m e :   T h i s   v a l u e   i n d i c a t e s   t h a t   s o m e   t a s k s   ( o n e   o r   m o r e )   a r e   s t a l l e d   o n   a   r e s o u r c e .   F o r   e x a m p l e ,   i f   s o m e   t a s k s   a r e   w a i t i n g   f o r   I / O ,   t h i s   m e t r i c   w i l l   i n c r e a s e .   T h i s   c a n   b e   a n   e a r l y   i n d i c a t o r   o f   r e s o u r c e   c o n t e n t i o n . f u l l :   T h i s   v a l u e   i n d i c a t e s   t h a t   a l l   n o n - i d l e   t a s k s   a r e   s t a l l e d   o n   a   r e s o u r c e   s i m u l t a n e o u s l y .   T h i s   s i g n i f i e s   a   m o r e   s e v e r e   r e s o u r c e   s h o r t a g e ,   w h e r e   t h e   e n t i r e   s y s t e m   i s   u n a b l e   t o   m a k e   p r o g r e s s .   E a c h   p r e s s u r e   t y p e   p r o v i d e s   f o u r   m e t r i c s :   a v g 1 0 ,   a v g 6 0 ,   a v g 3 0 0 ,   a n d   t o t a l .   T h e   a v g   v a l u e s   r e p r e s e n t   t h e   p e r c e n t a g e   o f   w a l l - c l o c k   t i m e   t h a t   t a s k s   w e r e   s t a l l e d   o v e r   1 0 - s e c o n d ,   6 0 - s e c o n d ,   a n d   3 - m i n u t e   m o v i n g   a v e r a g e s .   T h e   t o t a l   v a l u e   i s   a   c u m u l a t i v e   c o u n t e r   i n   m i c r o s e c o n d s   s h o w i n g   t h e   t o t a l   t i m e   t a s k s   h a v e   b e e n   s t a l l e d .


Question: What is Example Scenarios?

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


Question: What is Generating CPU Pressure?

Answer: C r e a t e   a   P o d   t h a t   g e n e r a t e s   C P U   p r e s s u r e   u s i n g   t h e   s t r e s s   u t i l i t y .   T h i s   w o r k l o a d   w i l l   p u t   a   h e a v y   l o a d   o n   o n e   C P U   c o r e .   C r e a t e   a   f i l e   n a m e d   c p u - p r e s s u r e - p o d . 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 :   c p u - p r e s s u r e - p o d   s p e c :   r e s t a r t P o l i c y :   N e v e r   c o n t a i n e r s :   -   n a m e :   c p u - s t r e s s   i m a g e :   r e g i s t r y . k 8 s . i o / e 2 e - t e s t - i m a g e s / a g n h o s t : 2 . 4 7   a r g s :   -   " s t r e s s "   -   " - - c p u s "   -   " 1 "   r e s o u r c e s :   l i m i t s :   c p u :   " 5 0 0 m "   r e q u e s t s :   c p u :   " 5 0 0 m "   A p p l y   i t   t o   y o u r   c l u s t e r :   k u b e c t l   a p p l y   - f   c p u - p r e s s u r e - p o d . y a m l


Question: What is Observing CPU Pressure?

Answer: A f t e r   t h e   P o d   i s   r u n n i n g ,   y o u   c a n   o b s e r v e   t h e   C P U   p r e s s u r e   t h r o u g h   e i t h e r   t h e   S u m m a r y   A P I   o r   t h e   P r o m e t h e u s   m e t r i c s   e n d p o i n t .   U s i n g   t h e   S u m m a r y   A P I :   W a t c h   t h e   s u m m a r y   s t a t s   f o r   y o u r   n o d e .   I n   a   s e p a r a t e   t e r m i n a l ,   r u n :   #   R e p l a c e   < n o d e - n a m e >   w i t h   t h e   n a m e   o f   a   n o d e   i n   y o u r   c l u s t e r   k u b e c t l   g e t   - - r a w   " / a p i / v 1 / n o d e s / < n o d e - n a m e > / p r o x y / s t a t s / s u m m a r y "   |   j q   ' . p o d s [ ]   |   s e l e c t ( . p o d R e f . n a m e   |   c o n t a i n s ( " c p u - p r e s s u r e - p o d " ) ) '   Y o u   w i l l   s e e   t h e   s o m e   P S I   m e t r i c s   f o r   C P U   i n c r e a s e   i n   t h e   s u m m a r y   A P I   o u t p u t .   T h e   a v g 1 0   v a l u e   f o r   s o m e   p r e s s u r e   s h o u l d   r i s e   a b o v e   z e r o ,   i n d i c a t i n g   t h a t   t a s k s   a r e   s p e n d i n g   t i m e   s t a l l e d   o n   t h e   C P U .   U s i n g   t h e   P r o m e t h e u s   m e t r i c s   e n d p o i n t :   Q u e r y   t h e   / m e t r i c s / c a d v i s o r   e n d p o i n t   t o   s e e   t h e   c o n t a i n e r _ p r e s s u r e _ c p u _ w a i t i n g _ s e c o n d s _ t o t a l   m e t r i c .   #   R e p l a c e   < n o d e - n a m e >   w i t h   t h e   n a m e   o f   t h e   n o d e   w h e r e   t h e   p o d   i s   r u n n i n g   k u b e c t l   g e t   - - r a w   " / a p i / v 1 / n o d e s / < n o d e - n a m e > / p r o x y / m e t r i c s / c a d v i s o r "   |   \   g r e p   ' c o n t a i n e r _ p r e s s u r e _ c p u _ w a i t i n g _ s e c o n d s _ t o t a l { c o n t a i n e r = " c p u - s t r e s s " '   T h e   o u t p u t   s h o u l d   s h o w   a n   i n c


Question: What is Cleanup?

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


Question: What is Generating Memory Pressure?

Answer: T h i s   e x a m p l e   c r e a t e s   a   P o d   t h a t   c o n t i n u o u s l y   w r i t e s   t o   f i l e s   i n   t h e   c o n t a i n e r ' s   w r i t a b l e   l a y e r ,   c a u s i n g   t h e   k e r n e l ' s   p a g e   c a c h e   t o   g r o w   a n d   f o r c i n g   m e m o r y   r e c l a m a t i o n ,   w h i c h   g e n e r a t e s   p r e s s u r e .   C r e a t e   a   f i l e   n a m e d   m e m o r y - p r e s s u r e - p o d . 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 :   m e m o r y - p r e s s u r e - p o d   s p e c :   r e s t a r t P o l i c y :   N e v e r   c o n t a i n e r s :   -   n a m e :   m e m o r y - s t r e s s   i m a g e :   r e g i s t r y . k 8 s . i o / e 2 e - t e s t - i m a g e s / a g n h o s t : 2 . 4 7   c o m m a n d :   [ " / b i n / s h " ,   " - c " ]   a r g s :   -   " i = 0 ;   w h i l e   t r u e ;   d o   d d   i f = / d e v / z e r o   o f = t e s t f i l e . $ i   b s = 1 M   c o u n t = 5 0   & > / d e v / n u l l ;   i = $ ( ( ( i + 1 ) % 5 ) ) ;   s l e e p   0 . 1 ;   d o n e "   r e s o u r c e s :   l i m i t s :   m e m o r y :   " 2 0 0 M "   r e q u e s t s :   m e m o r y :   " 2 0 0 M "   A p p l y   i t   t o   y o u r   c l u s t e r :   k u b e c t l   a p p l y   - f   m e m o r y - p r e s s u r e - p o d . y a m l


Question: What is Observing Memory Pressure?

Answer: U s i n g   t h e   S u m m a r y   A P I :   I n   t h e   s u m m a r y   o u t p u t ,   y o u   w i l l   o b s e r v e   a n   i n c r e a s e   i n   t h e   f u l l   P S I   m e t r i c s   f o r   m e m o r y ,   i n d i c a t i n g   t h a t   t h e   s y s t e m   i s   u n d e r   s i g n i f i c a n t   m e m o r y   p r e s s u r e .   #   R e p l a c e   < n o d e - n a m e >   w i t h   t h e   n a m e   o f   a   n o d e   i n   y o u r   c l u s t e r   k u b e c t l   g e t   - - r a w   " / a p i / v 1 / n o d e s / < n o d e - n a m e > / p r o x y / s t a t s / s u m m a r y "   |   j q   ' . p o d s [ ]   |   s e l e c t ( . p o d R e f . n a m e   |   c o n t a i n s ( " m e m o r y - p r e s s u r e - p o d " ) ) '   U s i n g   t h e   P r o m e t h e u s   m e t r i c s   e n d p o i n t :   Q u e r y   t h e   / m e t r i c s / c a d v i s o r   e n d p o i n t   t o   s e e   t h e   c o n t a i n e r _ p r e s s u r e _ m e m o r y _ w a i t i n g _ s e c o n d s _ t o t a l   m e t r i c .   #   R e p l a c e   < n o d e - n a m e >   w i t h   t h e   n a m e   o f   t h e   n o d e   w h e r e   t h e   p o d   i s   r u n n i n g   k u b e c t l   g e t   - - r a w   " / a p i / v 1 / n o d e s / < n o d e - n a m e > / p r o x y / m e t r i c s / c a d v i s o r "   |   \   g r e p   ' c o n t a i n e r _ p r e s s u r e _ m e m o r y _ w a i t i n g _ s e c o n d s _ t o t a l { c o n t a i n e r = " m e m o r y - s t r e s s " '   I n   t h e   o u t p u t ,   y o u   w i l l   o b s e r v e   a n   i n c r e a s i n g   v a l u e   f o r   t h e   m e t r i c ,   i n d i c a t i n g   t h a t   t h e   s y s t e m   i s   u n d e r   s i g n i f i c a n t   m e m o r y   p r e s s u r e .


Question: What is Cleanup?

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


Question: What is Generating I/O Pressure?

Answer: T h i s   P o d   g e n e r a t e s   I / O   p r e s s u r e   b y   r e p e a t e d l y   w r i t i n g   a   f i l e   t o   d i s k   a n d   u s i n g   s y n c   t o   f l u s h   t h e   d a t a   f r o m   m e m o r y ,   w h i c h   c r e a t e s   I / O   s t a l l s .   C r e a t e   a   f i l e   n a m e d   i o - p r e s s u r e - p o d . 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 :   i o - p r e s s u r e - p o d   s p e c :   r e s t a r t P o l i c y :   N e v e r   c o n t a i n e r s :   -   n a m e :   i o - s t r e s s   i m a g e :   r e g i s t r y . k 8 s . i o / e 2 e - t e s t - i m a g e s / a g n h o s t : 2 . 4 7   c o m m a n d :   [ " / b i n / s h " ,   " - c " ]   a r g s :   -   " w h i l e   t r u e ;   d o   d d   i f = / d e v / z e r o   o f = t e s t f i l e   b s = 1 M   c o u n t = 1 2 8   & > / d e v / n u l l ;   s y n c ;   r m   t e s t f i l e   & > / d e v / n u l l ;   d o n e "   A p p l y   t h i s   t o   y o u r   c l u s t e r :   k u b e c t l   a p p l y   - f   i o - p r e s s u r e - p o d . y a m l


Question: What is Observing I/O Pressure?

Answer: U s i n g   t h e   S u m m a r y   A P I :   Y o u   w i l l   s e e   t h e   s o m e   P S I   m e t r i c s   f o r   I / O   i n c r e a s e   a s   t h e   P o d   c o n t i n u o u s l y   w r i t e s   t o   d i s k .   #   R e p l a c e   < n o d e - n a m e >   w i t h   t h e   n a m e   o f   a   n o d e   i n   y o u r   c l u s t e r   k u b e c t l   g e t   - - r a w   " / a p i / v 1 / n o d e s / < n o d e - n a m e > / p r o x y / s t a t s / s u m m a r y "   |   j q   ' . p o d s [ ]   |   s e l e c t ( . p o d R e f . n a m e   |   c o n t a i n s ( " i o - p r e s s u r e - p o d " ) ) '   U s i n g   t h e   P r o m e t h e u s   m e t r i c s   e n d p o i n t :   Q u e r y   t h e   / m e t r i c s / c a d v i s o r   e n d p o i n t   t o   s e e   t h e   c o n t a i n e r _ p r e s s u r e _ i o _ w a i t i n g _ s e c o n d s _ t o t a l   m e t r i c .   #   R e p l a c e   < n o d e - n a m e >   w i t h   t h e   n a m e   o f   t h e   n o d e   w h e r e   t h e   p o d   i s   r u n n i n g   k u b e c t l   g e t   - - r a w   " / a p i / v 1 / n o d e s / < n o d e - n a m e > / p r o x y / m e t r i c s / c a d v i s o r "   |   \   g r e p   ' c o n t a i n e r _ p r e s s u r e _ i o _ w a i t i n g _ s e c o n d s _ t o t a l { c o n t a i n e r = " i o - s t r e s s " '   Y o u   w i l l   s e e   t h e   m e t r i c ' s   v a l u e   i n c r e a s e   a s   t h e   P o d   c o n t i n u o u s l y   w r i t e s   t o   d i s k .


Question: What is Cleanup?

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


Question: What is What's next?

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


Question: What is Patch?

Answer: PatchPatch is provided to give a concrete name and type to the Kubernetes PATCH request body.import "k8s.io/apimachinery/pkg/apis/meta/v1"Patch is provided to give a concrete name and type to the Kubernetes PATCH request body.This page is automatically generated.If you plan to report an issue with this page, mention that the page is auto-generated in your issue description. The fix may need to happen elsewhere in the Kubernetes project.


Question: How does Patch work?

Answer: PatchPatch is provided to give a concrete name and type to the Kubernetes PATCH request body.import "k8s.io/apimachinery/pkg/apis/meta/v1"Patch is provided to give a concrete name and type to the Kubernetes PATCH request body.This page is automatically generated.If you plan to report an issue with this page, mention that the page is auto-generated in your issue description. The fix may need to happen elsewhere in the Kubernetes project.


Question: When would you use Patch?

Answer: PatchPatch is provided to give a concrete name and type to the Kubernetes PATCH request body.import "k8s.io/apimachinery/pkg/apis/meta/v1"Patch is provided to give a concrete name and type to the Kubernetes PATCH request body.This page is automatically generated.If you plan to report an issue with this page, mention that the page is auto-generated in your issue description. The fix may need to happen elsewhere in the Kubernetes project.


Question: What are the benefits of Patch?

Answer: PatchPatch is provided to give a concrete name and type to the Kubernetes PATCH request body.import "k8s.io/apimachinery/pkg/apis/meta/v1"Patch is provided to give a concrete name and type to the Kubernetes PATCH request body.This page is automatically generated.If you plan to report an issue with this page, mention that the page is auto-generated in your issue description. The fix may need to happen elsewhere in the Kubernetes project.


Question: What is Patch?

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


Question: What is kubectl create role?

Answer: kubectl create roleSynopsisCreate a role with single rule.kubectl create role NAME --verb=verb --resource=resource.group/subresource [--resource-name=resourcename] [--dry-run=server|client|none] Examples # Create a role named "pod-reader" that allows user to perform "get", "watch" and "list" on pods kubectl create role pod-reader --verb=get --verb=list --verb=watch --resource=pods # Create a role named "pod-reader" with ResourceName specified kubectl create role pod-reader --verb=get --resource=pods --resource-name=readablepod --resource-name=anotherpod # Create a role named "foo" with API Group specified kubectl create role foo --verb=get,list,watch --resource=rs.apps # Create a role named "foo" with SubResource specified kubectl create role foo --verb=get,list,watch --resource=pods,pods/status Options--allow-missing-template-keys Default: trueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.--dry-run string[="unchanged"] Default: "none"Must be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource.--field-manager string Default: "kubectl-create"Name of the manager used to track field ownership.-h, --helphelp for role-o, --output stringOutput format. One of: (json, yaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file).--resource stringsResource that the rule applies to--resource-name stringsResource in the white list that the rule applies to, repeat this flag for multiple items--save-configIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.--show-managed-fieldsIf true, keep the managedFields when printing objects in JSON or YAML format.--template stringTemplate string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].--validate string[="strict"] Default: "strict"Must be one of: strict (or true), warn, ignore (or false). "true" or "strict" will use a schema to validate the input and fail the request if invalid. It will perform server side validation if ServerSideFieldValidation is enabled on the api-server, but will fall back to less reliable client-side validation if not. "warn" will warn about unknown or duplicate fields without blocking the request if server-side field validation is enabled on the API server, and behave as "ignore" otherwise. "false" or "ignore" will not perform any schema validation, silently dropping any unknown or duplicate fields.--verb stringsVerb that applies to the resources contained in the ruleParent Options Inherited--as stringUsername to impersonate for the operat


Question: How does kubectl create role work?

Answer: kubectl create roleSynopsisCreate a role with single rule.kubectl create role NAME --verb=verb --resource=resource.group/subresource [--resource-name=resourcename] [--dry-run=server|client|none] Examples # Create a role named "pod-reader" that allows user to perform "get", "watch" and "list" on pods kubectl create role pod-reader --verb=get --verb=list --verb=watch --resource=pods # Create a role named "pod-reader" with ResourceName specified kubectl create role pod-reader --verb=get --resource=pods --resource-name=readablepod --resource-name=anotherpod # Create a role named "foo" with API Group specified kubectl create role foo --verb=get,list,watch --resource=rs.apps # Create a role named "foo" with SubResource specified kubectl create role foo --verb=get,list,watch --resource=pods,pods/status Options--allow-missing-template-keys Default: trueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.--dry-run string[="unchanged"] Default: "none"Must be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource.--field-manager string Default: "kubectl-create"Name of the manager used to track field ownership.-h, --helphelp for role-o, --output stringOutput format. One of: (json, yaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file).--resource stringsResource that the rule applies to--resource-name stringsResource in the white list that the rule applies to, repeat this flag for multiple items--save-configIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.--show-managed-fieldsIf true, keep the managedFields when printing objects in JSON or YAML format.--template stringTemplate string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].--validate string[="strict"] Default: "strict"Must be one of: strict (or true), warn, ignore (or false). "true" or "strict" will use a schema to validate the input and fail the request if invalid. It will perform server side validation if ServerSideFieldValidation is enabled on the api-server, but will fall back to less reliable client-side validation if not. "warn" will warn about unknown or duplicate fields without blocking the request if server-side field validation is enabled on the API server, and behave as "ignore" otherwise. "false" or "ignore" will not perform any schema validation, silently dropping any unknown or duplicate fields.--verb stringsVerb that applies to the resources contained in the ruleParent Options Inherited--as stringUsername to impersonate for the operat


Question: When would you use kubectl create role?

Answer: kubectl create roleSynopsisCreate a role with single rule.kubectl create role NAME --verb=verb --resource=resource.group/subresource [--resource-name=resourcename] [--dry-run=server|client|none] Examples # Create a role named "pod-reader" that allows user to perform "get", "watch" and "list" on pods kubectl create role pod-reader --verb=get --verb=list --verb=watch --resource=pods # Create a role named "pod-reader" with ResourceName specified kubectl create role pod-reader --verb=get --resource=pods --resource-name=readablepod --resource-name=anotherpod # Create a role named "foo" with API Group specified kubectl create role foo --verb=get,list,watch --resource=rs.apps # Create a role named "foo" with SubResource specified kubectl create role foo --verb=get,list,watch --resource=pods,pods/status Options--allow-missing-template-keys Default: trueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.--dry-run string[="unchanged"] Default: "none"Must be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource.--field-manager string Default: "kubectl-create"Name of the manager used to track field ownership.-h, --helphelp for role-o, --output stringOutput format. One of: (json, yaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file).--resource stringsResource that the rule applies to--resource-name stringsResource in the white list that the rule applies to, repeat this flag for multiple items--save-configIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.--show-managed-fieldsIf true, keep the managedFields when printing objects in JSON or YAML format.--template stringTemplate string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].--validate string[="strict"] Default: "strict"Must be one of: strict (or true), warn, ignore (or false). "true" or "strict" will use a schema to validate the input and fail the request if invalid. It will perform server side validation if ServerSideFieldValidation is enabled on the api-server, but will fall back to less reliable client-side validation if not. "warn" will warn about unknown or duplicate fields without blocking the request if server-side field validation is enabled on the API server, and behave as "ignore" otherwise. "false" or "ignore" will not perform any schema validation, silently dropping any unknown or duplicate fields.--verb stringsVerb that applies to the resources contained in the ruleParent Options Inherited--as stringUsername to impersonate for the operat


Question: What are the benefits of kubectl create role?

Answer: kubectl create roleSynopsisCreate a role with single rule.kubectl create role NAME --verb=verb --resource=resource.group/subresource [--resource-name=resourcename] [--dry-run=server|client|none] Examples # Create a role named "pod-reader" that allows user to perform "get", "watch" and "list" on pods kubectl create role pod-reader --verb=get --verb=list --verb=watch --resource=pods # Create a role named "pod-reader" with ResourceName specified kubectl create role pod-reader --verb=get --resource=pods --resource-name=readablepod --resource-name=anotherpod # Create a role named "foo" with API Group specified kubectl create role foo --verb=get,list,watch --resource=rs.apps # Create a role named "foo" with SubResource specified kubectl create role foo --verb=get,list,watch --resource=pods,pods/status Options--allow-missing-template-keys Default: trueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.--dry-run string[="unchanged"] Default: "none"Must be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource.--field-manager string Default: "kubectl-create"Name of the manager used to track field ownership.-h, --helphelp for role-o, --output stringOutput format. One of: (json, yaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file).--resource stringsResource that the rule applies to--resource-name stringsResource in the white list that the rule applies to, repeat this flag for multiple items--save-configIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.--show-managed-fieldsIf true, keep the managedFields when printing objects in JSON or YAML format.--template stringTemplate string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].--validate string[="strict"] Default: "strict"Must be one of: strict (or true), warn, ignore (or false). "true" or "strict" will use a schema to validate the input and fail the request if invalid. It will perform server side validation if ServerSideFieldValidation is enabled on the api-server, but will fall back to less reliable client-side validation if not. "warn" will warn about unknown or duplicate fields without blocking the request if server-side field validation is enabled on the API server, and behave as "ignore" otherwise. "false" or "ignore" will not perform any schema validation, silently dropping any unknown or duplicate fields.--verb stringsVerb that applies to the resources contained in the ruleParent Options Inherited--as stringUsername to impersonate for the operat


Question: What is Synopsis?

Answer: C r e a t e   a   r o l e   w i t h   s i n g l e   r u l e .   k u b e c t l   c r e a t e   r o l e   N A M E   - - v e r b = v e r b   - - r e s o u r c e = r e s o u r c e . g r o u p / s u b r e s o u r c e   [ - - r e s o u r c e - n a m e = r e s o u r c e n a m e ]   [ - - d r y - r u n = s e r v e r | c l i e n t | n o n e ]


Question: What is Examples?

Answer: #   C r e a t e   a   r o l e   n a m e d   " p o d - r e a d e r "   t h a t   a l l o w s   u s e r   t o   p e r f o r m   " g e t " ,   " w a t c h "   a n d   " l i s t "   o n   p o d s   k u b e c t l   c r e a t e   r o l e   p o d - r e a d e r   - - v e r b = g e t   - - v e r b = l i s t   - - v e r b = w a t c h   - - r e s o u r c e = p o d s   #   C r e a t e   a   r o l e   n a m e d   " p o d - r e a d e r "   w i t h   R e s o u r c e N a m e   s p e c i f i e d   k u b e c t l   c r e a t e   r o l e   p o d - r e a d e r   - - v e r b = g e t   - - r e s o u r c e = p o d s   - - r e s o u r c e - n a m e = r e a d a b l e p o d   - - r e s o u r c e - n a m e = a n o t h e r p o d   #   C r e a t e   a   r o l e   n a m e d   " f o o "   w i t h   A P I   G r o u p   s p e c i f i e d   k u b e c t l   c r e a t e   r o l e   f o o   - - v e r b = g e t , l i s t , w a t c h   - - r e s o u r c e = r s . a p p s   #   C r e a t e   a   r o l e   n a m e d   " f o o "   w i t h   S u b R e s o u r c e   s p e c i f i e d   k u b e c t l   c r e a t e   r o l e   f o o   - - v e r b = g e t , l i s t , w a t c h   - - r e s o u r c e = p o d s , p o d s / s t a t u s


Question: What is Options?

Answer: I f   t r u e ,   i g n o r e   a n y   e r r o r s   i n   t e m p l a t e s   w h e n   a   f i e l d   o r   m a p   k e y   i s   m i s s i n g   i n   t h e   t e m p l a t e .   O n l y   a p p l i e s   t o   g o l a n g   a n d   j s o n p a t h   o u t p u t   f o r m a t s .   M u s t   b e   " n o n e " ,   " s e r v e r " ,   o r   " c l i e n t " .   I f   c l i e n t   s t r a t e g y ,   o n l y   p r i n t   t h e   o b j e c t   t h a t   w o u l d   b e   s e n t ,   w i t h o u t   s e n d i n g   i t .   I f   s e r v e r   s t r a t e g y ,   s u b m i t   s e r v e r - s i d e   r e q u e s t   w i t h o u t   p e r s i s t i n g   t h e   r e s o u r c e .   N a m e   o f   t h e   m a n a g e r   u s e d   t o   t r a c k   f i e l d   o w n e r s h i p .   h e l p   f o r   r o l e   O u t p u t   f o r m a t .   O n e   o f :   ( j s o n ,   y a m l ,   n a m e ,   g o - t e m p l a t e ,   g o - t e m p l a t e - f i l e ,   t e m p l a t e ,   t e m p l a t e f i l e ,   j s o n p a t h ,   j s o n p a t h - a s - j s o n ,   j s o n p a t h - f i l e ) .   R e s o u r c e   t h a t   t h e   r u l e   a p p l i e s   t o   R e s o u r c e   i n   t h e   w h i t e   l i s t   t h a t   t h e   r u l e   a p p l i e s   t o ,   r e p e a t   t h i s   f l a g   f o r   m u l t i p l e   i t e m s   I f   t r u e ,   t h e   c o n f i g u r a t i o n   o f   c u r r e n t   o b j e c t   w i l l   b e   s a v e d   i n   i t s   a n n o t a t i o n .   O t h e r w i s e ,   t h e   a n n o t a t i o n   w i l l   b e   u n c h a n g e d .   T h i s   f l a g   i s   u s e f u l   w h e n   y o u   w a n t   t o   p e r f o r m   k u b e c t l   a p p l y   o n   t h i s   o b j e c t   i n   t h e   f u t u r e .   I f   t r u e ,   k e e p   t h e   m a n a g e d F i e l d s   w h e n   p r i n t i n g   o b j e c t s   i n   J S O N   o r   Y A M L   f o r m a t .   T e m p l a t e   s t r i n g   o r   p a t h   t o   t e m p l a t e


Question: What is Parent Options Inherited?

Answer: U s e r n a m e   t o   i m p e r s o n a t e   f o r   t h e   o p e r a t i o n .   U s e r   c o u l d   b e   a   r e g u l a r   u s e r   o r   a   s e r v i c e   a c c o u n t   i n   a   n a m e s p a c e .   G r o u p   t o   i m p e r s o n a t e   f o r   t h e   o p e r a t i o n ,   t h i s   f l a g   c a n   b e   r e p e a t e d   t o   s p e c i f y   m u l t i p l e   g r o u p s .   U I D   t o   i m p e r s o n a t e   f o r   t h e   o p e r a t i o n .   D e f a u l t   c a c h e   d i r e c t o r y   P a t h   t o   a   c e r t   f i l e   f o r   t h e   c e r t i f i c a t e   a u t h o r i t y   P a t h   t o   a   c l i e n t   c e r t i f i c a t e   f i l e   f o r   T L S   P a t h   t o   a   c l i e n t   k e y   f i l e   f o r   T L S   T h e   n a m e   o f   t h e   k u b e c o n f i g   c l u s t e r   t o   u s e   T h e   n a m e   o f   t h e   k u b e c o n f i g   c o n t e x t   t o   u s e   I f   t r u e ,   o p t - o u t   o f   r e s p o n s e   c o m p r e s s i o n   f o r   a l l   r e q u e s t s   t o   t h e   s e r v e r   I f   t r u e ,   t h e   s e r v e r ' s   c e r t i f i c a t e   w i l l   n o t   b e   c h e c k e d   f o r   v a l i d i t y .   T h i s   w i l l   m a k e   y o u r   H T T P S   c o n n e c t i o n s   i n s e c u r e   P a t h   t o   t h e   k u b e c o n f i g   f i l e   t o   u s e   f o r   C L I   r e q u e s t s .   P a t h   t o   t h e   k u b e r c   f i l e   t o   u s e   f o r   p r e f e r e n c e s .   T h i s   c a n   b e   d i s a b l e d   b y   e x p o r t i n g   K U B E C T L _ K U B E R C = f a l s e   f e a t u r e   g a t e   o r   t u r n i n g   o f f   t h e   f e a t u r e   K U B E R C = o f f .   R e q u i r e   s e r v e r   v e r s i o n   t o   m a t c h   c l i e n t   v e r s i o n   I f   p r e s e n t ,   t h e   n a m e s p a c e   s c o p e   f o r   t h i s   C L I   r e q u e s t   P a s s w o r d   f o r   b a s i c   a u t h e n t i c a t


Question: What is See Also?

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


Question: What is kubectl replace?

Answer: kubectl replaceSynopsisReplace a resource by file name or stdin.JSON and YAML formats are accepted. If replacing an existing resource, the complete resource spec must be provided. This can be obtained by $ kubectl get TYPE NAME -o yaml kubectl replace -f FILENAME Examples # Replace a pod using the data in pod.json kubectl replace -f ./pod.json # Replace a pod based on the JSON passed into stdin cat pod.json | kubectl replace -f - # Update a single-container pod's image version (tag) to v4 kubectl get pod mypod -o yaml | sed 's/\(image: myimage\):.*$/\1:v4/' | kubectl replace -f - # Force replace, delete and then re-create the resource kubectl replace --force -f ./pod.json Options--allow-missing-template-keys Default: trueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.--cascade string[="background"] Default: "background"Must be "background", "orphan", or "foreground". Selects the deletion cascading strategy for the dependents (e.g. Pods created by a ReplicationController). Defaults to background.--dry-run string[="unchanged"] Default: "none"Must be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource.--field-manager string Default: "kubectl-replace"Name of the manager used to track field ownership.-f, --filename stringsThe files that contain the configurations to replace.--forceIf true, immediately remove resources from API and bypass graceful deletion. Note that immediate deletion of some resources may result in inconsistency or data loss and requires confirmation.--grace-period int Default: -1Period of time in seconds given to the resource to terminate gracefully. Ignored if negative. Set to 1 for immediate shutdown. Can only be set to 0 when --force is true (force deletion).-h, --helphelp for replace-k, --kustomize stringProcess a kustomization directory. This flag can't be used together with -f or -R.-o, --output stringOutput format. One of: (json, yaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file).--raw stringRaw URI to PUT to the server. Uses the transport specified by the kubeconfig file.-R, --recursiveProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.--save-configIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.--show-managed-fieldsIf true, keep the managedFields when printing objects in JSON or YAML format.--subresource stringIf specified, replace will operate on the subresource of the requested object.--template stringTemplate string or path to template file to use when -o=go-template, -o=go-templat


Question: How does kubectl replace work?

Answer: kubectl replaceSynopsisReplace a resource by file name or stdin.JSON and YAML formats are accepted. If replacing an existing resource, the complete resource spec must be provided. This can be obtained by $ kubectl get TYPE NAME -o yaml kubectl replace -f FILENAME Examples # Replace a pod using the data in pod.json kubectl replace -f ./pod.json # Replace a pod based on the JSON passed into stdin cat pod.json | kubectl replace -f - # Update a single-container pod's image version (tag) to v4 kubectl get pod mypod -o yaml | sed 's/\(image: myimage\):.*$/\1:v4/' | kubectl replace -f - # Force replace, delete and then re-create the resource kubectl replace --force -f ./pod.json Options--allow-missing-template-keys Default: trueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.--cascade string[="background"] Default: "background"Must be "background", "orphan", or "foreground". Selects the deletion cascading strategy for the dependents (e.g. Pods created by a ReplicationController). Defaults to background.--dry-run string[="unchanged"] Default: "none"Must be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource.--field-manager string Default: "kubectl-replace"Name of the manager used to track field ownership.-f, --filename stringsThe files that contain the configurations to replace.--forceIf true, immediately remove resources from API and bypass graceful deletion. Note that immediate deletion of some resources may result in inconsistency or data loss and requires confirmation.--grace-period int Default: -1Period of time in seconds given to the resource to terminate gracefully. Ignored if negative. Set to 1 for immediate shutdown. Can only be set to 0 when --force is true (force deletion).-h, --helphelp for replace-k, --kustomize stringProcess a kustomization directory. This flag can't be used together with -f or -R.-o, --output stringOutput format. One of: (json, yaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file).--raw stringRaw URI to PUT to the server. Uses the transport specified by the kubeconfig file.-R, --recursiveProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.--save-configIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.--show-managed-fieldsIf true, keep the managedFields when printing objects in JSON or YAML format.--subresource stringIf specified, replace will operate on the subresource of the requested object.--template stringTemplate string or path to template file to use when -o=go-template, -o=go-templat


Question: When would you use kubectl replace?

Answer: kubectl replaceSynopsisReplace a resource by file name or stdin.JSON and YAML formats are accepted. If replacing an existing resource, the complete resource spec must be provided. This can be obtained by $ kubectl get TYPE NAME -o yaml kubectl replace -f FILENAME Examples # Replace a pod using the data in pod.json kubectl replace -f ./pod.json # Replace a pod based on the JSON passed into stdin cat pod.json | kubectl replace -f - # Update a single-container pod's image version (tag) to v4 kubectl get pod mypod -o yaml | sed 's/\(image: myimage\):.*$/\1:v4/' | kubectl replace -f - # Force replace, delete and then re-create the resource kubectl replace --force -f ./pod.json Options--allow-missing-template-keys Default: trueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.--cascade string[="background"] Default: "background"Must be "background", "orphan", or "foreground". Selects the deletion cascading strategy for the dependents (e.g. Pods created by a ReplicationController). Defaults to background.--dry-run string[="unchanged"] Default: "none"Must be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource.--field-manager string Default: "kubectl-replace"Name of the manager used to track field ownership.-f, --filename stringsThe files that contain the configurations to replace.--forceIf true, immediately remove resources from API and bypass graceful deletion. Note that immediate deletion of some resources may result in inconsistency or data loss and requires confirmation.--grace-period int Default: -1Period of time in seconds given to the resource to terminate gracefully. Ignored if negative. Set to 1 for immediate shutdown. Can only be set to 0 when --force is true (force deletion).-h, --helphelp for replace-k, --kustomize stringProcess a kustomization directory. This flag can't be used together with -f or -R.-o, --output stringOutput format. One of: (json, yaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file).--raw stringRaw URI to PUT to the server. Uses the transport specified by the kubeconfig file.-R, --recursiveProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.--save-configIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.--show-managed-fieldsIf true, keep the managedFields when printing objects in JSON or YAML format.--subresource stringIf specified, replace will operate on the subresource of the requested object.--template stringTemplate string or path to template file to use when -o=go-template, -o=go-templat