Komodor is a Kubernetes management platform that empowers everyone from Platform engineers to Developers to stop firefighting, simplify operations and proactively improve the health of their workloads and infrastructure.
Proactively detect & remediate issues in your clusters & workloads.
Easily operate & manage K8s clusters at scale.
Reduce costs without compromising on performance.
Empower developers with self-service K8s troubleshooting.
Simplify and accelerate K8s migration for everyone.
Fix things fast with AI-powered root cause analysis.
Explore our K8s guides, e-books and webinars.
Learn about K8s trends & best practices from our experts.
Listen to K8s adoption stories from seasoned industry veterans.
The missing UI for Helm – a simplified way of working with Helm.
Visualize Crossplane resources and speed up troubleshooting.
Validate, clean & secure your K8s YAMLs.
Navigate the community-driven K8s ecosystem map.
Kubernetes 101: A comprehensive guide
Expert tips for debugging Kubernetes
Tools and best practices
Kubernetes monitoring best practices
Understand Kubernetes & Container exit codes in simple terms
Exploring the building blocks of Kubernetes
Cost factors, challenges and solutions
Kubectl commands at your fingertips
Understanding K8s versions & getting the latest version
Rancher overview, tutorial and alternatives
Kubernetes management tools: Lens vs alternatives
Troubleshooting and fixing 5xx server errors
Solving common Git errors and issues
Who we are, and our promise for the future of K8s.
Have a question for us? Write us.
Come aboard the K8s ship – we’re hiring!
Hear’s what they’re saying about Komodor in the news.
Kubernetes Pod Disruption Budgets (PDBs) are a feature designed to ensure that a specified minimum number of pods are always running for an application, even during voluntary disruptions such as upgrades or maintenance.
By defining a PDB, developers can set policies that limit the number of pods that can be simultaneously disrupted, maintaining the application’s availability and reliability. A PDB applies to pods that match certain criteria defined by the user, typically through label selectors. It specifies either a minimum number of available pods or a maximum percentage of pods that may be unavailable during voluntary disruptions.
This mechanism helps in preventing the application from becoming unavailable or underperforming due to an insufficient number of running pods, ensuring continuous operation and service reliability, especially in production environments.
Pod Disruption Budgets define a set of conditions that must be met before Kubernetes can safely perform voluntary disruptions on pods.
When an operation, such as a node upgrade or application scaling, requires pod termination, Kubernetes first checks the PDB associated with those pods. If the operation would violate the PDB’s conditions—either by making too many pods unavailable or dropping below the minimum availability threshold—the operation is delayed until it can comply with the PDB.
This process ensures that critical applications maintain their required level of service even during maintenance activities. For example, if a PDB specifies that at least three instances of a particular service must be available at all times, Kubernetes will not evict pods from this service if doing so would reduce its running instances below three.
Similarly, if a maximum unavailability is defined, Kubernetes respects this limit and orchestrates pod disruptions in a way that does not exceed it. This selective disruption management allows for cluster operations and maintenance while preserving application stability and availability.
Related content: Read our guide to horizontal pod autoscaler
Itiel Shwartz
Co-Founder & CTO
In my experience, here are tips that can help you better manage and utilize Kubernetes Pod Disruption Budgets (PDBs):
Define multiple PDBs for different application components to ensure critical parts remain highly available.
Automate the creation and validation of PDBs within your CI/CD pipelines to enforce consistency.
Conduct regular maintenance tests to ensure PDB configurations are effective under real-world conditions.
Use monitoring tools like Prometheus to track the effectiveness of your PDBs and adjust as necessary.
Use PDBs alongside Cluster Autoscaler to ensure that disruptions are handled smoothly even as the cluster scales.
Implementing PDBs in Kubernetes clusters provides the following benefits:
Here’s an overview of how to configure, manage and monitor PDBs in Kubernetes.
To configure a Pod Disruption Budget, you define it in a YAML file. This file outlines the rules that Kubernetes must follow when performing voluntary disruptions, ensuring that the specified number of pods remains available. Here is an example of a simple PDB configuration:
apiVersion: policy/v1kind: PodDisruptionBudgetmetadata: name: example-pdbspec: minAvailable: 1 selector: matchLabels: app: exampleapp
In this configuration, minAvailable specifies the minimum number of pods that must remain available at all times, ensuring at least one instance of the application is always running. The selector uses matchLabels to identify which pods fall under this PDB’s policy, targeting those with the app: exampleapp label. This setup prevents Kubernetes from evicting all instances during operations like updates or node maintenance.To adapt to different scenarios or more complex applications, you might opt for specifying maxUnavailable instead of minAvailable. This approach allows a certain percentage or number of pods to be unavailable during disruptions:
minAvailable
matchLabels
app: exampleapp
maxUnavailable
apiVersion: policy/v1kind: PodDisruptionBudgetmetadata: name: my-pdb-flexiblespec: maxUnavailable: 25% selector: matchLabels: app: myflexibleapp
Here, maxUnavailable allows up to a quarter of targeted pods to be disrupted simultaneously. This is particularly useful for applications that can tolerate temporary reductions in capacity without affecting overall functionality or performance.
To manage and monitor Pod Disruption Budgets, you can use Kubernetes command-line tools like kubectl. For example, to get a list of all PDBs in your system, you would execute the kubectl get pdb command. This command provides a concise overview of existing PDBs, including their names and how many pods are currently healthy versus the total number of pods that match the PDB’s selector criteria.
kubectl
kubectl get pdb
For more detailed information about a specific PDB, such as its configuration and status, use this command:
kubectl describe pdb <pdb-name>
The describe pdb command outputs detailed information including the selector criteria, current status of pods matching the PDB criteria (e.g., how many are currently available), and events related to the PDB. This is useful for troubleshooting or ensuring that your disruption budgets are configured correctly.
describe
Here are some of the ways that you can ensure the availability and stability of your Kubernetes applications with PDBs.
Selectors define the scope of a PDB, targeting the pods it will protect. They function by matching labels assigned to pods, enabling precise control over which pods fall under the PDB’s policy. This precision is crucial for ensuring that PDBs apply only to intended pods, avoiding unintended protection of non-critical pods that could otherwise consume valuable resources.
To maximize the effectiveness of selectors, use clear and consistent labeling strategies for your pods. Labels should accurately reflect the role, environment, and other significant characteristics of each pod. This enables more efficient resource management and enhances the clarity and maintainability of your Kubernetes configurations.
Instead of specifying a fixed number of pods that must remain available, you can define the required availability as a percentage. This approach automatically adjusts to the size of your deployment, ensuring that the proportion of available pods remains constant, regardless of how your application scales.
For example, setting minAvailable to 60% means that at least 60% of the targeted pods must always be available. This method is particularly useful in dynamic environments where application workloads change or scale frequently.
Integrating PDBs with Kubernetes objects like deployments, StatefulSets, and ReplicaSets enhances application resilience. These objects manage the pods’ desired state, including their number and lifecycle. When a PDB is used in conjunction with these controllers, it ensures that voluntary disruptions do not cause the number of available replicas to fall below the specified threshold.
This setup automates the enforcement of availability policies during updates or node maintenance. It also simplifies management by leveraging the controllers’ built-in mechanisms for rolling updates and automatic replacements. For example, when a deployment is updated, it tries to maintain availability according to its strategy (e.g., RollingUpdate), while also respecting any PDBs that apply to its pods.
RollingUpdate
Pod Disruption Budgets are designed to protect against voluntary disruptions, but it’s essential to consider involuntary disruptions such as hardware failures or network issues. These events can impact your application’s availability outside the scope of PDBs.
To mitigate these risks, ensure your Kubernetes cluster is sufficiently resilient. This involves strategies like distributing pods across multiple nodes or availability zones, which helps prevent a single point of failure from affecting your application’s overall availability. Monitoring and alerting systems can provide early warnings for involuntary disruptions, allowing you to take action before they impact your services.
Monitoring PDBs is essential for ensuring they function as intended and provide the expected level of protection against disruptions. Regular monitoring allows you to verify that the PDB settings align with your application’s availability requirements and to adjust them as those requirements evolve.
Use kubectl get pdb to list all PDBs and their current status, which shows how many pods are protected and whether any disruptions are currently blocked due to the PDB constraints.
In addition to command-line tools, consider integrating Kubernetes monitoring solutions that can track PDB status changes and alert you to potential issues.
Kubernetes troubleshooting relies on the ability to quickly contextualize the problem with what’s happening in the rest of the cluster. More often than not, you will be conducting your investigation during fires in production. The major challenge is correlating service-level incidents with other events happening in the underlying infrastructure.
Komodor can help with its ‘Node Status’ view, built to pinpoint correlations between service or deployment issues and changes in the underlying node infrastructure. With this view you can rapidly:
Beyond node error remediations, Komodor can help troubleshoot a variety of Kubernetes errors and issues. As the leading Continuous Kubernetes Reliability Platform, Komodor is designed to democratize K8s expertise across the organization and enable engineering teams to leverage its full value.
Komodor’s platform empowers developers to confidently monitor and troubleshoot their workloads while allowing cluster operators to enforce standardization and optimize performance. Specifically when working in a hybrid environment, Komodor reduces the complexity by providing a unified view of all your services and clusters.
By leveraging Komodor, companies of all sizes significantly improve reliability, productivity, and velocity. Or, to put it simply – Komodor helps you spend less time and resources on managing Kubernetes, and more time on innovating at scale.
If you are interested in checking out Komodor, use this link to sign up for a Free Trial.
Share:
How useful was this post?
Click on a star to rate it!
Average rating 5 / 5. Vote count: 6
No votes so far! Be the first to rate this post.
and start using Komodor in seconds!