From a1810c9a12f6839ef84a26c39467d2649c166d90 Mon Sep 17 00:00:00 2001 From: lkxed Date: Sun, 14 Aug 2022 10:12:42 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[=E6=89=8B=E5=8A=A8=E9=80=89=E9=A2=98][tech?= =?UTF-8?q?]:=2020220813=20What=20is=20PDB=20in=20Kubernetes-.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20220813 What is PDB in Kubernetes-.md | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 sources/tech/20220813 What is PDB in Kubernetes-.md diff --git a/sources/tech/20220813 What is PDB in Kubernetes-.md b/sources/tech/20220813 What is PDB in Kubernetes-.md new file mode 100644 index 0000000000..71d6784534 --- /dev/null +++ b/sources/tech/20220813 What is PDB in Kubernetes-.md @@ -0,0 +1,104 @@ +[#]: subject: "What is PDB in Kubernetes?" +[#]: via: "https://kerneltalks.com/virtualization/what-is-pdb-in-kubernetes/" +[#]: author: "kerneltalks https://www.facebook.com/kerneltalks/" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +What is PDB in Kubernetes? +====== +Ever wondered what is PDB i.e. Pod Disruption Budget in the Kubernetes world? Then this small post is just for you! + +![][1] + +PDB i.e. Pod Disruption Budget is a method to make sure the minimum number of Pods are always available for a certain application in the Kubernetes cluster. That is a kind of one-liner for explaining PDB 🙂 Let’s dive deeper and understand what is PDB. What does PDB offer? Should I define PDB for my applications? etc. + +#### What is Pod Disruption Budget? + +The Replicaset in Kubernetes helps us to keep multiple replicas of the same Pod to handle the load or add an extra layer of availability in containerized applications. But, those replicas are tossed during cluster maintenance or scaling actions if you don’t tell the control plane (Kubernetes master/ Kubernetes API server) how they should be terminated. + +The PDB is a way to let control plane how the Pods in a certain Replicaset should be terminated. The PDB is a Kubernetes kind that should be associated with the Deployment kind. + +#### How PDB is defined? + +It’s a very small kind and offers only three fields to configure: + +* spec.selector: Defines the Pods to which PDB will be applied +* spec.minAvailable: An absolute number or percentage. It’s the number of Pods that should always remain in a running state during evictions. +* spec.maxUnavailable: An absolute number or percentage. It’s the maximum number of Pods that can be unavailable during evictions. +* You can only specify either `spec.minAvailable` or `spec.maxUnavailable` + +A sample Kubernetes manifest for PDB looks like this – + +``` +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: sample-pdb + namespace: #optional + Annotations: #optional + key: value + labels: #optional + key: value +spec: + minAvailable: 1 + selector: + matchLabels: + app: web +``` + +Here – + +* metadata: The PDB name, the namespace in which PDB lives, annotations and labels that are applied to the PDB itself. +* spec: It’s a PDB config we discussed above. + +#### How does PDB work? + +Let’s look at how this configuration takes into effect. For better understanding, we will consider a simple application that has 5 replicas. + +Case 1: PDB is configured with minAvailable to be 3. + +This means we are telling the control plane that it can evict at most (5 running – 3 minavailable) 2 Pods at a time. That means we are allowing 2 disruptions at a time. This value is also called *disruptionsAllowed*. So, in a situation where the control plane needs to move all the 5 Pods, it will evict 2 Pods first then once those 2 evicted Pods, respawns on the new node and goes into the `Running` state, it will evict the next 2 and lastly 1. In a process, it makes sure that there are always 3 Pods in the `Running` state. + +Case 2: PDB is configured with maxUnavailable to be 2 + +It’s the same effect as above! Basically, you are telling the control plane at any given point of time 2 Pods can be evicted meaning 5-2 = 3 Pods should be running! + +The `Allowed Disruptions` is calculated on the fly. It always considers the Pods in `Running` state only. Continuing with the above example, if out of 5 Pods, 2 Pods are not in a `Running` state (for maybe some reason) then *disruptionsAllowed*is calculated as 3-3=0. This means only 3 Pods are in the `Running` state and all 3 should not be evicted since PDB says it wants a minimum of 3 Pods in the `Running` state all the time. + +In a nutshell: *disruptionsAllowed = Number of RUNNING Pods – minAvailable value* + +#### How to check Pod Disruption Budget? + +One can use the below command to check the PDB – + +``` +$ kubectl get poddisruptionbudgets -n +``` + +Then, `kubectl describe` can be used to get the details of each PDB fetched in the output of the previous command. + +#### Should I define PDB for my applications? + +Yes, you should! It’s a good practice to calculate and properly define the PDB to make your application resilient to Cluster maintenance/scaling activities. + +The minimum number is to have minAvailable as 1 and replicas 2. Or make sure that minAvailable is always less than the replica count. The wrongly configured PDB will not allow Pod evictions and may disturb the cluster activities. Obviously, cluster admins can force their way in but then it means downtime in your applications. + +You can also implement cluster constraints for PDB so that new applications won’t be allowed to deploy unless they have PDB manifest as well in the code. + +-------------------------------------------------------------------------------- + +via: https://kerneltalks.com/virtualization/what-is-pdb-in-kubernetes/ + +作者:[kerneltalks][a] +选题:[lkxed][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.facebook.com/kerneltalks/ +[b]: https://github.com/lkxed +[1]: https://z5.kerneltalks.com/wp-content/uploads/2022/08/pod-disruption-budget.png From a12d6f052e19bbc4375aa3d1f795d58539005f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AD=E5=BC=80=E7=AE=B1?= Date: Sun, 14 Aug 2022 10:42:38 +0800 Subject: [PATCH 2/2] Delete Test.md --- sources/tech/Test.md | 76 -------------------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 sources/tech/Test.md diff --git a/sources/tech/Test.md b/sources/tech/Test.md deleted file mode 100644 index 170f99a23e..0000000000 --- a/sources/tech/Test.md +++ /dev/null @@ -1,76 +0,0 @@ -[#]: subject: "Linux Kernel 6.0 is Likely the Next Version Upgrade With Initial Rust Code" -[#]: via: "https://news.itsfoss.com/linux-kernel-6-0-reveal" -[#]: author: "Anuj Sharma https://news.itsfoss.com/author/anuj/" -[#]: collector: "lkxed" -[#]: translator: " " -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -Linux Kernel 6.0 is Likely the Next Version Upgrade With Initial Rust Code -====== - -You might be aware of the fact that Linus Torvalds used an Apple MacBook hardware to release [Linux Kernel 5.19][1]. - -But, the news wasn’t limited to one interesting observation. - -Linus Torvalds also mentioned at the end of the [release announcement][2] that he might call the next version upgrade of Linux Kernel as 6.0. - -#### Linux Version Numbers Decoded: Why 6.0? - -So, why the change in version numbers for an upgrade? - -To understand the versioning scheme, let us take an example of **Linux Kernel 5.18.5** (that’s what I’m running on my system). - -If you want to check the Linux Kernel version on your system, simply head to the terminal and type in: - -``` -uname -r -``` - -- The first number ‘5’ represents the major version -- The second number, ’18’ represents the series of minor updates. -- The third number, ’15,’ represents the patch version - -The Linux Kernel usually follows the [Semantic Versioning][3] (A versioning system used in open source software). - -However, when it comes to major upgrades, the developers seem to avoid numbers that seem too big. - -So, instead of going with Linux Kernel 5.20, it will just be Linux Kernel 6.0 (or Linux 6.0). There’s no hard rule on this, only when Linus Torvalds gets worried with the number, we have a shorter version number. - -Linus Torvalds mentioned the same for changing the version number in the mailing list: - -> I’ll likely call it 6.0 since I’m starting to worry about getting confused by big numbers again. - -#### New Features Coming to Linux 6.0 - -If you are curious, here are some features that might be a part of the Linux Kernel 6.0 release: - -- Inclusion of Rust code (early phase) -- Real-time Kernel building support -- New Hardware support -- Usual Improvements to various Filesystems -- Scheduler changes - -Most of the anticipated feature additions are likely to be technical changes, so you may not have enough to get excited about as an end-user. - -But, it should be huge if the initial Rust code arrives with the next Linux Kernel upgrade. - -_So, what do you think about the upcoming Linux Kernel 6.0? Do you wish to see Rust kernel code land?_ - --------------------------------------------------------------------------------- - -via: https://news.itsfoss.com/linux-kernel-6-0-reveal - -作者:[Anuj Sharma][a] -选题:[lkxed][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://news.itsfoss.com/author/anuj/ -[b]: https://github.com/lkxed -[1]: https://news.itsfoss.com/linux-kernel-5-19-release/ -[2]: https://lore.kernel.org/all/CAHk-=wgrz5BBk=rCz7W28Fj_o02s0Xi0OEQ3H1uQgOdFvHgx0w@mail.gmail.com/ -[3]: https://semver.org/